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]

Re: [PATCH] Gracefully handle not being able to access a DWARF register number


On Mon, 2010-04-26 at 14:06 -0600, Tom Tromey wrote:
> >>>>> "Matthew" == Matthew Gretton-Dann <matthew.gretton-dann@arm.com> writes:
> 
> Matthew> The attached patch changes these internal errors into warnings, and
> Matthew> tries to return something sensible to the user.
> 
> Why a warning and not an error?
> 
> It seems to me that an error is preferable to returning incorrect
> information.

Agreed.

> Matthew> Please could someone review and comment on the patch, and then if this
> Matthew> is approved can they please commit it as I don't have commit rights.
> 
> Do you have copyright assignment paperwork in place?

Yes - through my employer (ARM).

> Matthew> +		warning (_("Unable to access DWARF register number %" BFD_VMA_FMT "d"),
> Matthew> +			 p->v.expr.value);
> 
> I think there is some other way to print a CORE_ADDR, but I forget what
> it is.  BFD_VMA_FMT seems suspect, just because it is not used anywhere
> else in gdb.

Okay.

Please find attached an updated patch that addresses the above two
issues.

Proposed ChangeLog:

2010-04-27  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
Index: gdb/dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.74
diff -u -p -u -p -r1.74 dwarf2loc.c
--- gdb/dwarf2loc.c	17 Mar 2010 22:04:43 -0000	1.74
+++ gdb/dwarf2loc.c	27 Apr 2010 09:44:34 -0000
@@ -284,8 +284,16 @@ 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
+	      {
+		error (_("Unable to access DWARF register number %s"),
+		       paddress (arch, p->v.expr.value));
+	      }
 	  }
 	  break;
 
@@ -356,8 +364,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
+	      {
+		error (_("Unable to write to DWARF register number %s"),
+		       paddress (arch, p->v.expr.value));
+	      }
 	  }
 	  break;
 	case DWARF_VALUE_MEMORY:
@@ -454,7 +470,16 @@ 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
+	      {
+		error (_("Unable to access DWARF register number %s"),
+		       paddress (arch, dwarf_regnum));
+	      }
 	  }
 	  break;
 

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