Skip to content

Commit

Permalink
arm: dump registers on fatal exceptions
Browse files Browse the repository at this point in the history
We had a function that did this, but it was dead code.
Move to fatal.c and call from z_arm_fatal_error().

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information
Andrew Boie authored and andrewboie committed Jul 25, 2019
1 parent fe8d75a commit c9a4bd4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
1 change: 0 additions & 1 deletion arch/arm/core/cortex_m/CMakeLists.txt
Expand Up @@ -9,7 +9,6 @@ zephyr_library_sources(
prep_c.c prep_c.c
scb.c scb.c
nmi.c nmi.c
exc_manage.c
) )


zephyr_linker_sources_ifdef(CONFIG_SW_VECTOR_RELAY zephyr_linker_sources_ifdef(CONFIG_SW_VECTOR_RELAY
Expand Down
38 changes: 0 additions & 38 deletions arch/arm/core/cortex_m/exc_manage.c

This file was deleted.

28 changes: 26 additions & 2 deletions arch/arm/core/fatal.c
Expand Up @@ -19,10 +19,34 @@
#include <kernel_structs.h> #include <kernel_structs.h>
#include <logging/log_ctrl.h> #include <logging/log_ctrl.h>


void z_arm_fatal_error(unsigned int reason, const NANO_ESF *esf) static void esf_dump(const NANO_ESF *esf)
{ {
z_fatal_print("Faulting instruction address = 0x%x", z_fatal_print("r0/a1: 0x%08x r1/a2: 0x%08x r2/a3: 0x%08x",
esf->basic.a1, esf->basic.a2, esf->basic.a3);
z_fatal_print("r3/a4: 0x%08x r12/ip: 0x%08x r14/lr: 0x%08x",
esf->basic.a4, esf->basic.ip, esf->basic.lr);
z_fatal_print(" xpsr: 0x%08x", esf->basic.xpsr);
#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING)
for (int i = 0; i < 16; i += 4) {
z_fatal_print("s[%d]: 0x%08x s[%d]: 0x%08x"
" s[%d]: 0x%08x s[%d]: 0x%08x\n",
i, (u32_t)esf->s[i],
i + 1, (u32_t)esf->s[i + 1],
i + 2, (u32_t)esf->s[i + 2],
i + 3, (u32_t)esf->s[i + 3]);
}
z_fatal_print("fpscr: 0x%08x\n", esf->fpscr);
#endif
z_fatal_print("Faulting instruction address (r15/pc): 0x%08x",
esf->basic.pc); esf->basic.pc);
}

void z_arm_fatal_error(unsigned int reason, const NANO_ESF *esf)
{

if (esf != NULL) {
esf_dump(esf);
}
z_fatal_error(reason, esf); z_fatal_error(reason, esf);
} }


Expand Down
8 changes: 0 additions & 8 deletions include/arch/arm/cortex_m/exc.h
Expand Up @@ -66,14 +66,6 @@ typedef struct __esf NANO_ESF;


extern void z_ExcExit(void); extern void z_ExcExit(void);


/**
* @brief display the contents of a exception stack frame
*
* @return N/A
*/

extern void sys_exc_esf_dump(NANO_ESF *esf);

#endif /* _ASMLANGUAGE */ #endif /* _ASMLANGUAGE */


#ifdef __cplusplus #ifdef __cplusplus
Expand Down

0 comments on commit c9a4bd4

Please sign in to comment.