Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* FYI: fix big-endian bug with DWARF_VALUE_STACK
@ 2010-02-23 16:08 Tom Tromey
  2010-02-23 16:16 ` Tom Tromey
  2010-02-23 19:53 ` Ulrich Weigand
  0 siblings, 2 replies; 11+ messages in thread
From: Tom Tromey @ 2010-02-23 16:08 UTC (permalink / raw)
  To: gdb-patches

I'm checking this in on the trunk and the 7.1 branch.

Jakub noticed a bug with DWARF expressions on big-endian machines.
This is https://bugzilla.redhat.com/show_bug.cgi?id=567251

Built and regtested on x86-64 (compile farm) -- little-endian, of
course, so I also ran the relevant tests on a PPC64 box in the farm.

I do have a test case (see the bugzilla link), but it only works on
PPC64, and it relies on having a very new version of gas, so I did not
include it in the patch.

Tom

2010-02-23  Tom Tromey  <tromey@redhat.com>

	* dwarf2loc.c (read_pieced_value) <DWARF_VALUE_STACK>: Correctly
	handle big-endian values.
	(dwarf2_evaluate_loc_desc) <DWARF_VALUE_STACK>: Likewise.

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 6679d74..1c4d057 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -298,16 +298,14 @@ read_pieced_value (struct value *v)
 
 	case DWARF_VALUE_STACK:
 	  {
-	    gdb_byte bytes[sizeof (ULONGEST)];
 	    size_t n;
 	    int addr_size = gdbarch_addr_bit (c->arch) / 8;
-	    store_unsigned_integer (bytes, addr_size,
-				    gdbarch_byte_order (c->arch),
-				    p->v.expr.value);
 	    n = p->size;
 	    if (n > addr_size)
 	      n = addr_size;
-	    memcpy (contents + offset, bytes, n);
+	    store_unsigned_integer (contents + offset, n,
+				    gdbarch_byte_order (c->arch),
+				    p->v.expr.value);
 	  }
 	  break;
 
@@ -476,19 +474,17 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
 
 	case DWARF_VALUE_STACK:
 	  {
-	    gdb_byte bytes[sizeof (ULONGEST)];
 	    ULONGEST value = (ULONGEST) dwarf_expr_fetch (ctx, 0);
 	    bfd_byte *contents;
 	    size_t n = ctx->addr_size;
 
-	    store_unsigned_integer (bytes, ctx->addr_size,
-				    gdbarch_byte_order (ctx->gdbarch),
-				    value);
 	    retval = allocate_value (SYMBOL_TYPE (var));
 	    contents = value_contents_raw (retval);
 	    if (n > TYPE_LENGTH (SYMBOL_TYPE (var)))
 	      n = TYPE_LENGTH (SYMBOL_TYPE (var));
-	    memcpy (contents, bytes, n);
+	    store_unsigned_integer (contents, n,
+				    gdbarch_byte_order (ctx->gdbarch),
+				    value);
 	  }
 	  break;
 


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-02-26 12:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-23 16:08 FYI: fix big-endian bug with DWARF_VALUE_STACK Tom Tromey
2010-02-23 16:16 ` Tom Tromey
2010-02-23 19:53 ` Ulrich Weigand
2010-02-23 20:26   ` Tom Tromey
2010-02-24 14:12     ` Ulrich Weigand
2010-02-24 14:20       ` Mark Wielaard
2010-02-24 16:10         ` Ulrich Weigand
2010-02-24 16:30       ` Tom Tromey
2010-02-25 20:44         ` Ulrich Weigand
2010-02-25 21:03           ` Tom Tromey
2010-02-26 12:50             ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox