From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/3] Adjust Value.location for lval_register
Date: Fri, 25 Nov 2016 10:07:00 -0000 [thread overview]
Message-ID: <1480068407-22616-3-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1480068407-22616-1-git-send-email-yao.qi@linaro.org>
value.regnum and value.next_frame_id are only used for lval_register,
so this patch moves them to union value.location. As a result, when
we copy value, only copy location, don't need to copy regnum and
next_frame_id.
gdb:
2016-11-23 Yao Qi <yao.qi@linaro.org>
* valops.c (value_slice): Don't set frame id of slice.
* value.c (struct value) <regnum, next_frame_id>: Move them to...
(struct value) <location>: ... here. Update comments.
(allocate_value_lazy): Don't set frame id and regnum.
(deprecated_value_next_frame_id_hack): Adjust.
(deprecated_value_regnum_hack): Adjust.
(value_copy): Don't copy frame id and regnu.
(value_primitive_field): Likewise.
(value_from_component): Likewise.
---
gdb/valops.c | 1 -
gdb/value.c | 40 +++++++++++++++-------------------------
2 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/gdb/valops.c b/gdb/valops.c
index 8a45641..3a7550d 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3827,7 +3827,6 @@ value_slice (struct value *array, int lowbound, int length)
}
set_value_component_location (slice, array);
- VALUE_NEXT_FRAME_ID (slice) = VALUE_NEXT_FRAME_ID (array);
set_value_offset (slice, value_offset (array) + offset);
}
diff --git a/gdb/value.c b/gdb/value.c
index 8d33501..eff5462 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -205,17 +205,23 @@ struct value
/* If the value has been released. */
unsigned int released : 1;
- /* Register number if the value is from a register. */
- short regnum;
-
/* Location of value (if lval). */
union
{
- /* If lval == lval_memory, this is the address in the inferior.
- If lval == lval_register, this is the byte offset into the
- registers structure. */
+ /* If lval == lval_memory, this is the address in the inferior */
CORE_ADDR address;
+ /*If lval == lval_register, the value is from a register. */
+ struct
+ {
+ /* Register number. */
+ short regnum;
+ /* Frame ID of "next" frame to which a register value is relative.
+ If the register value is found relative to frame F, then the
+ frame id of F->next will be stored in next_frame_id. */
+ struct frame_id next_frame_id;
+ } reg;
+
/* Pointer to internal variable. */
struct internalvar *internalvar;
@@ -237,9 +243,7 @@ struct value
/* Describes offset of a value within lval of a structure in target
addressable memory units. If lval == lval_memory, this is an offset to
- the address. If lval == lval_register, this is a further offset from
- location.address within the registers structure. Note also the member
- embedded_offset below. */
+ the address. Note also the member embedded_offset below. */
LONGEST offset;
/* Only used for bitfields; number of bits contained in them. */
@@ -262,12 +266,6 @@ struct value
bitfields. */
struct value *parent;
- /* Frame ID of "next" frame to which a register value is relative. A
- register value is indicated when the lval enum (above) is set to
- lval_register. So, if the register value is found relative to frame F,
- then the frame id of F->next will be stored in next_frame_id. */
- struct frame_id next_frame_id;
-
/* Type of the value. */
struct type *type;
@@ -945,11 +943,9 @@ allocate_value_lazy (struct type *type)
val->enclosing_type = type;
VALUE_LVAL (val) = not_lval;
val->location.address = 0;
- VALUE_NEXT_FRAME_ID (val) = null_frame_id;
val->offset = 0;
val->bitpos = 0;
val->bitsize = 0;
- VALUE_REGNUM (val) = -1;
val->lazy = 1;
val->embedded_offset = 0;
val->pointed_to_offset = 0;
@@ -1586,13 +1582,13 @@ deprecated_value_internalvar_hack (struct value *value)
struct frame_id *
deprecated_value_next_frame_id_hack (struct value *value)
{
- return &value->next_frame_id;
+ return &value->location.reg.next_frame_id;
}
short *
deprecated_value_regnum_hack (struct value *value)
{
- return &value->regnum;
+ return &value->location.reg.regnum;
}
int
@@ -1788,8 +1784,6 @@ value_copy (struct value *arg)
val->offset = arg->offset;
val->bitpos = arg->bitpos;
val->bitsize = arg->bitsize;
- VALUE_NEXT_FRAME_ID (val) = VALUE_NEXT_FRAME_ID (arg);
- VALUE_REGNUM (val) = VALUE_REGNUM (arg);
val->lazy = arg->lazy;
val->embedded_offset = value_embedded_offset (arg);
val->pointed_to_offset = arg->pointed_to_offset;
@@ -3229,8 +3223,6 @@ value_primitive_field (struct value *arg1, LONGEST offset,
+ value_embedded_offset (arg1));
}
set_value_component_location (v, arg1);
- VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
- VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (arg1);
return v;
}
@@ -3814,8 +3806,6 @@ value_from_component (struct value *whole, struct type *type, LONGEST offset)
}
v->offset = value_offset (whole) + offset + value_embedded_offset (whole);
set_value_component_location (v, whole);
- VALUE_REGNUM (v) = VALUE_REGNUM (whole);
- VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (whole);
return v;
}
--
1.9.1
next prev parent reply other threads:[~2016-11-25 10:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-22 15:49 [PATCH 0/3] New function value_has_address Yao Qi
2016-11-22 15:49 ` [PATCH 3/3] Restrict value_has_address Yao Qi
2016-11-22 18:06 ` Pedro Alves
2016-11-22 15:49 ` [PATCH 1/3] New function value_has_address Yao Qi
2016-11-22 16:50 ` Joel Brobecker
2016-11-22 17:56 ` Pedro Alves
2016-11-22 18:16 ` Ulrich Weigand
2016-11-22 18:29 ` Pedro Alves
2016-11-23 9:26 ` Yao Qi
2016-11-23 12:50 ` Ulrich Weigand
2016-11-25 10:07 ` [PATCH 0/3] regnum and next_frame_id are only used for lval_register Yao Qi
2016-11-25 10:07 ` Yao Qi [this message]
2016-11-25 11:51 ` [PATCH 2/3] Adjust Value.location " Ulrich Weigand
2016-11-25 11:57 ` Yao Qi
2016-11-25 12:10 ` Ulrich Weigand
2016-11-28 17:22 ` Yao Qi
2016-11-25 10:07 ` [PATCH 1/3] Move computed value's frame id to piece_closure Yao Qi
2016-11-25 11:48 ` Ulrich Weigand
2016-11-28 17:20 ` Yao Qi
2016-11-25 10:07 ` [PATCH 3/3] Restrict checking value.lval on using address Yao Qi
2016-11-25 11:52 ` Ulrich Weigand
2016-11-28 17:22 ` Yao Qi
2016-11-22 15:49 ` [PATCH 2/3] Set VALUE_VAL before set_value_address Yao Qi
2016-11-22 17:46 ` Luis Machado
2016-11-22 18:03 ` Pedro Alves
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=1480068407-22616-3-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