diff options
author | Milan Rossa <rossa.milan@gmail.com> | 2019-08-14 16:09:36 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-08-30 16:44:12 +1000 |
commit | 310b3d1b81d561e19d719acd89ee47b759e3795c (patch) | |
tree | 18beb2d50b30dd525fc57efd43a7e705e777fade /py/compile.c | |
parent | c96aedad4691d864c073890a7a20abc7ebd2de27 (diff) |
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.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/compile.c b/py/compile.c index 41ff66a8c..8b2d820b3 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1608,6 +1608,9 @@ STATIC void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_ qstr qstr_exception_local = 0; uint end_finally_label = comp_next_label(comp); + #if MICROPY_PY_SYS_SETTRACE + EMIT_ARG(set_source_line, pns_except->source_line); + #endif if (MP_PARSE_NODE_IS_NULL(pns_except->nodes[0])) { // this is a catch all exception handler @@ -3157,6 +3160,9 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { scope_find_or_add_id(scope, MP_QSTR___class__, ID_INFO_KIND_LOCAL); } + #if MICROPY_PY_SYS_SETTRACE + EMIT_ARG(set_source_line, pns->source_line); + #endif compile_load_id(comp, MP_QSTR___name__); compile_store_id(comp, MP_QSTR___module__); EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name |