Skip to content

Commit 2487461

Browse files
committed
Now stack dump is done correctly to the other way around.
1 parent 50daa7e commit 2487461

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

platform/source/mbed_error.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,23 +587,23 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
587587
// Find the stack end.
588588
int stack_end_cnt = 0;
589589
uint32_t st_end = ctx->thread_current_sp;
590-
for (; st_end >= ctx->thread_stack_mem; st_end -= sizeof(int)) {
590+
for (; st_end <= ctx->thread_stack_mem + ctx->thread_stack_size; st_end += sizeof(int)) {
591591
uint32_t st_val = *((uint32_t *)st_end);
592592
if (st_val == osRtxStackFillPattern) {
593593
stack_end_cnt++;
594594
} else {
595595
stack_end_cnt = 0;
596596
}
597597
if (stack_end_cnt >= STACK_END_MARK_CNT) {
598-
st_end += (STACK_END_MARK_CNT - 1) * sizeof(int);
598+
st_end -= (STACK_END_MARK_CNT - 1) * sizeof(int);
599599
break;
600600
}
601601
}
602-
for (uint32_t st = st_end; st <= ctx->thread_current_sp; st += sizeof(int) * STACK_DUMP_WIDTH) {
602+
for (uint32_t st = ctx->thread_current_sp; st <= st_end; st += sizeof(int) * STACK_DUMP_WIDTH) {
603603
mbed_error_printf("\n0x%08" PRIX32 ":", st);
604604
for (int i = 0; i < STACK_DUMP_WIDTH; i++) {
605605
uint32_t st_cur = st + i * sizeof(int);
606-
if (st_cur > ctx->thread_current_sp) {
606+
if (st_cur > st_end) {
607607
break;
608608
}
609609
uint32_t st_val = *((uint32_t *)st_cur);

0 commit comments

Comments
 (0)