]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Handling of arrays with optimized-out bounds
authorTom Tromey <tromey@adacore.com>
Thu, 21 Dec 2023 15:24:18 +0000 (08:24 -0700)
committerTom Tromey <tromey@adacore.com>
Mon, 5 Feb 2024 14:13:37 +0000 (07:13 -0700)
commita8b1650962b074fb8025399199f50abc65090670
tree8044b7d9173494fd688d50e0c2a78f62848dcab1
parentbae2a57f4c07f46093e7bf00fec2554868e77189
Handling of arrays with optimized-out bounds

In Ada, sometimes the compiler must emit array bounds by referencing
an artificial variable that's created for this purpose.  However, with
optimization enabled, these variables can be optimized away.

Currently this can result in displays like:

    (gdb) print mumble
    $1 = (warning: unable to get bounds of array, assuming null array
    )

This patch changes this to report that the array is optimized-out,
instead, which is closer to the truth, and more generally useful.  For
example, Python pretty-printers can now recognize this situation.

In order to accomplish this, I introduced a new PROP_OPTIMIZED_OUT
enumerator and changed one place to use it.  Reusing the "unknown"
state wouldn't work properly, because in C it is normal for array
bounds to be unknown.
gdb/ada-lang.c
gdb/c-varobj.c
gdb/eval.c
gdb/f-lang.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/testsuite/gdb.dwarf2/arr-opt-out.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/arr-opt-out.exp [new file with mode: 0644]
gdb/value.c