Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Clear *VAL in regcache_raw_read_unsigned
Date: Tue, 09 Feb 2016 14:54:00 -0000	[thread overview]
Message-ID: <1455029644-6197-1-git-send-email-yao.qi@linaro.org> (raw)

We have function regcache_raw_read_unsigned defined in both GDB and
GDBserver, so that it is used in common like this,

  ULONGEST value;
  status = regcache_raw_read_unsigned (regcache, regnum, &value);

'value' is correctly set in GDB side, but may not be correctly set
in GDBserver, because &value is passed in regcache_raw_read_unsigned
but collect_register may only set part of the whole variable.  In my
test, I see the top half of 'value' is garbage.  This patch fixes this
problem by clearing *VAL before calling collect_register.

Regression tests are still running.  I'll push it in if there is no
regression in tests.

gdb/gdbserver:

2016-02-09  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (regcache_raw_read_unsigned): Clear *VAL.
---
 gdb/gdbserver/regcache.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index 6a737ea..2af8e24 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -440,6 +440,7 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
             "%d bytes."),
           (int) sizeof (ULONGEST));
 
+  *val = 0;
   collect_register (regcache, regnum, val);
 
   return REG_VALID;
-- 
1.9.1


             reply	other threads:[~2016-02-09 14:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 14:54 Yao Qi [this message]
2016-02-10 16:45 ` Yao Qi
2016-02-10 16:52   ` Pedro Alves
2016-02-10 17:25     ` Yao Qi
2016-02-10 17:36       ` Pedro Alves
2016-02-11 10:12         ` Yao Qi
2016-02-11 12:46           ` Pedro Alves
2016-02-11 15:15             ` Yao Qi
2016-02-11 15:51               ` Pedro Alves
2016-02-11 16:32                 ` Antoine Tremblay
2016-02-11 17:00                 ` Yao Qi
2016-02-11 17:24                   ` Pedro Alves
2016-02-12 11:15                     ` Yao Qi

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=1455029644-6197-1-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox