diff --git a/cm_backtrace/cm_backtrace.c b/cm_backtrace/cm_backtrace.c index e348c3d..4d446e8 100644 --- a/cm_backtrace/cm_backtrace.c +++ b/cm_backtrace/cm_backtrace.c @@ -374,6 +374,10 @@ size_t cm_backtrace_call_stack(uint32_t *buffer, size_t size, uint32_t sp) { for (; sp < stack_start_addr + stack_size; sp += sizeof(size_t)) { /* the *sp value may be LR, so need decrease a word to PC */ pc = *((uint32_t *) sp) - sizeof(size_t); + /* the Cortex-M using thumb instruction, so the pc must be an odd number */ + if (pc % 2 == 0) { + continue; + } if ((pc >= code_start_addr) && (pc <= code_start_addr + code_size) && (depth < CMB_CALL_STACK_MAX_DEPTH) && (depth < size)) { /* the second depth function may be already saved, so need ignore repeat */ diff --git a/cm_backtrace/cmb_def.h b/cm_backtrace/cmb_def.h index 41f0b82..0d15d65 100644 --- a/cm_backtrace/cmb_def.h +++ b/cm_backtrace/cmb_def.h @@ -34,7 +34,7 @@ #include /* library software version number */ -#define CMB_SW_VERSION "1.2.0" +#define CMB_SW_VERSION "1.2.1" #define CMB_CPU_ARM_CORTEX_M0 0 #define CMB_CPU_ARM_CORTEX_M3 1