Skip to content

Commit

Permalink
Better trace printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gm281 committed Aug 5, 2014
1 parent 009970c commit 21d6d08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ def trace(debugger, command, result, internal_dict):
# to verify the address.
if parent_instrumented_frame != None and parent_instrumented_frame.is_stopped_on_return(frame):
print >>result, "Stopped on return, popping a frame"
destination = frame.GetSymbol().GetName()
offset = frame.GetPCAddress().GetFileAddress() - frame.GetSymbol().GetStartAddress().GetFileAddress()
print >>result, "T: {destination} + {offset:#x} <==".format(destination=destination, offset=offset)
instrumented_frame.clear()
instrumented_frame = instrumented_frames.pop()
instrumented_frame.clear_return_breakpoint()
Expand All @@ -306,15 +309,24 @@ def trace(debugger, command, result, internal_dict):
success = instrumented_frame.clear_calls_and_jmps_and_instrument_return(frame)
if not success:
break
caller = frame.GetSymbol().GetName()
offset = frame.GetPCAddress().GetFileAddress() - frame.GetSymbol().GetStartAddress().GetFileAddress()
thread.StepInstruction(False)
destination = thread.GetFrameAtIndex(0).GetSymbol().GetName()
print >>result, "T: {caller} + {offset:#x} ==> {destination}".format(caller=caller, offset=offset, destination=destination)
instrumented_frames.append(instrumented_frame)
instrumented_frame = None
frame = thread.GetFrameAtIndex(0)
print >>result, 'Entered new frame at: 0x%lx' % frame.GetPC()
elif instrumented_frame.is_stopped_on_jmp(frame, False):
print >>result, "Stopped on jmp"
caller = frame.GetSymbol().GetName()
caller_offset = frame.GetPCAddress().GetFileAddress() - frame.GetSymbol().GetStartAddress().GetFileAddress()
thread.StepInstruction(False)
frame = thread.GetFrameAtIndex(0)
destination = frame.GetSymbol().GetName()
destination_offset = frame.GetPCAddress().GetFileAddress() - frame.GetSymbol().GetStartAddress().GetFileAddress()
print >>result, "T: {caller} + {caller_offset:#x} === {destination} + {destination_offset:#16x}".format(caller=caller, caller_offset=caller_offset, destination=destination, destination_offset=destination_offset)
instrumented_frame.update_frame(frame)
instrumented_frame.instrument_calls_and_jmps()
else:
Expand Down

0 comments on commit 21d6d08

Please sign in to comment.