← index #7372PR #4265
Related · high · value 1.231
QUERY · ISSUE

py: settrace is incompatible with Interrupt Handlers

openby amirgonopened 2021-06-08updated 2021-06-09
py-core

When MICROPY_PY_SYS_SETTRACE is enabled, bytecode execution allocates RAM, which is forbidden on interrupt handlers.

https://github.com/micropython/micropython/blob/4d9e657f0ee881f4a41093ab89ec91d03613744d/py/vm.c#L142-L149

https://github.com/micropython/micropython/blob/e9e9c76ddf131f8e50b0ae2d44501d3cd88537ef/py/profile.c#L315-L318

CANDIDATE · PULL REQUEST

Profiling: sys.settrace implementation.

closedby malinahopened 2018-10-24updated 2019-08-30

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied