Caterpillar

Daily Thought - 2024-08-27

< back to list

I've been talking about call stack reconstruction, starting with a simple case. Let's move on to a slightly more complicated one.

Let's say you have the stack frame of function a on the call stack, its active expression is a call to function b, but the next stack frame belongs to function c. This is not right. We have detected a gap! At the very least, a single stack frame (for b) is missing.

So before showing the active functions in the debugger, we add the missing b. And we know that only tail call elimination removes stack frames, so the active expression is the last one. From there we can repeat the check: is that last expression a call to c? If not, there still is a gap, and we can keep adding missing functions until it's closed.

<< previous thoughtnext thought >>