[PATCH] FRV: Implement the GDB remote protocol 'p' command toretrieve a register
From: David Howells
Date: Wed Jun 09 2010 - 12:20:02 EST
Implement the GDB remote protocol 'p' command to retrieve a single register
value.
The 'p' command is tried by some gdb versions before they consider using the
'g' command (to batch-retrieve all the registers). Before the following
commit:
commit 7ca8b9c0dafd1cb36289aa4c92c7beae7adcd34f
Author: David Howells <dhowells@xxxxxxxxxx>
Date: Mon May 24 14:32:54 2010 -0700
Subject: frv: extend gdbstub to support more features of gdb
the 'p' command just returned an empty reply, which causes gdb to then go and
use the 'g' command. However, since that commit, the 'p' command returns an
error string, which causes gdb to abort its connection to the target.
Not all gdb versions are affected, some use try 'g' first, and if that works,
don't bother with 'p', and so don't see the error.
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---
arch/frv/include/asm/gdb-stub.h | 2 +
arch/frv/kernel/gdb-stub.c | 116 +++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+), 0 deletions(-)
diff --git a/arch/frv/include/asm/gdb-stub.h b/arch/frv/include/asm/gdb-stub.h
index e6bedd0..8bb0288 100644
--- a/arch/frv/include/asm/gdb-stub.h
+++ b/arch/frv/include/asm/gdb-stub.h
@@ -60,6 +60,8 @@
#define GDB_REG_SCR(N) (141+(N))
#define GDB_REG_LR 145
#define GDB_REG_LCR 146
+#define GDB_REG_IACC0H 147
+#define GDB_REG_IACC0L 148
#define GDB_REG_FSR0 149
#define GDB_REG_ACC(N) (150+(N))
#define GDB_REG_ACCG(N) (158+(N)/4)
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 84d103c..1a65d7b 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -1789,6 +1789,104 @@ void gdbstub(int sigval)
flush_cache = 1;
break;
+ /* pNN: Read value of reg N and return it */
+ case 'p':
+ ptr = &input_buffer[1];
+
+ if (!hexToInt(&ptr, &addr)) {
+ gdbstub_strcpy(output_buffer, "E01");
+ break;
+ }
+
+ temp2 = 1;
+ switch (addr) {
+ case GDB_REG_GR(0):
+ temp = 0;
+ break;
+ case GDB_REG_GR(1) ... GDB_REG_GR(63):
+ temp = __debug_user_context->i.gr[addr - GDB_REG_GR(0)];
+ break;
+ case GDB_REG_FR(0) ... GDB_REG_FR(63):
+ temp = __debug_user_context->f.fr[addr - GDB_REG_FR(0)];
+ break;
+ case GDB_REG_PC:
+ temp = __debug_user_context->i.pc;
+ break;
+ case GDB_REG_PSR:
+ temp = __debug_user_context->i.psr;
+ break;
+ case GDB_REG_CCR:
+ temp = __debug_user_context->i.ccr;
+ break;
+ case GDB_REG_CCCR:
+ temp = __debug_user_context->i.cccr;
+ break;
+ case GDB_REG_BRR:
+ temp = __debug_status.brr;
+ break;
+ case GDB_REG_LR:
+ temp = __debug_user_context->i.lr;
+ break;
+ case GDB_REG_LCR:
+ temp = __debug_user_context->i.lcr;
+ break;
+ case GDB_REG_TBR:
+ temp = __debug_user_context->i.tbr;
+ break;
+ case GDB_REG_FSR0:
+ temp = __debug_user_context->f.fsr[0];
+ break;
+ case GDB_REG_ACC(0) ... GDB_REG_ACC(7):
+ temp = __debug_user_context->f.acc[addr - GDB_REG_ACC(0)];
+ break;
+ case GDB_REG_ACCG(0):
+ temp = *(uint32_t *) &__debug_user_context->f.accg[0];
+ break;
+ case GDB_REG_ACCG(4):
+ temp = *(uint32_t *) &__debug_user_context->f.accg[4];
+ break;
+ case GDB_REG_IACC0H:
+ temp = ((u32*)&__debug_frame->iacc0)[0];
+ break;
+ case GDB_REG_IACC0L:
+ temp = ((u32*)&__debug_frame->iacc0)[1];
+ break;
+ case GDB_REG_MSR(0) ... GDB_REG_MSR(1):
+ temp = __debug_user_context->f.msr[addr - GDB_REG_MSR(0)];
+ break;
+ case GDB_REG_GNER(0) ... GDB_REG_GNER(1):
+ temp = __debug_user_context->i.gner[addr - GDB_REG_GNER(0)];
+ break;
+ case GDB_REG_FNER(0) ... GDB_REG_FNER(1):
+ temp = __debug_user_context->f.fner[addr - GDB_REG_FNER(0)];
+ break;
+ case GDB_REG_DBAR(0):
+ asm volatile("movsg dbar0,%0" : "=r"(temp));
+ break;
+ case GDB_REG_DBAR(1):
+ asm volatile("movsg dbar1,%0" : "=r"(temp));
+ break;
+ case GDB_REG_DBAR(2):
+ asm volatile("movsg dbar2,%0" : "=r"(temp));
+ break;
+ case GDB_REG_DBAR(3):
+ asm volatile("movsg dbar3,%0" : "=r"(temp));
+ break;
+ default:
+ temp = 0;
+ temp2 = 0;
+ break;
+ }
+
+ if (temp2) {
+ ptr = output_buffer;
+ ptr = mem2hex(&temp, ptr, 4, 0);
+ }
+ else {
+ gdbstub_strcpy(output_buffer, "E02");
+ }
+ break;
+
/* PNN,=RRRRRRRR: Write value R to reg N return OK */
case 'P':
ptr = &input_buffer[1];
@@ -1844,6 +1942,12 @@ void gdbstub(int sigval)
case GDB_REG_ACCG(4):
*(uint32_t *) &__debug_user_context->f.accg[4] = temp;
break;
+ case GDB_REG_IACC0H:
+ ((u32*)&__debug_frame->iacc0)[0] = temp;
+ break;
+ case GDB_REG_IACC0L:
+ ((u32*)&__debug_frame->iacc0)[1] = temp;
+ break;
case GDB_REG_MSR(0) ... GDB_REG_MSR(1):
__debug_user_context->f.msr[addr - GDB_REG_MSR(0)] = temp;
break;
@@ -1853,6 +1957,18 @@ void gdbstub(int sigval)
case GDB_REG_FNER(0) ... GDB_REG_FNER(1):
__debug_user_context->f.fner[addr - GDB_REG_FNER(0)] = temp;
break;
+ case GDB_REG_DBAR(0):
+ asm volatile("movgs %0,dbar0" :: "r"(temp));
+ break;
+ case GDB_REG_DBAR(1):
+ asm volatile("movgs %0,dbar1" :: "r"(temp));
+ break;
+ case GDB_REG_DBAR(2):
+ asm volatile("movgs %0,dbar2" :: "r"(temp));
+ break;
+ case GDB_REG_DBAR(3):
+ asm volatile("movgs %0,dbar3" :: "r"(temp));
+ break;
default:
temp2 = 0;
break;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/