POP instruction causes process continuation


I have the following i386 assembly code:

Try getting a backtrace at each location. Stepping is very sensitive to stacks being able to correctly unwind themselves. If the stack is wrong, it might change the behavior of the step. So repeat with "bt" between each one.

step-over of any sort as currently implemented depends on being able to tell whether the current frame is older or younger than the frame we started in. So if we step and end up in a frame that is younger than the one we started from, we step back out to the parent frame. Your pop %ebp is fooling the unwinder into thinking this is a newer frame, so we try to step back out, which turns into a continue. You are adding instructions that look like frame setup instructions, which is probably what is fooling us.

We can probably make this work better in odd cases like this by taking a look at the instruction we are about to execute, and if it is not a branch, then we know it hasn't pushed a real new execution frame, so we should stop. The nice thing about dealing just the results of each operation, rather than trying to predict what each instruction is going to do, is that we don't have to reason about all the instructions in the instruction set. The downside is that you do get fooled by odd patterns like this. I'm not sure corner-cases like this are enough to motivate me to switch to a more architecture-specific algorithm, however.

For now, just use "step-inst" not "next-inst" when you are stepping over code that looks like it might be frame setup but isn't.