Skip to content

Instantly share code, notes, and snippets.

@crass
crass / gdb_trace.py
Created February 8, 2023 03:12 — forked from stettberger/gdb_trace.py
GDB Function Call Trace
# Example Invocation:
#
# gcc test.c -o test -g
# TRACE_FUNCTIONS=fib TRACE_FILE=log gdb -x gdb_trace.py test
# cat log
#
# Log File Format:
#
# ('call', Parent Call ID, Call ID, Breakpoint Name, Symbol Name, Arguments)
# ('return', Call Id, Breakpoint Name, Return Value)
>>> class A(object):
... blah = []
... def hmm(self):
... self.blah.append("hmm")
...
>>> test = A()
>>> test.hmm()
>>> test.blah
['hmm']
>>> test2 = A()