From a8b1650962b074fb8025399199f50abc65090670 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 21 Dec 2023 08:24:18 -0700 Subject: 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/ada-lang.c') diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 52bae58..a3fd695 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -679,7 +679,7 @@ ada_discrete_type_high_bound (struct type *type) return high.const_val (); else { - gdb_assert (high.kind () == PROP_UNDEFINED); + gdb_assert (!high.is_available ()); /* This happens when trying to evaluate a type's dynamic bound without a live target. There is nothing relevant for us to @@ -714,7 +714,7 @@ ada_discrete_type_low_bound (struct type *type) return low.const_val (); else { - gdb_assert (low.kind () == PROP_UNDEFINED); + gdb_assert (!low.is_available ()); /* This happens when trying to evaluate a type's dynamic bound without a live target. There is nothing relevant for us to -- cgit v1.1