GDB debugging.

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

Moderators: barthess, RoccoMarco

rew
Posts: 333
Joined: Sat Jul 19, 2014 12:59 pm
Been thanked: 8 times

GDB debugging.

Postby rew » Wed Jun 19, 2019 6:55 am

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: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 745 times
Been thanked: 621 times
Contact:

Re: GDB debugging.

Postby Giovanni » Wed Jun 19, 2019 7:39 am

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: 333
Joined: Sat Jul 19, 2014 12:59 pm
Been thanked: 8 times

Re: GDB debugging.

Postby rew » Wed Jun 19, 2019 8:04 pm

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: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 745 times
Been thanked: 621 times
Contact:

Re: GDB debugging.

Postby Giovanni » Wed Jun 19, 2019 8:56 pm

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

Giovanni

mikeprotts
Posts: 144
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: GDB debugging.

Postby mikeprotts » Fri Jun 21, 2019 8:02 am

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: 451
Joined: Sat Nov 19, 2011 6:47 pm
Location: Versailles, France
Has thanked: 12 times
Been thanked: 17 times

Re: GDB debugging.

Postby mobyfab » Sat Jun 22, 2019 8:25 pm

Are you using tickless mode?

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

User avatar
Giovanni
Site Admin
Posts: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 745 times
Been thanked: 621 times
Contact:

Re: GDB debugging.

Postby Giovanni » Sat Jun 22, 2019 8:34 pm

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

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 5 guests