-
Notifications
You must be signed in to change notification settings - Fork 85
Backtrace for HardFault #158
Comments
Reading in on the related #139, perhaps the handler should not be ->!, but -> () and wrapped in an external handler being ->!. Then internally, we should have a correct stack handling (I hope, if LLVM is not outsmarting us by knowing that its called only in -> ! context and hence -> ! stack rules should apply). In any case the consequence is that "after" printing the Any thoughts on how we should handle this problem? Best |
Here is a possible workaround in the meantime (could be replacing the Notice, this requires "asm-inline", as the breakpoint would else be
|
This seems like a duplicate of #139, so closing in favor of that (though ultimately it's an upstream bug) |
I was experimenting with the latest release of cortex-m-rt (0.6.6).
Possibly related to #139.
The code (below) should hard fault, and it does and the handler is invoked.
a gdb bactrace works at the first breakpoint. (I used the "asm-inline" feature, to have the bkpts inlined).
seems ok. (pc being the
read_volatile
on the faulty address)However, when trying to make a backtrace from within
testf
or aftertestf
(back in the HardFault handler), backtracing ends up in an infinite loop.I wonder if this is the expected behavior. If so, then the docs should perhaps indicate that if you want to make a backtrace, put an asm::bkptr at entry of the HardFault handler, and do the bactrace before you call any function, e.g.,
I did not use
panic!(..)
to print theef
, as I wanted the example as simple as possible (less indirections). Printingef
can of course be done from within gdb as well, and is often preferrable as bringing formatting and semi-hosting printing is somewhat bloating the code.On another note, I tried printing `ef' over ITM, but that is not advisable, as (at least on the stlink/nucleo 64), the internal buffer of the debug interface will overflow causing the ITM channel to be frozen). After that ITM was inaccessible, requiring an openocd kill/restart, but that behaviour might be installation dependent.
I took a brief look at the generated asm (release mode), and it looks ok, it reserves som place on the stack for the HardFault handler, etc.
The text was updated successfully, but these errors were encountered: