Don't error out when variable not available

Andreas Schwab schwab@suse.de
Mon Jan 3 13:41:00 GMT 2005


How about this?

Andreas.

2005-01-03  Andreas Schwab  <schwab@suse.de>

	* stack.c (print_frame_args): Handle VALUE_OPTIMIZED_OUT.

	* dwarf2loc.c (loclist_read_variable): Return a value with
	VALUE_OPTIMIZED_OUT set instead of erring out when value not
	available.

Index: dwarf2loc.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2loc.c,v
retrieving revision 1.18
diff -u -a -p -r1.18 dwarf2loc.c
--- dwarf2loc.c	9 Nov 2004 14:43:25 -0000	1.18
+++ dwarf2loc.c	3 Jan 2005 13:33:23 -0000
@@ -1,5 +1,5 @@
 /* DWARF 2 location expression support for GDB.
-   Copyright 2003 Free Software Foundation, Inc.
+   Copyright 2003, 2005 Free Software Foundation, Inc.
    Contributed by Daniel Jacobowitz, MontaVista Software, Inc.
 
    This file is part of GDB.
@@ -510,9 +510,14 @@ loclist_read_variable (struct symbol *sy
   data = find_location_expression (dlbaton, &size,
 				   frame ? get_frame_pc (frame) : 0);
   if (data == NULL)
-    error ("Variable \"%s\" is not available.", SYMBOL_NATURAL_NAME (symbol));
-
-  val = dwarf2_evaluate_loc_desc (symbol, frame, data, size, dlbaton->objfile);
+    {
+      val = allocate_value (SYMBOL_TYPE (symbol));
+      VALUE_LVAL (val) = not_lval;
+      VALUE_OPTIMIZED_OUT (val) = 1;
+    }
+  else
+    val = dwarf2_evaluate_loc_desc (symbol, frame, data, size,
+				    dlbaton->objfile);
 
   return val;
 }
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.119
diff -u -a -p -r1.119 stack.c
--- stack.c	12 Nov 2004 21:45:07 -0000	1.119
+++ stack.c	3 Jan 2005 13:33:56 -0000
@@ -1,7 +1,7 @@
 /* Print and select stack frames for GDB, the GNU debugger.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
    Software Foundation, Inc.
 
    This file is part of GDB.
@@ -353,10 +353,15 @@ print_frame_args (struct symbol *func, s
 
 	  if (val)
 	    {
-	      val_print (value_type (val), VALUE_CONTENTS (val), 0,
-			 VALUE_ADDRESS (val),
-			 stb->stream, 0, 0, 2, Val_no_prettyprint);
-	      ui_out_field_stream (uiout, "value", stb);
+	      if (VALUE_OPTIMIZED_OUT (val))
+		ui_out_text (uiout, "<value optimized out>");
+	      else
+		{
+		  val_print (value_type (val), VALUE_CONTENTS (val), 0,
+			     VALUE_ADDRESS (val),
+			     stb->stream, 0, 0, 2, Val_no_prettyprint);
+		  ui_out_field_stream (uiout, "value", stb);
+		}
 	    }
 	  else
 	    ui_out_text (uiout, "???");

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gdb-patches mailing list