Skip to content

Commit 5769c4d

Browse files
lyakhfabiobaltieri
authored andcommitted
xtensa: gdbstub: fix compilation
Building gdbstub for xtensa is failing currently with multiple failures like arch/xtensa/core/gdbstub.c:432:24: error: invalid operands to \ binary - (have 'int *' and 'const struct arch_esf *') 432 | if ((int *)bsa - stack > 4) { Fix them by using appropriate pointer types. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 92a32a9 commit 5769c4d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

arch/xtensa/core/gdbstub.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ static void copy_to_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
427427
struct xtensa_register *reg;
428428
int idx, num_laddr_regs;
429429

430-
uint32_t *bsa = *(int **)stack;
430+
uint32_t *bsa = *(const int **)stack;
431431

432-
if ((int *)bsa - stack > 4) {
432+
if (bsa - (const uint32_t *)stack > 4) {
433433
num_laddr_regs = 8;
434-
} else if ((int *)bsa - stack > 8) {
434+
} else if (bsa - (const uint32_t *)stack > 8) {
435435
num_laddr_regs = 12;
436-
} else if ((int *)bsa - stack > 12) {
436+
} else if (bsa - (const uint32_t *)stack > 12) {
437437
num_laddr_regs = 16;
438438
} else {
439439
num_laddr_regs = 4;
@@ -445,8 +445,7 @@ static void copy_to_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
445445

446446
if (reg->regno == SOC_GDB_REGNO_A1) {
447447
/* A1 is calculated */
448-
reg->val = POINTER_TO_UINT(
449-
((char *)bsa) + BASE_SAVE_AREA_SIZE);
448+
reg->val = POINTER_TO_UINT(((char *)bsa) + sizeof(_xtensa_irq_bsa_t));
450449
reg->seqno = ctx->seqno;
451450
} else {
452451
reg->val = bsa[reg->stack_offset / 4];
@@ -518,13 +517,13 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
518517
struct xtensa_register *reg;
519518
int idx, num_laddr_regs;
520519

521-
_xtensa_irq_bsa_t *bsa = (void *)*(int **)stack;
520+
_xtensa_irq_bsa_t *bsa = (void *)*(const int **)stack;
522521

523-
if ((int *)bsa - stack > 4) {
522+
if ((uint32_t *)bsa - (const uint32_t *)stack > 4) {
524523
num_laddr_regs = 8;
525-
} else if ((int *)bsa - stack > 8) {
524+
} else if ((uint32_t *)bsa - (const uint32_t *)stack > 8) {
526525
num_laddr_regs = 12;
527-
} else if ((int *)bsa - stack > 12) {
526+
} else if ((uint32_t *)bsa - (const uint32_t *)stack > 12) {
528527
num_laddr_regs = 16;
529528
} else {
530529
num_laddr_regs = 4;
@@ -547,7 +546,7 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
547546
/* Shouldn't be changing stack pointer */
548547
continue;
549548
} else {
550-
bsa[reg->stack_offset / 4] = reg->val;
549+
((uint32_t *)bsa)[reg->stack_offset / 4] = reg->val;
551550
}
552551
}
553552

@@ -559,7 +558,7 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack)
559558
continue;
560559
} else if (reg->stack_offset != 0) {
561560
/* For those registers stashed in stack */
562-
bsa[reg->stack_offset / 4] = reg->val;
561+
((uint32_t *)bsa)[reg->stack_offset / 4] = reg->val;
563562
} else if (gdb_xtensa_is_special_reg(reg)) {
564563
/*
565564
* Currently not writing back any special

0 commit comments

Comments
 (0)