A method for tracing an instrumented program, including triggering an trap
instruction in the instrumented program, transferring control of the
instrumented program to a trap handler associated with the trap
instruction, and emulating an instruction corresponding to the trap
instruction in the trap handler, wherein the instruction relates to
creating or dismantling a stack frame.