Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/RFC] Restore old handling of multi-register variables
Date: Thu, 27 Oct 2011 02:56:00 -0000	[thread overview]
Message-ID: <20111027002409.GX19246@adacore.com> (raw)
In-Reply-To: <20111026213726.GV19246@adacore.com>

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

> gdb/ChangeLog:
> 
>         * value.h (read_frame_register_value): Add declaration.
>         * findvar.c (read_frame_register_value): New function.
>         (value_from_register): Use read_frame_register_value
>         instead of get_frame_register_value + value_contents_copy
>         to get value contents.

(sigh)

-- 
Joel

[-- Attachment #2: multi-register-value.diff --]
[-- Type: text/x-diff, Size: 2836 bytes --]

commit 7f0a0ff60859de96d30b20d1462841a1f2283a72
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Fri Oct 21 14:34:54 2011 -0700

    handle variables stored in muliple consecutive registers
    
    gdb/ChangeLog:
    
            * value.h (read_frame_register_value): Add declaration.
            * findvar.c (read_frame_register_value): New function.
            (value_from_register): Use read_frame_register_value
            instead of get_frame_register_value + value_contents_copy
            to get value contents.

diff --git a/gdb/findvar.c b/gdb/findvar.c
index 8e986f1..54e7b4a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -623,6 +623,35 @@ default_value_from_register (struct type *type, int regnum,
   return value;
 }
 
+/* VALUE must be an lval_register value.  If regnum is the value's
+   associated register number, and len the length of the values type,
+   read one or more registers in FRAME, starting with register REGNUM,
+   until we've read LEN bytes.  */
+
+void
+read_frame_register_value (struct value *value, struct frame_info *frame)
+{
+  int offset = 0;
+  int regnum = VALUE_REGNUM (value);
+  const int len = TYPE_LENGTH (check_typedef (value_type (value)));
+
+  gdb_assert (VALUE_LVAL (value) == lval_register);
+
+  while (offset < len)
+    {
+      struct value *regval = get_frame_register_value (frame, regnum);
+      int reg_len = TYPE_LENGTH (value_type (regval));
+
+      if (offset + reg_len > len)
+        reg_len = len - offset;
+      value_contents_copy (value, offset, regval, value_offset (regval),
+			   reg_len);
+
+      offset += reg_len;
+      regnum++;
+    }
+}
+
 /* Return a value of type TYPE, stored in register REGNUM, in frame FRAME.  */
 
 struct value *
@@ -661,16 +690,11 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
     }
   else
     {
-      int len = TYPE_LENGTH (type);
-      struct value *v2;
-
       /* Construct the value.  */
       v = gdbarch_value_from_register (gdbarch, type, regnum, frame);
 
       /* Get the data.  */
-      v2 = get_frame_register_value (frame, regnum);
-
-      value_contents_copy (v, 0, v2, value_offset (v), len);
+      read_frame_register_value (v, frame);
     }
 
   return v;
@@ -695,3 +719,4 @@ address_from_register (struct type *type, int regnum, struct frame_info *frame)
 
   return result;
 }
+
diff --git a/gdb/value.h b/gdb/value.h
index f18390e..d2c58ec 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -502,6 +502,9 @@ extern struct value *default_value_from_register (struct type *type,
 						  int regnum,
 						  struct frame_info *frame);
 
+extern void read_frame_register_value (struct value *value,
+				       struct frame_info *frame);
+
 extern struct value *value_from_register (struct type *type, int regnum,
 					  struct frame_info *frame);
 

  parent reply	other threads:[~2011-10-27  0:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 21:03 Joel Brobecker
2011-10-06 17:55 ` Pedro Alves
2011-10-06 20:11   ` Joel Brobecker
2011-10-06 21:00     ` Pedro Alves
2011-10-07 16:38       ` Joel Brobecker
2011-10-07 16:52         ` Pedro Alves
2011-10-22 14:48   ` Joel Brobecker
2011-10-25 19:34     ` Pedro Alves
2011-10-25 20:37       ` Joel Brobecker
2011-10-25 21:09         ` Pedro Alves
2011-10-26 21:44           ` Joel Brobecker
2011-10-26 22:11             ` Joel Brobecker
2011-10-27 15:57               ` Tom Tromey
2011-10-27 17:51                 ` Joel Brobecker
2011-10-27  2:56             ` Joel Brobecker [this message]
2011-10-27 11:10             ` Pedro Alves
2011-10-27 17:56               ` Joel Brobecker
2011-10-31  3:17             ` [RFA] read_frame_register_value and big endian arches Joel Brobecker
2011-11-07 19:42               ` Pedro Alves
2011-11-07 21:24                 ` Joel Brobecker
2011-11-10 17:15                 ` Checked in: " Joel Brobecker
2011-11-16 18:23                   ` Ulrich Weigand
2011-11-18  2:01                     ` Joel Brobecker
2011-11-18 17:40                       ` Ulrich Weigand
2011-11-18 19:41                         ` Joel Brobecker
2011-11-18 20:06                           ` [commit] " Ulrich Weigand

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=20111027002409.GX19246@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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