Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Gracefully handle not being able to access a DWARF  register number
@ 2010-04-26 15:28 Matthew Gretton-Dann
  2010-04-26 20:06 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Gretton-Dann @ 2010-04-26 15:28 UTC (permalink / raw)
  To: gdb-patches

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

Hi,

There are cases when gcc outputs a valid DWARF register number in a
DWARF expression, but gdb can't access that register.  In theory this is
a generic problem, but the specific case I'm interested in is debugging
ARM VFP code on Linux with a kernel prior to 2.6.30. In this case ptrace
does not expose the contents of a processes' VFP registers although gcc
accurately describes the location of floating point values as being in
the VFP registers.

If you try to access such a DWARF register number gdb reports an
internal error.

The attached patch changes these internal errors into warnings, and
tries to return something sensible to the user.

Please could someone review and comment on the patch, and then if this
is approved can they please commit it as I don't have commit rights.

Suggested ChangeLog:

2010-04-26  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

	* dwarf2loc.c (read_pieced_value, write_pieced_value,
	dwarf2_evaluate_loc_desc): Handle not being able to access DWARF
	registers gracefully.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Principal Engineer - Tools, PD Software
ARM Limited

[-- Attachment #2: 1004-gdb-dwarf2loc.patch --]
[-- Type: text/x-patch, Size: 2259 bytes --]

Index: gdb/dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.75
diff -u -p -r1.75 dwarf2loc.c
--- gdb/dwarf2loc.c	20 Apr 2010 18:52:59 -0000	1.75
+++ gdb/dwarf2loc.c	26 Apr 2010 14:51:25 -0000
@@ -284,8 +284,17 @@ read_pieced_value (struct value *v)
 	      /* Big-endian, and we want less than full size.  */
 	      reg_offset = register_size (arch, gdb_regnum) - p->size;
 
-	    get_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
-				      contents + offset);
+	    if (gdb_regnum != -1)
+	      {
+		get_frame_register_bytes (frame, gdb_regnum, reg_offset, 
+					  p->size, contents + offset);
+	      }
+	    else
+	      {
+		warning (_("Unable to access DWARF register number %" BFD_VMA_FMT "d"),
+			 p->v.expr.value);
+		memset (contents + offset, '\0', p->size);
+	      }
 	  }
 	  break;
 
@@ -356,8 +365,16 @@ write_pieced_value (struct value *to, st
 	      /* Big-endian, and we want less than full size.  */
 	      reg_offset = register_size (arch, gdb_regnum) - p->size;
 
-	    put_frame_register_bytes (frame, gdb_regnum, reg_offset, p->size,
-				      contents + offset);
+	    if (gdb_regnum != -1)
+	      {
+		put_frame_register_bytes (frame, gdb_regnum, reg_offset, 
+					  p->size, contents + offset);
+	      }
+	    else
+	      {
+		warning (_("Unable to write to DWARF Register %" BFD_VMA_FMT "d"),
+			 p->v.expr.value);
+	      }
 	  }
 	  break;
 	case DWARF_VALUE_MEMORY:
@@ -454,7 +471,20 @@ dwarf2_evaluate_loc_desc (struct symbol 
 	    struct gdbarch *arch = get_frame_arch (frame);
 	    CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
 	    int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_regnum);
-	    retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame);
+	    if (gdb_regnum != -1)
+	      {
+		retval = value_from_register (SYMBOL_TYPE (var),
+					      gdb_regnum, frame);
+	      }
+	    else
+	      {
+		warning (_("Unable to access DWARF register number %" BFD_VMA_FMT "d"),
+			 dwarf_regnum);
+		retval = allocate_value (SYMBOL_TYPE (var));
+		VALUE_LVAL (retval) = not_lval;
+		set_value_optimized_out (retval, 1);
+		return retval;
+	      }
 	  }
 	  break;
 

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

end of thread, other threads:[~2010-04-30 18:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26 15:28 [PATCH] Gracefully handle not being able to access a DWARF register number Matthew Gretton-Dann
2010-04-26 20:06 ` Tom Tromey
2010-04-26 20:21   ` Sergio Durigan Junior
2010-04-27 10:54   ` Matthew Gretton-Dann
2010-04-30 18:08     ` Tom Tromey

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