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 1/3] Move computed value's frame id to piece_closure
Date: Fri, 25 Nov 2016 10:07:00 -0000	[thread overview]
Message-ID: <1480068407-22616-2-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1480068407-22616-1-git-send-email-yao.qi@linaro.org>

Nowadays, we set computed value's frame id, which is a misuse to me.
The computed value itself doesn't care about frame id, but function
value_computed_funcs (val)->read (or read_pieced_value) cares about
which frame the register is relative to, so 'struct piece_closure' is
a better place to fit frame id.

This patch adds a frame id in 'struct piece_closure', and use it
instead of using computed value's frame id.

gdb:

2016-11-24  Yao Qi  <yao.qi@linaro.org>

	* dwarf2loc.c (struct piece_closure) <frame_id>: New field.
	(allocate_piece_closure): Add new parameter 'frame' and set
	closure's frame_id field accordingly.
	(read_pieced_value): Get frame from closure instead of value.
	(dwarf2_evaluate_loc_desc_full): Remove code getting frame id.
	Don't set value's frame id.
---
 gdb/dwarf2loc.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 44dceda..872d033 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1464,6 +1464,10 @@ struct piece_closure
 
   /* The pieces themselves.  */
   struct dwarf_expr_piece *pieces;
+
+  /* Frame ID of frame to which a register value is relative, used
+     only by DWARF_VALUE_REGISTER.  */
+  struct frame_id frame_id;
 };
 
 /* Allocate a closure for a value formed from separately-described
@@ -1472,7 +1476,7 @@ struct piece_closure
 static struct piece_closure *
 allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
 			int n_pieces, struct dwarf_expr_piece *pieces,
-			int addr_size)
+			int addr_size, struct frame_info *frame)
 {
   struct piece_closure *c = XCNEW (struct piece_closure);
   int i;
@@ -1482,6 +1486,10 @@ allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
   c->n_pieces = n_pieces;
   c->addr_size = addr_size;
   c->pieces = XCNEWVEC (struct dwarf_expr_piece, n_pieces);
+  if (frame == NULL)
+    c->frame_id = null_frame_id;
+  else
+    c->frame_id = get_frame_id (get_next_frame_sentinel_okay (frame));
 
   memcpy (c->pieces, pieces, n_pieces * sizeof (struct dwarf_expr_piece));
   for (i = 0; i < n_pieces; ++i)
@@ -1672,18 +1680,12 @@ read_pieced_value (struct value *v)
   gdb_byte *contents;
   struct piece_closure *c
     = (struct piece_closure *) value_computed_closure (v);
-  struct frame_info *frame;
   size_t type_len;
   size_t buffer_size = 0;
   std::vector<gdb_byte> buffer;
   int bits_big_endian
     = gdbarch_bits_big_endian (get_type_arch (value_type (v)));
 
-  /* VALUE_FRAME_ID is used instead of VALUE_NEXT_FRAME_ID here
-     because FRAME is passed to get_frame_register_bytes(), which
-     does its own "->next" operation.  */
-  frame = frame_find_by_id (VALUE_FRAME_ID (v));
-
   if (value_type (v) != value_enclosing_type (v))
     internal_error (__FILE__, __LINE__,
 		    _("Should not be able to create a lazy value with "
@@ -1743,6 +1745,8 @@ read_pieced_value (struct value *v)
 	{
 	case DWARF_VALUE_REGISTER:
 	  {
+	    struct frame_info *frame
+	      = frame_find_by_id (get_prev_frame_id_by_id (c->frame_id));
 	    struct gdbarch *arch = get_frame_arch (frame);
 	    int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno);
 	    int optim, unavail;
@@ -2311,10 +2315,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
   if (ctx.num_pieces > 0)
     {
       struct piece_closure *c;
-      struct frame_id frame_id
-        = frame == NULL 
-	  ? null_frame_id
-	  : get_frame_id (get_next_frame_sentinel_okay (frame));
       ULONGEST bit_size = 0;
       int i;
 
@@ -2324,12 +2324,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
 	invalid_synthetic_pointer ();
 
       c = allocate_piece_closure (per_cu, ctx.num_pieces, ctx.pieces,
-				  ctx.addr_size);
+				  ctx.addr_size, frame);
       /* We must clean up the value chain after creating the piece
 	 closure but before allocating the result.  */
       do_cleanups (value_chain);
       retval = allocate_computed_value (type, &pieced_value_funcs, c);
-      VALUE_NEXT_FRAME_ID (retval) = frame_id;
       set_value_offset (retval, byte_offset);
     }
   else
-- 
1.9.1


  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 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
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               ` [PATCH 2/3] Adjust Value.location " Yao Qi
2016-11-25 11:51                 ` 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               ` Yao Qi [this message]
2016-11-25 11:48                 ` [PATCH 1/3] Move computed value's frame id to piece_closure 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 3/3] Restrict value_has_address Yao Qi
2016-11-22 18:06   ` 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-2-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