cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in the debugger?

Pavel A.
Evangelist III

Not sure whether this is a GDB or Eclipse behavior, or "feature" of debug info created by gcc compiler...

Debugger in CubeIDE and Atollic refuses to display pointers to volatile.

For example:

volatile char *ptr = some_func();

It always says that such pointers are optimized out.

Very annoying.

Debugger rightly refuses to dereference ptr - but ptr itself is NOT volatile!

Another debugger annoyance: consider a loop in one source line, like this:

while ( foo == 0) {}

When debugger tries to step over (F6) such line and the loop won't exit, the pause button (||) becomes unavailable and it's impossible to break in.

The only available action is to stop debug session altogether.

Optimization is either off or "optimize for debug" - neither helps

Regards,

Pavel

5 REPLIES 5
Pavel A.
Evangelist III

More debugger annoyances:

Debug (launch) settings dialog looks in CubeIDE way differently from Atollic.

I need to specify a non-standard entry address, and CubeIDE has a special field for this.

But in my system the address is not fixed, it should be read from the image after it been loaded.

In Atollic, this can be done with set $pc command in the debugger script, like:

set $pc=*(0x08010104)

In CubeIDE this works as well, but sometimes fails with

Error in final launch sequence:
 
Failed to execute MI command:
set $pc=*(0x08120204)
 
Error message from debugger back end:
Selected thread is running.

After this, need to replug the debugger cable and wait some time. Very annoying as well.

-- pa

IMHO the debugger in CubeIDE is notably less stable than in old good Atollic.

Even though the Eclipse part, toolchain etc. are newer and greater.

-- pa

KnarfB
Principal III

> refuses to display pointers to volatile.

Hmm. Thats a compiler decision. Are you using optimization level -O0 ?

Try making the volatile variable static or add an attribute

volatile char *i __attribute__ ((used)) = rand();

Optimization level is always a compromize between speed, space (limited flash) and debuggability.

    while ( foo == 0) {}

Hmm, break || works for me (STM32CubeIDE 1.2.1).

Sometimes I switch to instruction level debugging before entering such a tight loop.

Thank you Frank. I'll re-test with latest CubeIDE. Was sure I'm using -O0.

Do you use ST GDB or Open OCD with CubeIDE? Linux or Windows?

-- pa

KnarfB
Principal III

ST GDB. Just tested openOCD (without recompilation) and it can access the local volatile variable, strange.