GDB debugging.

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

GDB debugging.

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GDB debugging.

Post 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
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: GDB debugging.

Post 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.....
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GDB debugging.

Post by Giovanni »

Are you able to step up to chSysInit()? interrupts should be disabled up that point.

Giovanni
mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: GDB debugging.

Post 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.
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: GDB debugging.

Post by mobyfab »

Are you using tickless mode?

Timers don't stop when core is halted unless you enable some options.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GDB debugging.

Post by Giovanni »

The HAL ST driver should enable the freeze option by default.

Giovanni
Post Reply