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] [2/2] Don't raise an error for optimized out sub-fields.


When performing a lazy fetch of a sub-bitfield, we raise an error
if the bits have been optimized-out from the parent value.  This
is odd, as in most other cases we report the value as "<optimized out>".

This patch marks the result of the lazy fetch as optimized out,
and then returns rather than raising an error.  No regressions,
and the one test I see that hits this now seems more consistent.

OK to apply?

Thanks,
Andrew



gdb/ChangeLog

2013-07-11  Andrew Burgess  <aburgess@broadcom.com>

	* value.c (value_fetch_lazy): Mark optimized out values as such
	rather than raising an error.

gdb/testsuite/ChangeLog

2013-07-11  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.dwarf2/pieces-optimized-out.exp: Expect "<optimized out>"
	rather than an error.

diff --git a/gdb/value.c b/gdb/value.c
index 8e0f8c4..8d635c7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3439,9 +3439,8 @@ value_fetch_lazy (struct value *val)
       if (!value_bits_valid (parent,
 			     TARGET_CHAR_BIT * offset + value_bitpos (val),
 			     value_bitsize (val)))
-	error (_("value has been optimized out"));
-
-      if (!unpack_value_bits_as_long (value_type (val),
+	set_value_optimized_out (val, 1);
+      else if (!unpack_value_bits_as_long (value_type (val),
 				      value_contents_for_printing (parent),
 				      offset,
 				      value_bitpos (val),
diff --git a/gdb/testsuite/gdb.dwarf2/pieces-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/pieces-optimized-out.exp
index 2e4d028..8376235 100644
--- a/gdb/testsuite/gdb.dwarf2/pieces-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/pieces-optimized-out.exp
@@ -44,6 +44,6 @@ gdb_test "p s" \
     "print s"
 gdb_test "p s.a" " = 5" "print s.a"
 gdb_test "p s.b" " = <optimized out>" "print s.b"
-gdb_test "p s.c" "value has been optimized out" "print s.c"
-gdb_test "p s.d" "value has been optimized out" "print s.d"
+gdb_test "p s.c" " = <optimized out>" "print s.c"
+gdb_test "p s.d" " = <optimized out>" "print s.d"
 


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