Created
April 16, 2021 20:23
-
-
Save amirgon/38a418f08f74358b4efeec5eb7dc9a3f to your computer and use it in GitHub Desktop.
Tracing Micropython code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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