Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [2/2] Don't raise an error for optimized out sub-fields.
@ 2013-07-11 14:35 Andrew Burgess
  2013-07-30 14:53 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2013-07-11 14:35 UTC (permalink / raw)
  To: gdb-patches

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"
 


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

* Re: [PATCH] [2/2] Don't raise an error for optimized out sub-fields.
  2013-07-11 14:35 [PATCH] [2/2] Don't raise an error for optimized out sub-fields Andrew Burgess
@ 2013-07-30 14:53 ` Pedro Alves
  2013-07-30 15:38   ` Andrew Burgess
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2013-07-30 14:53 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

On 07/11/2013 03:35 PM, Andrew Burgess wrote:
> 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>".

Agreed.  For printing, we aim at being graceful, and not throw
errors.  Errors are left for when computing expressions that
would require the contents of a non-optimized out value.  IOW,

 gdb_test "p s.d + 1"

should still throw.  Can you confirm that?  Might as well add it
to the test while at it.

> 
> 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.

Nice, thanks.

> 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>"

OK.

-- 
Pedro Alves


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

* Re: [PATCH] [2/2] Don't raise an error for optimized out sub-fields.
  2013-07-30 14:53 ` Pedro Alves
@ 2013-07-30 15:38   ` Andrew Burgess
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Burgess @ 2013-07-30 15:38 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

On 30/07/2013 3:53 PM, Pedro Alves wrote:
> On 07/11/2013 03:35 PM, Andrew Burgess wrote:
>> 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>".
> 
> Agreed.  For printing, we aim at being graceful, and not throw
> errors.  Errors are left for when computing expressions that
> would require the contents of a non-optimized out value.  IOW,
> 
>  gdb_test "p s.d + 1"
> 
> should still throw.  Can you confirm that?  Might as well add it
> to the test while at it.

Confirmed that we get an error for the example you gave.  I've
included a test of this as part of this commit.

> 
>> 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>"
> 
> OK.

Committed.

Thanks,
Andrew




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

end of thread, other threads:[~2013-07-30 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-11 14:35 [PATCH] [2/2] Don't raise an error for optimized out sub-fields Andrew Burgess
2013-07-30 14:53 ` Pedro Alves
2013-07-30 15:38   ` Andrew Burgess

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