From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Assert on lval_register
Date: Wed, 30 Nov 2016 14:56:00 -0000 [thread overview]
Message-ID: <1480517757-11733-1-git-send-email-yao.qi@linaro.org> (raw)
This patch adds asserts where the value's lval must be lval_register.
This triggers an error in frame_register_unwind because VALUE_REGNUM
is used but value's lval is not lval_register.
This also reveals a design issue in frame_register_unwind, that is
arguments addrp and realnump are mutually exclusive, we either use
addrp (for lval_memory), or use realnump (for lval_register). This
can be done in a separate patch.
Regression tested on x86_64-linux.
gdb:
2016-11-30 Yao Qi <yao.qi@linaro.org>
* frame.c (frame_register_unwind): Set *realnump if *lvalp is
lval_register.
* value.c (deprecated_value_next_frame_id_hack): Assert
value->lval is lval_register.
(deprecated_value_regnum_hack): Likewise.
---
gdb/frame.c | 3 ++-
gdb/value.c | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/frame.c b/gdb/frame.c
index 5414cb3..1c388d1 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1107,7 +1107,8 @@ frame_register_unwind (struct frame_info *frame, int regnum,
*unavailablep = !value_entirely_available (value);
*lvalp = VALUE_LVAL (value);
*addrp = value_address (value);
- *realnump = VALUE_REGNUM (value);
+ if (*lvalp == lval_register)
+ *realnump = VALUE_REGNUM (value);
if (bufferp)
{
diff --git a/gdb/value.c b/gdb/value.c
index cc291cf..022900f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1576,12 +1576,14 @@ deprecated_value_internalvar_hack (struct value *value)
struct frame_id *
deprecated_value_next_frame_id_hack (struct value *value)
{
+ gdb_assert (value->lval == lval_register);
return &value->location.reg.next_frame_id;
}
int *
deprecated_value_regnum_hack (struct value *value)
{
+ gdb_assert (value->lval == lval_register);
return &value->location.reg.regnum;
}
--
1.9.1
next reply other threads:[~2016-11-30 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 14:56 Yao Qi [this message]
2016-11-30 21:16 ` Ulrich Weigand
2016-12-06 10:15 ` Yao Qi
2016-12-06 13:13 ` Ulrich Weigand
2016-12-06 14:26 ` 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=1480517757-11733-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