Skip to content

Commit 0a91905

Browse files
lyakhfabiobaltieri
authored andcommitted
xtensa: gdbstub: fix stack calculation
Fix a logic error when calculating stack frame sizes. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 5769c4d commit 0a91905

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arch/xtensa/core/gdbstub.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ static void copy_to_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
429429

430430
uint32_t *bsa = *(const int **)stack;
431431

432-
if (bsa - (const uint32_t *)stack > 4) {
433-
num_laddr_regs = 8;
432+
if (bsa - (const uint32_t *)stack > 12) {
433+
num_laddr_regs = 16;
434434
} else if (bsa - (const uint32_t *)stack > 8) {
435435
num_laddr_regs = 12;
436-
} else if (bsa - (const uint32_t *)stack > 12) {
437-
num_laddr_regs = 16;
436+
} else if (bsa - (const uint32_t *)stack > 4) {
437+
num_laddr_regs = 8;
438438
} else {
439439
num_laddr_regs = 4;
440440
}
@@ -519,12 +519,12 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
519519

520520
_xtensa_irq_bsa_t *bsa = (void *)*(const int **)stack;
521521

522-
if ((uint32_t *)bsa - (const uint32_t *)stack > 4) {
523-
num_laddr_regs = 8;
522+
if ((uint32_t *)bsa - (const uint32_t *)stack > 12) {
523+
num_laddr_regs = 16;
524524
} else if ((uint32_t *)bsa - (const uint32_t *)stack > 8) {
525525
num_laddr_regs = 12;
526-
} else if ((uint32_t *)bsa - (const uint32_t *)stack > 12) {
527-
num_laddr_regs = 16;
526+
} else if ((uint32_t *)bsa - (const uint32_t *)stack > 4) {
527+
num_laddr_regs = 8;
528528
} else {
529529
num_laddr_regs = 4;
530530
}

0 commit comments

Comments
 (0)