Parsing problem of gdb 'M' packet
PATCH 1/1 Parsing problem of gdb 'M' packet
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
Signature · 4 lines
PETAZZONI Thomas - [email protected] http://thomas.enix.org - Jabber: [email protected] 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
gdbstub.c +1 -1
@@ -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 )
Hello,
Quoted 1 line · Thomas Petazzoni
The included one-line patch fixes the problem :
Don't hesitate to tell me if something is wrong with this patch.
Thomas
Signature · 4 lines
PETAZZONI Thomas - [email protected] http://thomas.enix.org - Jabber: [email protected] KOS: http://kos.enix.org/ - SOS: http://sos.enix.org Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7