summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2016-12-06 14:25:51 +0000
committerYao Qi <yao.qi@linaro.org>2016-12-06 14:25:51 +0000
commit7c2ba67e6ab10879968c938aefd4d0d0b4ce79bc (patch)
treef654ea7bb52fc5b536c17d212c6065ba2704932c /gdb
parent5e359a63b7a39e0ff0f750ca8fc97d27b14c0ef7 (diff)
downloadbinutils-gdb-7c2ba67e6ab10879968c938aefd4d0d0b4ce79bc.tar.gz
Assert on lval_register
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. gdb: 2016-12-06 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/frame.c5
-rw-r--r--gdb/value.c2
3 files changed, 14 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4a64fca8d2d..ea1cff35f83 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2016-12-06 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.
+
2016-12-02 Simon Marchi <simon.marchi@polymtl.ca>
* ui-out.h: Include "common/enum-flags.h".
diff --git a/gdb/frame.c b/gdb/frame.c
index 5414cb3325a..00001bcf3f5 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1107,7 +1107,10 @@ 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);
+ else
+ *realnump = -1;
if (bufferp)
{
diff --git a/gdb/value.c b/gdb/value.c
index cc291cf7d95..022900ff73c 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;
}