Page 1 of 1

GDB debugging.

Posted: Wed Jun 19, 2019 6:55 am
by rew
I use arm-gcc and gdb under Linux (ubuntu).

When I try to debug my code under gdb, when I stop in say "init_something ()" and then type "next", the next instruction is always some interrupt handling stuff. Is there a way to get this to work normally?

Re: GDB debugging.

Posted: Wed Jun 19, 2019 7:39 am
by Giovanni
I don't usually use GDB directly but Eclipse uses it internally, it works under Linux for me.

It looks like you are hitting an exception and it jumps into the default handler.

Giovanni

Re: GDB debugging.

Posted: Wed Jun 19, 2019 8:04 pm
by rew
It is just a normal "timer" interrupt. Or maybe USB. I don't know. But I can never step through MY code because it keeps going into the interrupt handler when I single-step the target.....

Re: GDB debugging.

Posted: Wed Jun 19, 2019 8:56 pm
by Giovanni
Are you able to step up to chSysInit()? interrupts should be disabled up that point.

Giovanni

Re: GDB debugging.

Posted: Fri Jun 21, 2019 8:02 am
by mikeprotts
I struggle with single stepping as I have frequently firing interrupts at high priority. My usual debugging process is to set several breakpoints for the area of code of interest, and just examine the code when it hits these. Often I add another breakpoint for the next line of interest so 'continue' will let the interrupts run, but effectively step to the next line in the thread of interest.

Another option would be to disable the interrupts while debugging specific sections of code, which means having a diagnostic build.

You might also see if next, until or advance would work better for you.

Re: GDB debugging.

Posted: Sat Jun 22, 2019 8:25 pm
by mobyfab
Are you using tickless mode?

Timers don't stop when core is halted unless you enable some options.

Re: GDB debugging.

Posted: Sat Jun 22, 2019 8:34 pm
by Giovanni
The HAL ST driver should enable the freeze option by default.

Giovanni