Do not print <synthetic pointer> when piece is optimized out
authorTom Tromey <tom@tromey.com>
Thu, 20 Apr 2023 21:47:41 +0000 (15:47 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 11 May 2023 21:47:37 +0000 (15:47 -0600)
commit245f9db1fa8a355e9b18d0966fe20d6341e36813
treecd6ba023a81f8f75b29a180699a2ca47f8794592
parentb7ea736a38013510cd0496b42a8eb2dd2d2f6830
Do not print <synthetic pointer> when piece is optimized out

A user reported a bug where printing a certain array of integer types
would result in the nonsensical:

(gdb) p l_126
$1 = {6639779683436459270, <synthetic pointer>, <synthetic pointer>, <synthetic pointer>}

I tracked this down to some issues in the DWARF expression code.
First, check_pieced_synthetic_pointer did not account for the
situation where a location expression does not describe all the bits
of a value -- in this case it returned true, meaning there is a
synthetic pointer, but in fact these bits are optimized out.  (It
turns out this incorrect output had already been erroneously tested
for as well.)

Next, rw_pieced_value did not mark these bits as optimized-out,
either.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30296
gdb/dwarf2/expr.c
gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/shortpiece.exp