cortex-debug: Unable to view Static/Global variables during debug
Follow up to https://github.com/Marus/cortex-debug/pull/175#issuecomment-506534366
I built a tiny binary with a minimal main() for two parts: an RX231 and an ATSAMD21G18A. This is main.c for both:
int globalInt = 8;
static int staticInt = 9;
int main(void)
{
while(1)
{
volatile int _volatile;
_volatile = globalInt + staticInt;
globalInt++;
staticInt--;
}
return 0;
}
I debugged both binaries using a JLink (FINE interface for RX231, SWD for ATSAMD21G18A).
When debugging the RX231 part, the only thing to show up under Variables > Global was the name of a function argument in a stub function. Nothing showed up under Variables > Static. This is the relevant output from objdump:
rx-elf-objdump --syms out.elf | grep \\.data
00000004 l d .data 00000000 .data
00000004 l .data 00000000 .LANCHOR0
00000008 l .data 00000000 .LANCHOR1
00000008 l O .data 00000004 _staticInt
00000004 l .data 00000000 __clockSourceEnd
00000004 g .data 00000000 __clockSourceStart
00000004 g O .data 00000004 _globalInt
00000004 g .data 00000000 _data
0000000c g .data 00000000 _edata
I was able to verify with the memory viewer that globalInt and staticInt both contained their expected values at their expected offsets. I was also able to view globalInt and staticInt using a watch.
When debugging the ATSAMD21G18A part, globalInt was viewable under Variables > Global and showed the proper value. Nothing showed up under Variables > Static. This is the relevant output from objdump:
arm-none-eabi-objdump --syms out.elf | grep \\.data
20000000 l d .data 00000000 .data
20000000 l O .data 00000004 ticks
2000000c l O .data 00000004 staticInt
20000000 g .data 00000000 __data_start__
20000008 g O .data 00000004 globalInt
00000ac8 g .data 00000000 __etext
20000004 g O .data 00000004 SystemCoreClock
20000010 g .data 00000000 __data_end__
I was able to view globalInt and staticInt using a watch.
It’s not entirely surprising that globals aren’t visible when debugging the RX231 part since it’s not a Cortex M core, but there’s nothing conspicuously different about the output of objdump except the names of the linker symbols.
It’s unclear why no statics are visible in either case. This is the only part of the behavior that seems like it could be a real bug in the plugin.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 31 (19 by maintainers)
Commits related to this issue
- Fix issue #179, better handling of statics and globals, set-variable fix, C++ demangling — committed to haneefdm/cortex-debug by haneefdm 4 years ago
- Fix issue #179, better handling of statics and globals, set-variable fix, C++ demangling — committed to mayjs/cortex-debug by haneefdm 4 years ago
Yes, this is fixed, was broken again and fixed again, improving performance a couple times (#539), etc. Wish we never had to rely on objdump.
We always demangle now and the option to control it is gone.
I push a PR to fix this #233 . It solves my problem, and I hope it helps others