I'm debugging the following function from Micropython and I'm unable to step into the code of the macro VERIFY_MARK_AND_PUSH
.
I'm able to step into normal functions and I'm compiling with -g3 -gdwarf-2
.
void gc_collect_root(void **ptrs, size_t len) {
for (size_t i = 0; i < len; i++) {
void *ptr = ptrs[i];
VERIFY_MARK_AND_PUSH(ptr);
gc_drain_stack();
}
}
The macro is:
// ptr should be of type void*
#define VERIFY_MARK_AND_PUSH(ptr) \
do { \
if (VERIFY_PTR(ptr)) { \
size_t _block = BLOCK_FROM_PTR(ptr); \
if (ATB_GET_KIND(_block) == AT_HEAD) { \
/* an unmarked head, mark it, and push it on gc stack */ \
DEBUG_printf("gc_mark(%p)\n", ptr); \
ATB_HEAD_TO_MARK(_block); \
if (MP_STATE_MEM(gc_sp) < &MP_STATE_MEM(gc_stack)[MICROPY_ALLOC_GC_STACK_SIZE]) { \
*MP_STATE_MEM(gc_sp)++ = _block; \
} else { \
MP_STATE_MEM(gc_stack_overflow) = 1; \
} \
} \
} \
} while (0)
QUESTION
Is there any way to step into macros containing multiple lines of code?
Is there any way to step into macros containing multiple lines of code?
You can't step into the macro regardless of whether it has single or multiple lines, because the preprocessor expands the body of the macro before the complier sees it.
A macro is simply a shorthand, a cut/paste if you will, so there is nowhere to step into -- it all becomes part of the current function.
To understand this better, look at preprocessed code (output from gcc -E foo.c
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With