Skip to content

Instantly share code, notes, and snippets.

@kergoth
Last active March 2, 2022 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kergoth/3f0b24517194d4dd805028dd400bdd04 to your computer and use it in GitHub Desktop.
Save kergoth/3f0b24517194d4dd805028dd400bdd04 to your computer and use it in GitHub Desktop.
def trace_calls():
import inspect, sys, traceback
def tracer(frame, event, arg):
if event == 'call':
lineno = frame.f_lineno
co = frame.f_code
filename = co.co_filename
name = co.co_name
if filename.startswith(sys.prefix):
return
summary = traceback.FrameSummary(filename, lineno, name, lookup_line=False, locals=frame.f_locals)
for i in traceback.format_list([summary]):
bb.warn(i)
sys.setprofile(tracer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment