Skip to content

Instantly share code, notes, and snippets.

@amirgon
Created April 16, 2021 20:23
Show Gist options
  • Save amirgon/38a418f08f74358b4efeec5eb7dc9a3f to your computer and use it in GitHub Desktop.
Save amirgon/38a418f08f74358b4efeec5eb7dc9a3f to your computer and use it in GitHub Desktop.
Tracing Micropython code
import sys
# See: https://pymotw.com/2/sys/tracing.html
def mp_trace(frame, event, arg):
co = frame.f_code
func_name = co.co_name
func_line_no = frame.f_lineno
func_filename = co.co_filename
print('[%s] [%s] %s:%s' % (event, func_name, func_filename, func_line_no))
return mp_trace
sys.settrace(mp_trace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment