Can not see any local variables while debugging (nrf52-dk, mbed)

I have the nrf52-dk, want to use the mbed framework and debug it. Many things seems to work, but i can not see any local variables while debugging. I can set breakpoints, do steps, see some registers, peripherals, … , but can not see any variable.
If I do the same with an arduino-framework (as example arduino-blink-example), I can debug and see the variables there. Do you have a reason for that?

Thanks for your support.

What optimization level and debug information are you compiling on? (-O0-O3 and -g0 to -g3?)

My debug configuration (platformio.ini) is this:
[env:nrf52_dk]
platform = nordicnrf52
framework = mbed
board = nrf52_dk
debug_tool = jlink

I didn’t have set any optimization level.

Then you have -Os set by default.

Add this to your platformio.ini:

build_unflags = -Os
build_flags = -O0 -g3 -ggdb

And retry debugging.

When I add this line

build_unflags = -Os

then i get an error while building:

/Users/Admin/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/sleep.c: In function ‘hal_sleep’:
/Users/Admin/.platformio/packages/framework-mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/sleep.c:86:1: error: unrecognizable insn:

When I only add the build_flags line

build_flags = -O0 -g3 -ggdb

then it is possible to build (success), but unfortunately the same behaviour while debugging (can not see the variables).

Try my original configuration but with -O1 instead of -O0. No optimization semes to leed to a assembler error…

I changed to -O1. Now it builds (success) but for debugging still the same: can not see the variables.

[env:nrf52_dk]
platform = nordicnrf52
framework = mbed
board = nrf52_dk
debug_tool = jlink
build_unflags = -Os
build_flags = -O1 -g3 -ggdb

right? Then how do you debug? Using pio debug or what IDE / configuration?

Yes, exactly this configuration. I’m using the platformio-IDE and just tried to use an nrf52 mbed example (mbed-blinky). I’m a new user of platformio.

The arduino-blinky-xample works without problems…

Since I have neither the board nor the debugger tool I can’t reproduce.

Maybe you need a more complex function to debug because -O1 really does optimize away the trivial blinky code so that no local variable is used anymore.

I can refer to you the video tutorial ThingForward TechBlog: First steps with PlatformIO´s unified Debugger - YouTube and general documentation.

Anyway, thanks for your support!

I will try some things and will write my solution here if I will find it.

Until now, I did not found a solution for that. I also tried exactly the same example (and other examples) with the default platformio.ini-config and the edited config (unbuild/build-flags,…) on Windows10 which shows the same behaviour.
As example:

Uh, this looks perfectly fine?

myled is a global variable and it’s there. Also the compiler completely optmized i to be held in a register so it doesn’t show up as a global / local var. Would have to see the assembly, but at -O1 that’s pretty reasonable.

Oh, yes, absolutely. This is not a good example.

I edited it a little bit:

  • I would expect to see “j” and “myled” in Locals.
  • I expect to see “j”, “i” and “myled” on the left side in “Überwachen”.
    Makes it sense that I can not see these variables?

Additionally, when I tried it with the arduino-framework, then I could see the value of the variable “i” when I did a mouseover over the variable. Here, with the mbed framework, this does not work.

Here is an similar example with the arduino framework:

i used this platform.ini:

[env:nrf52_dk]
platform = nordicnrf52
framework = arduino
board = nrf52_dk
debug_tool = jlink
build_unflags = -Os
build_flags = -O1 -g3 -ggdb

The same behaviour when I use Eclipse as IDE: works fine with arduino-framework, does not showing variables with mbed-framework.

It works for me. See below.

Please provide the next information:

  1. Start debug session
  2. Go to “Debug Console” and type
# list call stack frames
> bt

# select the latest frame
> select-frame NUMBER

# print local variables
> info locals

For example

> bt
> select-frame 0
> info locals

Please provide info here.

The blink-example with the output of the debug console:

@valeros could you help here?

I still haven’t found a solution for that. Does anyone have a solution for that?