py: Fix compiling with debug enabled and make more use of DEBUG_printf.
DEBUG_printf and MICROPY_DEBUG_PRINTER is now used instead of normal printf, and a fault is fixed in mp_obj_class_lookup with debugging enabled; see issue #3999. Debugging can now be enabled on all ports including when nan-boxing is used.
This commit is contained in:
parent
da2d2b6d88
commit
b630dfcc1d
|
@ -76,6 +76,9 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG_PRINT
|
||||
#if !MICROPY_DEBUG_PRINTERS
|
||||
const size_t len = 0;
|
||||
#endif
|
||||
DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
|
||||
#endif
|
||||
#if MICROPY_DEBUG_PRINTERS
|
||||
|
|
3
py/gc.c
3
py/gc.c
|
@ -910,7 +910,8 @@ void gc_dump_alloc_table(void) {
|
|||
GC_EXIT();
|
||||
}
|
||||
|
||||
#if DEBUG_PRINT
|
||||
#if 0
|
||||
// For testing the GC functions
|
||||
void gc_test(void) {
|
||||
mp_uint_t len = 500;
|
||||
mp_uint_t *heap = malloc(len);
|
||||
|
|
8
py/map.c
8
py/map.c
|
@ -423,13 +423,13 @@ void mp_set_clear(mp_set_t *set) {
|
|||
#if defined(DEBUG_PRINT) && DEBUG_PRINT
|
||||
void mp_map_dump(mp_map_t *map) {
|
||||
for (size_t i = 0; i < map->alloc; i++) {
|
||||
if (map->table[i].key != NULL) {
|
||||
if (map->table[i].key != MP_OBJ_NULL) {
|
||||
mp_obj_print(map->table[i].key, PRINT_REPR);
|
||||
} else {
|
||||
printf("(nil)");
|
||||
DEBUG_printf("(nil)");
|
||||
}
|
||||
printf(": %p\n", map->table[i].value);
|
||||
DEBUG_printf(": %p\n", map->table[i].value);
|
||||
}
|
||||
printf("---\n");
|
||||
DEBUG_printf("---\n");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -257,8 +257,8 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
|
|||
dump_args(args, n_args);
|
||||
DEBUG_printf("Input kw args: ");
|
||||
dump_args(args + n_args, n_kw * 2);
|
||||
|
||||
mp_obj_fun_bc_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
DEBUG_printf("Func n_def_args: %d\n", self->n_def_args);
|
||||
|
||||
size_t n_state, state_size;
|
||||
DECODE_CODESTATE_SIZE(self->bytecode, n_state, state_size);
|
||||
|
|
11
py/objtype.c
11
py/objtype.c
|
@ -177,10 +177,13 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
|||
mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest);
|
||||
}
|
||||
#if DEBUG_PRINT
|
||||
printf("mp_obj_class_lookup: Returning: ");
|
||||
mp_obj_print(lookup->dest[0], PRINT_REPR); printf(" ");
|
||||
// Don't try to repr() lookup->dest[1], as we can be called recursively
|
||||
printf("<%s @%p>\n", mp_obj_get_type_str(lookup->dest[1]), lookup->dest[1]);
|
||||
DEBUG_printf("mp_obj_class_lookup: Returning: ");
|
||||
mp_obj_print_helper(MICROPY_DEBUG_PRINTER, lookup->dest[0], PRINT_REPR);
|
||||
if (lookup->dest[1] != MP_OBJ_NULL) {
|
||||
// Don't try to repr() lookup->dest[1], as we can be called recursively
|
||||
DEBUG_printf(" <%s @%p>", mp_obj_get_type_str(lookup->dest[1]), MP_OBJ_TO_PTR(lookup->dest[1]));
|
||||
}
|
||||
DEBUG_printf("\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue