tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kgdb on amd64
On Wed, Jun 24, 2015 at 04:42:12PM +0100, Patrick Welche wrote:
> The reason kgdb wasn't working all this time on amd64 is that GETC()
> returns -1 immediately whether or not a character is available =>
> all of kgdb's checksums fail due to the extra "-1" characters.
The attached gets us that far.
(Next the target suffers a lock panic on receipt of a "m" command)
Cheers,
Patrick
Index: kgdb_stub.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kgdb_stub.c,v
retrieving revision 1.28
diff -u -p -r1.28 kgdb_stub.c
--- kgdb_stub.c 21 Sep 2014 17:17:15 -0000 1.28
+++ kgdb_stub.c 24 Jun 2015 16:37:55 -0000
@@ -244,7 +245,9 @@ kgdb_send(const u_char *bp)
PUTC(KGDB_END);
PUTC(i2digit(csum >> 4));
PUTC(i2digit(csum));
- } while ((c = GETC() & 0x7f) == KGDB_BADP);
+ while ((c = GETC()) == -1)
+ ;
+ } while ((c & 0x7f) == KGDB_BADP);
}
/*
@@ -261,17 +264,25 @@ kgdb_recv(u_char *bp, int maxlen)
do {
p = bp;
csum = len = 0;
- while ((c = GETC()) != KGDB_START)
+ do {
+ while ((c = GETC()) == -1)
+ ;
DPRINTF(("%c",c));
+ } while (c != KGDB_START);
+
DPRINTF(("%c Start ",c));
- while ((c = GETC()) != KGDB_END && len < maxlen) {
+ do {
+ while ((c = GETC()) == -1)
+ ;
+ if (c == KGDB_END)
+ break;
DPRINTF(("%c",c));
c &= 0x7f;
csum += c;
*p++ = c;
len++;
- }
+ } while (len < maxlen);
csum &= 0xff;
*p = '\0';
DPRINTF(("%c End ", c));
@@ -283,10 +294,12 @@ kgdb_recv(u_char *bp, int maxlen)
}
tmpcsum = csum;
- c = GETC();
+ while ((c = GETC()) == -1)
+ ;
DPRINTF(("%c",c));
csum -= digit2i(c) * 16;
- c = GETC();
+ while ((c = GETC()) == -1)
+ ;
DPRINTF(("%c",c));
csum -= digit2i(c);
@@ -326,7 +339,7 @@ kgdb_attach(int (*getfn)(void *), void (
* This function does all command processing for interfacing to
* a remote gdb. Note that the error codes are ignored by gdb
* at present, but might eventually become meaningful. (XXX)
- * It might makes sense to use POSIX errno values, because
+ * It might make sense to use POSIX errno values, because
* that is what the gdb/remote.c functions want to return.
*/
int
Home |
Main Index |
Thread Index |
Old Index