Patent ID: 7350196

Claim:
A method to trace an instrumented program, comprising: triggering a trap instruction in the instrumented program during tracing of the instrumented program; transferring control of the instrumented program to a trap handler associated with the trap instruction; calling into a tracing framework, by the trap handler, to perform a tracing operation associated with the trap instruction; performing the tracing operation to obtain tracing information, wherein the tracing information is used to analyze the instrumented program; and emulating, after performing the tracing operation, an original instruction in the instrumented program using the trap handler, wherein the original instruction is associated with the trap instruction, wherein the original instruction relates to creating or dismantling a stack frame, wherein emulating the original instruction comprises emulating a push1 instruction, and wherein emulating the push1 instruction comprises: obtaining a stack pointer location, wherein the stack pointer location corresponds to a location in the stack frame; incrementing an instruction pointer to obtain an incremented instruction pointer; loading the incremented instruction pointer in the stack frame at one location before the stack pointer location; loading a code segment (CS) value stored one location after the stack pointer location into the stack pointer location; loading an EFLAGS value stored two locations after the stack pointer location into one location after the stack pointer; and loading a base pointer into two locations after the stack pointer location.