Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc] dwarf2 unwinder and MIPS n32
Date: Mon, 30 Apr 2007 13:28:00 -0000	[thread overview]
Message-ID: <20070430132613.GD25539@caradoc.them.org> (raw)
In-Reply-To: <200704282240.l3SMefEh024381@d12av02.megacenter.de.ibm.com>

On Sun, Apr 29, 2007 at 12:40:41AM +0200, Ulrich Weigand wrote:
> Well, when we *read* a register in order to get (or compute) the CFA,
> read_reg does
> 
>   unpack_long (register_type (gdbarch, regnum), buf)
> 
> which in turn uses either extract_type_address, extract_signed_integer,
> or extract_unsigned_integer, depending on the type.
> 
> It may make sense to perform the analogous operation when *writing*
> the CFA to (an unwound copy of the contents of) a register.  There
> is no "pack_long", [...]

Well then, how about we add one?  Your mention of symmetry is I think
very important; we have a lot of different ways to manipulate longs /
addresses, and I'd rather reduce than increase the number, but the
first step is to make the interfaces we have consistent.

Tested on mips64-linux N32, where it still fixes the problem; unlike
the previous patch, this one should not break segmented architectures
that need to adjust pointers and addresses.

-- 
Daniel Jacobowitz
CodeSourcery

2007-04-30  Daniel Jacobowitz  <dan@codesourcery.com>

	* dwarf2-frame.c (dwarf2_frame_prev_register): Use pack_long
	instead of store_typed_address.
	* value.c (pack_long): New.
	(value_from_longest): Use it.
	* value.h (pack_long): New prototype.

---
 dwarf2-frame.c |   14 ++++----------
 value.c        |   36 ++++++++++++++++++++++--------------
 value.h        |    2 ++
 3 files changed, 28 insertions(+), 24 deletions(-)

Index: gdb/dwarf2-frame.c
===================================================================
--- gdb.orig/dwarf2-frame.c	2007-04-30 08:29:26.000000000 -0400
+++ gdb/dwarf2-frame.c	2007-04-30 08:34:48.000000000 -0400
@@ -1137,10 +1137,7 @@ dwarf2_frame_prev_register (struct frame
       *addrp = 0;
       *realnump = -1;
       if (valuep)
-	{
-	  /* Store the value.  */
-	  store_typed_address (valuep, builtin_type_void_data_ptr, cache->cfa);
-	}
+	pack_long (valuep, register_type (gdbarch, regnum), cache->cfa);
       break;
 
     case DWARF2_FRAME_REG_CFA_OFFSET:
@@ -1149,11 +1146,8 @@ dwarf2_frame_prev_register (struct frame
       *addrp = 0;
       *realnump = -1;
       if (valuep)
-	{
-	  /* Store the value.  */
-	  store_typed_address (valuep, builtin_type_void_data_ptr,
-			       cache->cfa + cache->reg[regnum].loc.offset);
-	}
+	pack_long (valuep, register_type (gdbarch, regnum),
+		   cache->cfa + cache->reg[regnum].loc.offset);
       break;
 
     case DWARF2_FRAME_REG_RA_OFFSET:
@@ -1167,7 +1161,7 @@ dwarf2_frame_prev_register (struct frame
 
           regnum = DWARF2_REG_TO_REGNUM (cache->retaddr_reg.loc.reg);
           pc += frame_unwind_register_unsigned (next_frame, regnum);
-          store_typed_address (valuep, builtin_type_void_func_ptr, pc);
+          pack_long (valuep, register_type (gdbarch, regnum), pc);
         }
       break;
 
Index: gdb/value.c
===================================================================
--- gdb.orig/value.c	2007-04-30 08:29:26.000000000 -0400
+++ gdb/value.c	2007-04-30 08:35:14.000000000 -0400
@@ -1505,23 +1505,18 @@ modify_field (gdb_byte *addr, LONGEST fi
   store_unsigned_integer (addr, sizeof oword, oword);
 }
 \f
-/* Convert C numbers into newly allocated values */
+/* Pack NUM into BUF using a target format of TYPE.  */
 
-struct value *
-value_from_longest (struct type *type, LONGEST num)
+void
+pack_long (gdb_byte *buf, struct type *type, LONGEST num)
 {
-  struct value *val = allocate_value (type);
-  enum type_code code;
   int len;
-retry:
-  code = TYPE_CODE (type);
+
+  type = check_typedef (type);
   len = TYPE_LENGTH (type);
 
-  switch (code)
+  switch (TYPE_CODE (type))
     {
-    case TYPE_CODE_TYPEDEF:
-      type = check_typedef (type);
-      goto retry;
     case TYPE_CODE_INT:
     case TYPE_CODE_CHAR:
     case TYPE_CODE_ENUM:
@@ -1529,17 +1524,30 @@ retry:
     case TYPE_CODE_BOOL:
     case TYPE_CODE_RANGE:
     case TYPE_CODE_MEMBERPTR:
-      store_signed_integer (value_contents_raw (val), len, num);
+      store_signed_integer (buf, len, num);
       break;
 
     case TYPE_CODE_REF:
     case TYPE_CODE_PTR:
-      store_typed_address (value_contents_raw (val), type, (CORE_ADDR) num);
+      store_typed_address (buf, type, (CORE_ADDR) num);
       break;
 
     default:
-      error (_("Unexpected type (%d) encountered for integer constant."), code);
+      error (_("Unexpected type (%d) encountered for integer constant."),
+	     TYPE_CODE (type));
     }
+}
+
+
+/* Convert C numbers into newly allocated values.  */
+
+struct value *
+value_from_longest (struct type *type, LONGEST num)
+{
+  struct value *val = allocate_value (type);
+
+  pack_long (value_contents_raw (val), type, num);
+
   return val;
 }
 
Index: gdb/value.h
===================================================================
--- gdb.orig/value.h	2007-04-30 08:29:26.000000000 -0400
+++ gdb/value.h	2007-04-30 08:29:57.000000000 -0400
@@ -271,6 +271,8 @@ extern LONGEST unpack_field_as_long (str
 				     const gdb_byte *valaddr,
 				     int fieldno);
 
+extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
+
 extern struct value *value_from_longest (struct type *type, LONGEST num);
 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
 extern struct value *value_from_double (struct type *type, DOUBLEST num);


  reply	other threads:[~2007-04-30 13:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-28 20:42 Daniel Jacobowitz
2007-04-28 22:52 ` Ulrich Weigand
2007-04-30 13:28   ` Daniel Jacobowitz [this message]
2007-04-30 20:19     ` Ulrich Weigand
2007-05-14 17:22       ` Daniel Jacobowitz
2007-04-30 13:00 ` Maciej W. Rozycki
2007-04-30 13:26   ` Daniel Jacobowitz
2007-04-30 13:44     ` Maciej W. Rozycki

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=20070430132613.GD25539@caradoc.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.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