From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cpqq0-00071A-Qp for qemu-devel@nongnu.org; Sat, 15 Jan 2005 11:31:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Cpqpu-0006xE-CV for qemu-devel@nongnu.org; Sat, 15 Jan 2005 11:31:38 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Cpqpu-0006vn-3t for qemu-devel@nongnu.org; Sat, 15 Jan 2005 11:31:38 -0500 Received: from [213.228.0.44] (helo=postfix3-1.free.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CpqXG-0004KV-93 for qemu-devel@nongnu.org; Sat, 15 Jan 2005 11:12:22 -0500 Message-ID: <41E940DD.7030803@enix.org> Date: Sat, 15 Jan 2005 17:12:13 +0100 From: Thomas Petazzoni MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA4D8A648A4CB9BF397E1CC6F" Subject: [Qemu-devel] [PATCH] Parsing problem of gdb 'M' packet Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: David Decotigny This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA4D8A648A4CB9BF397E1CC6F Content-Type: multipart/mixed; boundary="------------020807090401080206070605" This is a multi-part message in MIME format. --------------020807090401080206070605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 - thomas.petazzoni@enix.org http://thomas.enix.org - Jabber: thomas.petazzoni@jabber.dk KOS: http://kos.enix.org/ - SOS: http://sos.enix.org Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7 --------------020807090401080206070605 Content-Type: text/plain; name="gdb-M-packet-parsing-problem.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-M-packet-parsing-problem.patch" 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) --------------020807090401080206070605-- --------------enigA4D8A648A4CB9BF397E1CC6F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFB6UDg9lPLMJjT96cRAiiGAJ9QX1+/OUPpEPmy2YgTXtZkhD//nwCfVFsQ LM7LCp2Av3+P8qZarxkp7BQ= =0Nn9 -----END PGP SIGNATURE----- --------------enigA4D8A648A4CB9BF397E1CC6F--