From: Carsten Langgaard <carstenl@mips.com>
To: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: GDB patch
Date: Tue, 10 Dec 2002 13:07:31 +0100 [thread overview]
Message-ID: <3DF5D902.22E5AA55@mips.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 531 bytes --]
I've attached a patch for gdb-stub.c to make it work better with the
sde-gdb.
These changes should be backwards compatible with a standard gdb, so it
shouldn't break anything.
Ralf, could you please apply it.
/Carsten
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
[-- Attachment #2: gdb-stub.patch --]
[-- Type: text/plain, Size: 3896 bytes --]
Index: arch/mips/kernel/gdb-stub.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/kernel/gdb-stub.c,v
retrieving revision 1.15.2.3
diff -u -r1.15.2.3 gdb-stub.c
--- arch/mips/kernel/gdb-stub.c 7 Nov 2002 01:47:45 -0000 1.15.2.3
+++ arch/mips/kernel/gdb-stub.c 10 Dec 2002 11:50:35 -0000
@@ -166,7 +166,7 @@
* BUFMAX defines the maximum number of characters in inbound/outbound buffers
* at least NUMREGBYTES*2 are needed for register packets
*/
-#define BUFMAX 2048
+#define BUFMAX 8192
static char input_buffer[BUFMAX];
static char output_buffer[BUFMAX];
@@ -218,7 +218,7 @@
* now, read until a # or end of buffer is found
*/
while (count < BUFMAX) {
- ch = getDebugChar() & 0x7f;
+ ch = getDebugChar();
if (ch == '#')
break;
checksum = checksum + ch;
@@ -324,19 +324,33 @@
* may_fault is non-zero if we are reading from arbitrary memory, but is currently
* not used.
*/
-static char *hex2mem(char *buf, char *mem, int count, int may_fault)
+static char *hex2mem(char *buf, char *mem, int count, int binary, int may_fault)
{
int i;
unsigned char ch;
+ char *startadr = mem;
for (i=0; i<count; i++)
{
- ch = hex(*buf++) << 4;
- ch |= hex(*buf++);
+ if (binary) {
+ ch = *buf++;
+ if (ch == 0x7d)
+ ch = 0x20 ^ *buf++;
+ }
+ else {
+ ch = hex(*buf++) << 4;
+ ch |= hex(*buf++);
+ }
if (kgdb_write_byte(ch, mem++) != 0)
return 0;
}
+ /*
+ * Since we may have written to instruction space via
+ * the data path, the icache needs to be flushed here.
+ */
+ flush_icache_range(startadr, count);
+
return mem;
}
@@ -594,6 +608,7 @@
int length;
char *ptr;
unsigned long *stack;
+ int bflag;
#if 0
printk("in handle_exception()\n");
@@ -695,6 +710,7 @@
* Wait for input from remote GDB
*/
while (1) {
+ bflag = 0;
output_buffer[0] = 0;
getpacket(input_buffer);
@@ -767,6 +783,13 @@
break;
/*
+ * XAA..AA,LLLL: Write LLLL escaped binary bytes at address AA.AA
+ */
+ case 'X':
+ bflag = 1;
+ /* fall through */
+
+ /*
* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK
*/
case 'M':
@@ -776,7 +799,7 @@
&& *ptr++ == ','
&& hexToInt(&ptr, &length)
&& *ptr++ == ':') {
- if (hex2mem(ptr, (char *)addr, length, 1))
+ if (hex2mem(ptr, (char *)addr, length, bflag, 1))
strcpy(output_buffer, "OK");
else
strcpy(output_buffer, "E03");
@@ -816,13 +839,64 @@
case 'k' :
break; /* do nothing */
+ case 'R':
+ /* RNN[:SS], Set the value of CPU register NN (size SS) */
+ /* FALL THROUGH */
+
+ case 'P':
+ /* PNN[:SS]= Set the value of CPU register NN (size SS) */
+ {
+ int regno, regsize = 4, regval;
+ ptr = &input_buffer[1];
+
+ if (!hexToInt (&ptr, ®no))
+ goto error;
+
+ ptr++;
+ if (!hexToInt (&ptr, ®size))
+ goto error;
+
+ if (regsize != 4)
+ goto error;
+ if (*ptr != ((input_buffer[0] == 'P') ? '=' : ','))
+ goto error;
+ ptr++;
+ if (!hex2mem (ptr, (char *)®val, 4, 0, 0))
+ goto error;
+
+ memcpy ((char *)®s->reg0+regno*4, ®val, 4);
+ strcpy (output_buffer, "OK");
+ }
+ break;
- /*
- * Reset the whole machine (FIXME: system dependent)
- */
case 'r':
- break;
+ /* rNN[:SS] Return the value of CPU register NN (size SS) */
+ {
+ int regno, regsize = 4;
+ ptr = &input_buffer[1];
+ if (hexToInt (&ptr, ®no)) {
+ if (*ptr == ':') {
+ ptr++;
+ if (!hexToInt (&ptr, ®size))
+ goto error;
+ }
+
+ if (regsize != 4)
+ goto error;
+ (void) mem2hex((char *)®s->reg0+regno*4,
+ output_buffer, 4, 0);
+ }
+ else {
+ error:
+ strcpy(output_buffer,"E22 invalid arguments");
+ }
+ }
+ break;
+ case 'D':
+ putpacket("OK");
+ return;
+ /* NOTREACHED */
/*
* Step to next instruction
next reply other threads:[~2002-12-10 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-10 12:07 Carsten Langgaard [this message]
2002-12-10 16:51 ` GDB patch Daniel Jacobowitz
-- strict thread matches above, loose matches on Subject: below --
2002-12-10 19:19 Nigel Stephens
2002-12-10 19:19 ` Nigel Stephens
2002-12-10 19:32 ` Daniel Jacobowitz
2002-12-10 20:40 ` Nigel Stephens
2002-12-11 16:52 ` Daniel Jacobowitz
2002-12-11 17:24 ` Nigel Stephens
2002-12-11 17:56 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DF5D902.22E5AA55@mips.com \
--to=carstenl@mips.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.