All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@enix.org>
To: qemu-devel@nongnu.org
Cc: David Decotigny <david.decotigny@free.fr>
Subject: [Qemu-devel] [PATCH] Parsing problem of gdb 'M' packet
Date: Sat, 15 Jan 2005 17:12:13 +0100	[thread overview]
Message-ID: <41E940DD.7030803@enix.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1241 bytes --]

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

[-- Attachment #1.2: gdb-M-packet-parsing-problem.patch --]
[-- Type: text/plain, Size: 540 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

             reply	other threads:[~2005-01-15 16:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-15 16:12 Thomas Petazzoni [this message]
2005-01-16 22:29 ` [Qemu-devel] [PATCH] Parsing problem of gdb 'M' packet Thomas Petazzoni

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=41E940DD.7030803@enix.org \
    --to=thomas.petazzoni@enix.org \
    --cc=david.decotigny@free.fr \
    --cc=qemu-devel@nongnu.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.