This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, rfc, v2] MIPS dwarf2 location lists


Joel Brobecker wrote:

> > > 	* dwarf2expr.c (dwarf2_read_address): Make static.
> > > 	* dwarf2expr.h (dwarf2_read_address): Remove prototype.
> > > 	* dwarf2loc.c (find_location_expression): Add relocation offset
> > > 	to base-address-selection entry base addresses.  Read addresses
> > > 	(and offsets) as signed/unsigned integers, depending on the
> > > 	BFD's sign_extend_vma flag.  Do not call dwarf2_read_address.
> > > 	(locexpr_describe_location): Read TLS offset as unsigned
> > > 	integer.  Do not call dwarf2_read_address.
> > 
> > Ping.  Any thoughts on whether we should go with this?
> 
> Can't really say much about the patch itself; but FWIW, I tested it
> on mips-irix, and saw no regression.

Thanks for running the test!  And sorry for taking so long to get back
to this patch ...   Dan agreed (in an off-line mail) that the patch
makes sense to him, so I'm planning to go forward with it.

Due to Tom's recent dwarf2 changes, a couple of modifications were
required.  An updated patch is appended below.

Retested with no regressions on i386-linux.
I'm planning on committing the patch next week.

Thanks,
Ulrich

ChangeLog:

	* dwarf2expr.c (dwarf2_read_address): Make static.
	* dwarf2expr.h (dwarf2_read_address): Remove prototype.
	* dwarf2loc.c (find_location_expression): Add relocation offset
	to base-address-selection entry base addresses.  Read addresses
	(and offsets) as signed/unsigned integers, depending on the
	BFD's sign_extend_vma flag.  Do not call dwarf2_read_address.
	(loclist_describe_location): Likewise.
	(disassemble_dwarf_expression): Read DW_OP_addr operand as
	unsigned integer.  Do not call dwarf2_read_address.
	(locexpr_describe_location): Likewise for DW_OP_GNU_push_tls_address.


