lpcware

HardFault_Handler Showing the Nested Stack Calls

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by kralux on Thu Aug 23 17:08:47 MST 2012
I am looking for code that would give me the list of all nested jumps after an exception occurs. This is similar to what the Red Suite debugger does.
This is to be used during run-time operation to give more information on the cause of the error.
I am familiar with the .axf disassembler to match instructions and memory location.
I am also familiar with this page http://support.code-red-tech.com/CodeRedWiki/DebugHardFault
Unfortunately that code does not seem to give the nested list of method calls. It also strangely shows PC as being the address of the faulty instruction which caused the exception. Is that correct? (would have thought it should have been in LR).

My platform is an M3 LPC1788.

Here is a list of the type of debug info I would like to have (info needed is in red):
6 HardFault_HandlerAsm() cr_startup_lpc178x.c:450 0x0000ddc8
5 <signal handler called>()  0xfffffff9
4 takeAction() model.c:925 [COLOR=Red]0x000119a4[/COLOR]
3 processController() controller.c:49 [COLOR=red]0x0000dd5c[/COLOR]
2 main() main.c:207 [COLOR=red]0x0000f2ec[/COLOR]
1 ResetISR() cr_startup_lpc178x.c:345 [COLOR=red]0x00000194[/COLOR]

(of course, the debug text would not be there but just having the lines of the call would be useful).

Right now it seems the best thing I can do is to look on the stack and get addresses that way with an interval of 6 words for each address. (interval of 11 words to get to the first one though).

Here is the snippet:
uint32_t i;
for (i = 0; i < 10; i++) {
if ((uint32_t)&hardfault_args[17 + i * 6] < 0x1000FFFF) {
stacked_next = ((uint32_t)hardfault_args[17 + i * 6]) ;
}
}

It seems like this may solve my need.

Let me know your thoughts or if you have a better idea.

Thank you.

Alex

Outcomes