sys.settrace issue (bug?)
Hi,
when I have the following code
def test():
for a in range(10):
if a == 7:
print("it worked")
print("again")
print("or not.")
test()
then sys.settrace fires at the line containing print("or not.") even if the condition a==7 is False.
for the debugger I am writing, see https://github.com/wolfc01/micropython_debugger/blob/main/debugger.py
Probably this has to do with entering or leaving some local scope?
When I run the very same debugger and example in python 3, above effect does not occur.
Best regards
Carl.
Profiling: sys.settrace implementation.
This is a working concept of profiling API related to issue #3864.
Please review this pull-request and comment especially on the overall integration into the Micropython.
So far the main concern of the profiler is runtime instruction tracing used to create detailed code coverage reports. To achieve this the analogue of sys.settrace was implemented and puts Micropython closer to feature a debugger #3009.
Building and Running
So far only the Unix port is concerned.
Enable profiling in ports/unix/mpconfigport.h like so:
#define MICROPY_PY_SYS_SETTRACE (1)
MICROPY_PERSISTENT_CODE_SAVE is required by the MICROPY_PY_SYS_TRACE.
Python API
sys.settrace(tracefunc)
As defined in original Python3 documentation sys.settrace(tracefunc). The Frame object and Code objects are only partially implemented.