py: Integrate sys.settrace feature into the VM and runtime.

This commit adds support for sys.settrace, allowing to install Python
handlers to trace execution of Python code.  The interface follows CPython
as closely as possible.  The feature is disabled by default and can be
enabled via MICROPY_PY_SYS_SETTRACE.
This commit is contained in:
Milan Rossa
2019-08-14 16:09:36 +02:00
committed by Damien George
parent c96aedad46
commit 310b3d1b81
15 changed files with 201 additions and 1 deletions

View File

@@ -253,6 +253,12 @@ typedef struct _mp_state_thread_t {
mp_obj_dict_t *dict_globals;
nlr_buf_t *nlr_top;
#if MICROPY_PY_SYS_SETTRACE
mp_obj_t prof_trace_callback;
bool prof_callback_is_executing;
struct _mp_code_state_t *current_code_state;
#endif
} mp_state_thread_t;
// This structure combines the above 3 structures.