track program execution

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
ardthusiast
Posts: 25
Joined: Tue Feb 08, 2022 4:13 pm

track program execution

Post by ardthusiast » Sun May 15, 2022 6:30 pm

Hello, I was wondering if there's a way to track the execution of Micropython code. Similar to this CPython library.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: track program execution

Post by KJM » Mon May 16, 2022 1:33 am

Thonny has some built it program tracking but I find it's hard to beat a few well placed print statements. See also viewtopic.php?f=2&t=12411

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: track program execution

Post by stijn » Mon May 16, 2022 8:20 am

If you build with MICROPY_PY_SYS_SETTRACE defined (e.g. make CFLAGS_EXTRA="-DMICROPY_PY_SYS_SETTRACE=1") the sys.settrace (https://docs.python.org/3/library/sys.html#sys.settrace) functionality becomes available. Not completely the same as the trace module, but does track all calls. You can use the test to get an idea what the output is: https://github.com/micropython/micropyt ... eatures.py

Post Reply