callstack and _unhandled_exception

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

callstack and _unhandled_exception

Post by alex31 »

When something goes really wrong, mcu branches on _unhandled_exception, unfortunately
i cannot know using gdb where is the code which trig the error :

#0 _unhandled_exception () at ../../ChibiOS/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c:211
#1 <signal handler called>
#2 0x55555554 in ?? ()
#3 0x55555554 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)


is there a method to have a valid callstack without running program step by step ?

i use gdb over swd (texane st-link)

Alexandre
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: callstack and _unhandled_exception

Post by Giovanni »

Hi,

GDB is able to backtrace but in that case the CPU jumped there directly because an exception, the exceptions stack is a whole different stack and it is not possible to know where the exception has been triggered by backtracing.

There are registers in the NVIC that can give you detailed info about the exception, you have to look there.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: callstack and _unhandled_exception

Post by Tectu »

It's also worth to check the BusFault register of the core. It will tell you what exactly happened when there was a core-internal problem and from there the ways to procede split.

http://infocenter.arm.com/help/index.js ... 05s01.html


~ Tectu
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: callstack and _unhandled_exception

Post by alex31 »

thanks both of you for this precious information !

i will declare global variable to alias SCBBase, because gdb cannot handle define and is no able to interpret
print SCB_BFAR

Alexandre
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: callstack and _unhandled_exception

Post by Giovanni »

Good approach.

You could also redefine _unhandled_exception as a function and put code there to inspect the CPU status.

Giovanni
chrismerck
Posts: 21
Joined: Fri Mar 14, 2014 12:35 am
Been thanked: 4 times

Re: callstack and _unhandled_exception

Post by chrismerck »

Alexandre,

Wasn't it you who posted your _unhandled_exception() code here back in September?
http://forum.chibios.org/phpbb/viewtopic.php?uid=1176&f=16&t=1410&start=0

Was this approach not working for you?

-Chris
Post Reply