Improve sys.settrace to help support debugpy / pdb debugging#8767
Improve sys.settrace to help support debugpy / pdb debugging#8767andrewleech wants to merge 1 commit into
Conversation
16bd204 to
e027113
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8767 +/- ##
==========================================
- Coverage 98.46% 98.39% -0.08%
==========================================
Files 176 176
Lines 22784 22816 +32
==========================================
+ Hits 22435 22450 +15
- Misses 349 366 +17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Requires micropython to be compiled with MICROPY_PY_SYS_SETTRACE. Also requires micropython/micropython#8767
Requires micropython to be compiled with MICROPY_PY_SYS_SETTRACE. Also requires micropython/micropython#8767
Requires micropython to be compiled with MICROPY_PY_SYS_SETTRACE. Also requires micropython/micropython#8767
| MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_gettrace_obj, mp_sys_gettrace); | ||
|
|
||
| // _getframe(): Return current frame object. | ||
| STATIC mp_obj_t mp_sys_getframe(size_t n_args, const mp_obj_t *args) { |
There was a problem hiding this comment.
please call it mp_sys__getframe
| if (attr == MP_QSTR___code__) { | ||
| mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in); | ||
| mp_obj_code_t *code = MP_OBJ_TO_PTR(mp_obj_new_code(self->context, self->rc)); | ||
| if (code != NULL) { |
| case MP_QSTR_f_back: | ||
| dest[0] = mp_const_none; | ||
| if (o->code_state->prev_state) { | ||
| if (!o->code_state->prev_state->frame) { |
There was a problem hiding this comment.
did you find a case where this could be NULL? maybe it needs a test...
| dest[0] = o->trace_obj; | ||
| break; | ||
| case MP_QSTR_f_locals: | ||
| dest[0] = MP_OBJ_FROM_PTR(o->code->dict_locals); |
There was a problem hiding this comment.
is this needed? locals in uPy doesn't work well
There was a problem hiding this comment.
can we just return an empty dict instead?
| o->lineno = mp_prof_bytecode_lineno(rc, o->lasti); | ||
| o->trace_opcodes = false; | ||
| o->callback = MP_OBJ_NULL; | ||
| o->trace_obj = MP_OBJ_NULL; |
|
|
||
| // This is the implementation for the sys.settrace | ||
| mp_obj_t mp_prof_settrace(mp_obj_t callback); | ||
| mp_obj_t mp_prof_gettrace(); |
| return mp_const_none; | ||
| } | ||
|
|
||
| mp_obj_t mp_prof_gettrace() { |
| return prof_trace_cb; | ||
| } | ||
|
|
||
| mp_obj_t mp_prof_get_frame(int depth) { |
There was a problem hiding this comment.
can we change int to size_t to indicate it can't be negative?
Requires micropython to be compiled with MICROPY_PY_SYS_SETTRACE. Also requires micropython/micropython#8767
f3c6bf2 to
c32fec4
Compare
|
Code size report: |
Re-enable binascii.crc32()
|
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Requires micropython to be compiled with MICROPY_PY_SYS_SETTRACE. Also requires micropython/micropython#8767
0bbcb6e to
e0237a8
Compare
Add sys.gettrace() to mirror settrace, add sys._getframe() for stack frame inspection, and enable sys.settrace() by default on unix standard variant. These additions provide the baseline infrastructure needed for pdb and debugpy to function on MicroPython. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
e0237a8 to
3280c2a
Compare
Companion support for micropython/micropython-lib#1022 & micropython/micropython-lib#499
Requires micropython be built with
MICROPY_PY_SYS_SETTRACEeg. unix standard variantIncludes:
sys/settrace: Add sys._getframe() function.
Refer to https://docs.python.org/3/library/sys.html#sys._getframe
sys/settrace: Add frame.f_trace object support.
f_traceholds a python obj on the frame, used inbdbto track active trace function for call stack.