qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Parsing problem of gdb 'M' packet


From: Thomas Petazzoni
Subject: [Qemu-devel] [PATCH] Parsing problem of gdb 'M' packet
Date: Sat, 15 Jan 2005 17:12:13 +0100
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Hello,

I've found a problem in the code parsing the gdb 'M' packet. During gdb remote sessions, I saw strange things when writing to memory :

============================================================
(gdb) print addr
$1 = 0
(gdb) set addr=12
(gdb) print addr
$2 = 49152
============================================================

So, I went into Qemu code, and found a problem in gdbstub.c. The format of a 'M' packet is Maddr,length:XX... as stated on [1]. So the addr is separated from the length using a comma, and the length from the data using a colon.

However, the Qemu code assumed that all fields were seperated with a comma, leading to wrong analysis of the data field.

The included one-line patch fixes the problem :

=============================================================
(gdb) print addr
$1 = 0
(gdb) set addr=12
(gdb) print addr
$2 = 12
=============================================================

Thomas

[1] http://sources.redhat.com/gdb/current/onlinedocs/gdb_33.html#SEC664
--
PETAZZONI Thomas - address@hidden
http://thomas.enix.org - Jabber: address@hidden
KOS: http://kos.enix.org/ - SOS: http://sos.enix.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7
Index: gdbstub.c
===================================================================
RCS file: /cvsroot/qemu/qemu/gdbstub.c,v
retrieving revision 1.22
diff -u -u -r1.22 gdbstub.c
--- gdbstub.c   3 Jan 2005 23:34:06 -0000       1.22
+++ gdbstub.c   15 Jan 2005 16:06:09 -0000
@@ -420,7 +420,7 @@
         if (*p == ',')
             p++;
         len = strtoul(p, (char **)&p, 16);
-        if (*p == ',')
+        if (*p == ':')
             p++;
         hextomem(mem_buf, p, len);
         if (cpu_memory_rw_debug(env, addr, mem_buf, len, 1) != 0)

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]