Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "zhigang gong" <zhigang.gong@gmail.com>
To: gdb-patches@sources.redhat.com
Subject: Wrong data type in function unpack_varlen_hex()
Date: Fri, 16 Jun 2006 12:58:00 -0000	[thread overview]
Message-ID: <40c9f5b20606160558v277bb813r9d5a497c9899432@mail.gmail.com> (raw)

Hi,

        I am working on an mips4k platform. When I added hw watchpoint
support for my target board and debug it with gdb. The write
watchpoint works fine, but rwatch and awatch doesn't work. After trace
the source code of the gdb, I found there is a bug in
unpack_varlen_hex. The local variable retval is a signed integer. For
my case, the ULONGEST is a 64bit integer type. So when the
watchpoint's address is 0x8XXXXXXX, the "retval" will be 0x8XXXXXXX,
and pass its value to variable "result", the "result"'s value will be
sign extended to 0xFFFFFFFF8XXXXXXX. Then when i set a rwatch point,
the address matching will fail when the read watchpoint ocurred.
     The patch is as belows. And I test it,


--- src/gdb/remote.c    2006-05-06 04:08:45.000000000 +0800
+++ insight-6550-060529/gdb/remote.c    2006-06-15 19:26:46.000000000 +0800
@@ -1125,7 +1125,7 @@
                   ULONGEST *result)
 {
   int nibble;
-  int retval = 0;
+  ULONGEST retval = 0;

   while (ishex (*buff, &nibble))
     {

--- src/gdb/ChangeLog   2006-05-28 13:56:50.000000000 +0800
+++ insight-6550-060529/gdb/ChangeLog   2006-06-16 09:19: 55.000000000 +0800
@@ -1,3 +1,8 @@
+2006-06-16  Zhigang Gong < zhigang.gong@gmail.com>
+       * remote.c(unpack_varlen_hex):
+       Change the type of local variable "retval" to ULONGEST, so it
will avoid
+       incorrect sign extending.
+
 2006-05-28  Alexandre Oliva  < aoliva@redhat.com>


Best Regards,
Zhigang Gong


             reply	other threads:[~2006-06-16 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-16 12:58 zhigang gong [this message]
2006-07-13  4:07 ` Daniel Jacobowitz
2006-07-13 15:19   ` zhigang gong
2006-07-13 15:23     ` Daniel Jacobowitz
2006-07-13 15:36       ` Daniel Jacobowitz
2006-07-15 10:34         ` zhigang gong
2006-07-17  0:10           ` Daniel Jacobowitz

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=40c9f5b20606160558v277bb813r9d5a497c9899432@mail.gmail.com \
    --to=zhigang.gong@gmail.com \
    --cc=gdb-patches@sources.redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox