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]

[unavailable regs/locals, 05/11] location expressions that hit unavailable registers or memory


This handles the case of when we need to evaluate a dwarf location
expression to get at a (local) variable, but, the expression requires
registers or memory that hasn't been collected to compute correctly.

Some bits of the core accept a NULL value to represent that we
don't know the location of a given expression.  But what
GDB shows in that case to the user didn't appear that much
useful or descriminatory enough.

The patch makes it so that values on the stack, when we don't
know the stack's address at all show as

 (gdb) p foo
 $1 = <unavailable>

That violates a bit what an <unavailable> value is
(it's not the contents that are unavailable, it's that we
don't know where they are!), but I think it's good enough
for now.

-- 
Pedro Alves

2011-02-22  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* dwarf2loc.c (dwarf2_evaluate_loc_desc): Catch
	NOT_AVAILABLE_ERROR when evaluating the location expression.

---
 gdb/dwarf2loc.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Index: src/gdb/dwarf2loc.c
===================================================================
--- src.orig/gdb/dwarf2loc.c	2011-02-01 19:42:28.524645000 +0000
+++ src/gdb/dwarf2loc.c	2011-02-01 20:08:54.984645003 +0000
@@ -1075,6 +1075,7 @@ dwarf2_evaluate_loc_desc_full (struct ty
   struct dwarf_expr_context *ctx;
   struct cleanup *old_chain;
   struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
+  volatile struct gdb_exception ex;
 
   if (byte_offset < 0)
     invalid_synthetic_pointer ();
@@ -1105,7 +1106,22 @@ dwarf2_evaluate_loc_desc_full (struct ty
   ctx->get_tls_address = dwarf_expr_tls_address;
   ctx->dwarf_call = dwarf_expr_dwarf_call;
 
-  dwarf_expr_eval (ctx, data, size);
+  TRY_CATCH (ex, RETURN_MASK_ERROR)
+    {
+      dwarf_expr_eval (ctx, data, size);
+    }
+  if (ex.reason < 0)
+    {
+      if (ex.error == NOT_AVAILABLE_ERROR)
+	{
+	  retval = allocate_value (type);
+	  mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
+	  return retval;
+	}
+      else
+	throw_exception (ex);
+    }
+
   if (ctx->num_pieces > 0)
     {
       struct piece_closure *c;


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