diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs index ac6e7205a3..44ab574f5a 100644 --- a/arch/arm64/src/common/Make.defs +++ b/arch/arm64/src/common/Make.defs @@ -47,7 +47,7 @@ CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c arm64_createstack.c CMN_CSRCS += arm64_releasestack.c arm64_stackframe.c arm64_usestack.c CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_vfork.c arm64_switchcontext.c CMN_CSRCS += arm64_schedulesigaction.c arm64_sigdeliver.c -CMN_CSRCS += arm64_backtrace.c arm64_getintstack.c arm64_registerdump.c +CMN_CSRCS += arm64_getintstack.c arm64_registerdump.c CMN_CSRCS += arm64_perf.c # Common C source files ( hardware BSP ) @@ -115,3 +115,7 @@ endif ifeq ($(CONFIG_STACK_COLORATION),y) CMN_CSRCS += arm64_checkstack.c endif + +ifeq ($(CONFIG_SCHED_BACKTRACE),y) +CMN_CSRCS += arm64_backtrace.c +endif diff --git a/arch/arm64/src/common/arm64_backtrace.c b/arch/arm64/src/common/arm64_backtrace.c index 24d1ac956d..60406f7f4d 100644 --- a/arch/arm64/src/common/arm64_backtrace.c +++ b/arch/arm64/src/common/arm64_backtrace.c @@ -53,14 +53,13 @@ static int backtrace(uintptr_t *base, uintptr_t *limit, if (pc) { - i++; if (*skip-- <= 0) { - *buffer++ = pc; + buffer[i++] = pc; } } - for (; i < size; fp = (uintptr_t *)*(fp - 1), i++) + for (; i < size; fp = (uintptr_t *)*fp) { if (fp > limit || fp < base || *fp == 0) { @@ -69,7 +68,7 @@ static int backtrace(uintptr_t *base, uintptr_t *limit, if (*skip-- <= 0) { - *buffer++ = (void *)*fp; + buffer[i++] = (void *)*(fp + 1); } }