Index: gdb/dwarf2expr.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.c,v
retrieving revision 1.46
diff -u -p -r1.46 dwarf2expr.c
--- gdb/dwarf2expr.c	7 Jun 2010 19:55:33 -0000	1.46
+++ gdb/dwarf2expr.c	11 Jun 2010 13:19:13 -0000
@@ -263,7 +263,7 @@ read_sleb128 (const gdb_byte *buf, const
 /* Read an address of size ADDR_SIZE from BUF, and verify that it
    doesn't extend past BUF_END.  */
 
-CORE_ADDR
+static CORE_ADDR
 dwarf2_read_address (struct gdbarch *gdbarch, const gdb_byte *buf,
 		     const gdb_byte *buf_end, int addr_size)
 {
Index: gdb/dwarf2expr.h
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.h,v
retrieving revision 1.25
diff -u -p -r1.25 dwarf2expr.h
--- gdb/dwarf2expr.h	7 Jun 2010 19:55:33 -0000	1.25
+++ gdb/dwarf2expr.h	11 Jun 2010 13:19:13 -0000
@@ -204,8 +204,6 @@ const gdb_byte *read_uleb128 (const gdb_
 			      ULONGEST * r);
 const gdb_byte *read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
 			      LONGEST * r);
-CORE_ADDR dwarf2_read_address (struct gdbarch *gdbarch, const gdb_byte *buf,
-			       const gdb_byte *buf_end, int addr_size);
 
 const char *dwarf_stack_op_name (unsigned int, int);
 
Index: gdb/dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.88
diff -u -p -r1.88 dwarf2loc.c
--- gdb/dwarf2loc.c	7 Jun 2010 19:55:33 -0000	1.88
+++ gdb/dwarf2loc.c	11 Jun 2010 13:19:13 -0000
@@ -67,6 +67,7 @@ find_location_expression (struct dwarf2_
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
+  int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Adjust base_address for relocatable objects.  */
   CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
@@ -81,21 +82,25 @@ find_location_expression (struct dwarf2_
       if (buf_end - loc_ptr < 2 * addr_size)
 	error (_("find_location_expression: Corrupted DWARF expression."));
 
-      low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
+      if (signed_addr_p)
+	low = extract_signed_integer (loc_ptr, addr_size, byte_order);
+      else
+	low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
+      loc_ptr += addr_size;
+
+      if (signed_addr_p)
+	high = extract_signed_integer (loc_ptr, addr_size, byte_order);
+      else
+	high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
       loc_ptr += addr_size;
 
       /* A base-address-selection entry.  */
-      if (low == base_mask)
+      if ((low & base_mask) == base_mask)
 	{
-	  base_address = dwarf2_read_address (gdbarch,
-					      loc_ptr, buf_end, addr_size);
-	  loc_ptr += addr_size;
+	  base_address = high + base_offset;
 	  continue;
 	}
 
-      high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
-      loc_ptr += addr_size;
-
       /* An end-of-list entry.  */
       if (low == 0 && high == 0)
 	return NULL;
@@ -1468,15 +1473,14 @@ locexpr_describe_location_piece (struct 
 	   && data[1 + addr_size] == DW_OP_GNU_push_tls_address
 	   && piece_end_p (data + 2 + addr_size, end))
     {
-      CORE_ADDR offset = dwarf2_read_address (gdbarch,
-					      data + 1,
-					      end,
-					      addr_size);
+      ULONGEST offset;
+      offset = extract_unsigned_integer (data + 1, addr_size,
+					 gdbarch_byte_order (gdbarch));
 
       fprintf_filtered (stream, 
-			_("a thread-local variable at offset %s "
+			_("a thread-local variable at offset 0x%s "
 			  "in the thread-local storage for `%s'"),
-			paddress (gdbarch, offset), objfile->name);
+			phex_nz (offset, addr_size), objfile->name);
 
       data += 1 + addr_size + 1;
     }
@@ -1513,7 +1517,6 @@ disassemble_dwarf_expression (struct ui_
 	     || (data[0] != DW_OP_piece && data[0] != DW_OP_bit_piece)))
     {
       enum dwarf_location_atom op = *data++;
-      CORE_ADDR addr;
       ULONGEST ul;
       LONGEST l;
       const char *name;
@@ -1528,9 +1531,10 @@ disassemble_dwarf_expression (struct ui_
       switch (op)
 	{
 	case DW_OP_addr:
-	  addr = dwarf2_read_address (arch, data, end, addr_size);
+	  ul = extract_unsigned_integer (data, addr_size,
+					 gdbarch_byte_order (arch));
 	  data += addr_size;
-	  fprintf_filtered (stream, " %s", paddress (arch, addr));
+	  fprintf_filtered (stream, " 0x%s", phex_nz (ul, addr_size));
 	  break;
 
 	case DW_OP_const1u:
@@ -1938,6 +1942,7 @@ loclist_describe_location (struct symbol
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int addr_size = dwarf2_per_cu_addr_size (dlbaton->per_cu);
   int offset_size = dwarf2_per_cu_offset_size (dlbaton->per_cu);
+  int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
   CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
   /* Adjust base_address for relocatable objects.  */
   CORE_ADDR base_offset = ANOFFSET (objfile->section_offsets,
@@ -1956,23 +1961,27 @@ loclist_describe_location (struct symbol
 	error (_("Corrupted DWARF expression for symbol \"%s\"."),
 	       SYMBOL_PRINT_NAME (symbol));
 
-      low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
+      if (signed_addr_p)
+	low = extract_signed_integer (loc_ptr, addr_size, byte_order);
+      else
+	low = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
+      loc_ptr += addr_size;
+
+      if (signed_addr_p)
+	high = extract_signed_integer (loc_ptr, addr_size, byte_order);
+      else
+	high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
       loc_ptr += addr_size;
 
       /* A base-address-selection entry.  */
-      if (low == base_mask)
+      if ((low & base_mask) == base_mask)
 	{
-	  base_address = dwarf2_read_address (gdbarch,
-					      loc_ptr, buf_end, addr_size);
+	  base_address = high + base_offset;
 	  fprintf_filtered (stream, _("  Base address %s"),
 			    paddress (gdbarch, base_address));
-	  loc_ptr += addr_size;
 	  continue;
 	}
 
-      high = extract_unsigned_integer (loc_ptr, addr_size, byte_order);
-      loc_ptr += addr_size;
-
       /* An end-of-list entry.  */
       if (low == 0 && high == 0)
 	break;



-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]