py: settrace is incompatible with Interrupt Handlers
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
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.