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] Handle DW_OP_GNU_const_index


Hi.

fyi, I will be checking this in once the corresponding change
to include/dwarf2.def is approved on the gcc side
(and the change is brought over to src).

2012-06-14  Doug Evans  <dje@google.com>

	* dwarf2expr.c (execute_stack_op): Handle DW_OP_GNU_const_index.
	Adjust address for DW_OP_GNU_addr_index.
	* dwarf2expr.h (dwarf_expr_context): Update comment.
	* dwarf2loc.c (locexpr_describe_location_piece): Handle
	TLS vars described with DW_OP_GNU_const_index.
	(disassemble_dwarf_expression): Handle DW_OP_GNU_addr_index
	and DW_OP_GNU_const_index.
	* dwarf2read.c (decode_locdesc): Handle DW_OP_GNU_addr_index.

Index: dwarf2expr.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.c,v
retrieving revision 1.84
diff -u -p -r1.84 dwarf2expr.c
--- dwarf2expr.c	24 May 2012 01:26:15 -0000	1.84
+++ dwarf2expr.c	14 Jun 2012 19:45:11 -0000
@@ -727,6 +727,12 @@ execute_stack_op (struct dwarf_expr_cont
 	case DW_OP_GNU_addr_index:
 	  op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
 	  result = (ctx->funcs->get_addr_index) (ctx->baton, uoffset);
+	  result += ctx->offset;
+	  result_val = value_from_ulongest (address_type, result);
+	  break;
+	case DW_OP_GNU_const_index:
+	  op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
+	  result = (ctx->funcs->get_addr_index) (ctx->baton, uoffset);
 	  result_val = value_from_ulongest (address_type, result);
 	  break;
 
Index: dwarf2expr.h
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2expr.h,v
retrieving revision 1.48
diff -u -p -r1.48 dwarf2expr.h
--- dwarf2expr.h	24 May 2012 01:26:15 -0000	1.48
+++ dwarf2expr.h	14 Jun 2012 19:45:11 -0000
@@ -158,7 +158,7 @@ struct dwarf_expr_context
      context and operations depending on DW_FORM_ref_addr are not allowed.  */
   int ref_addr_size;
 
-  /* Offset used to relocate DW_OP_addr argument.  */
+  /* Offset used to relocate DW_OP_addr and DW_OP_GNU_addr_index arguments.  */
   CORE_ADDR offset;
 
   /* An opaque argument provided by the caller, which will be passed
Index: dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.147
diff -u -p -r1.147 dwarf2loc.c
--- dwarf2loc.c	24 May 2012 01:26:15 -0000	1.147
+++ dwarf2loc.c	14 Jun 2012 19:45:11 -0000
@@ -3258,6 +3263,7 @@ locexpr_describe_location_piece (struct 
 				 unsigned int addr_size)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
+  size_t leb128_size;
 
   if (data[0] >= DW_OP_reg0 && data[0] <= DW_OP_reg31)
     {
@@ -3377,6 +3383,28 @@ locexpr_describe_location_piece (struct 
 
       data += 1 + addr_size + 1;
     }
+
+  /* With -gsplit-dwarf a TLS variable can also look like this:
+     DW_AT_location    : 3 byte block: fc 4 e0
+                        (DW_OP_GNU_const_index: 4;
+			 DW_OP_GNU_push_tls_address)  */
+  else if (data + 3 <= end
+	   && data + 1 + (leb128_size = skip_leb128 (data + 1, end)) < end
+	   && data[0] == DW_OP_GNU_const_index
+	   && leb128_size > 0
+	   && data[1 + leb128_size] == DW_OP_GNU_push_tls_address
+	   && piece_end_p (data + 2 + leb128_size, end))
+    {
+      ULONGEST offset;
+
+      data = safe_read_uleb128 (data + 1, end, &offset);
+      fprintf_filtered (stream, 
+			_("a thread-local variable at offset 0x%s "
+			  "in the thread-local storage for `%s'"),
+			phex_nz (offset, addr_size), objfile->name);
+      data += 1 + leb128_size + 1;
+    }
+
   else if (data[0] >= DW_OP_lit0
 	   && data[0] <= DW_OP_lit31
 	   && data + 1 < end
@@ -3732,6 +3760,17 @@ disassemble_dwarf_expression (struct ui_
 					all, per_cu);
 	  data += ul;
 	  continue;
+
+	case DW_OP_GNU_addr_index:
+	  data = safe_read_uleb128 (data, end, &ul);
+	  ul = dwarf2_read_addr_index (per_cu, ul);
+	  fprintf_filtered (stream, " 0x%s", phex_nz (ul, addr_size));
+	  break;
+	case DW_OP_GNU_const_index:
+	  data = safe_read_uleb128 (data, end, &ul);
+	  ul = dwarf2_read_addr_index (per_cu, ul);
+	  fprintf_filtered (stream, " %s", pulongest (ul));
+	  break;
 	}
 
       fprintf_filtered (stream, "\n");
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.661
diff -u -p -r1.661 dwarf2read.c
--- dwarf2read.c	11 Jun 2012 20:19:22 -0000	1.661
+++ dwarf2read.c	14 Jun 2012 19:45:11 -0000
@@ -15496,6 +15496,7 @@ decode_locdesc (struct dwarf_block *blk,
 	  break;
 
 	case DW_OP_GNU_addr_index:
+	case DW_OP_GNU_const_index:
 	  stack[++stacki] = read_addr_index_from_leb128 (cu, &data[i],
 							 &bytes_read);
 	  i += bytes_read;


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