aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-11-04 08:49:16 -0700
committerTom Tromey <tromey@adacore.com>2020-11-04 08:49:16 -0700
commit75fd6a26f893fbee0ebd665612e115c0735274ab (patch)
tree0b13eb7086bf9ab771fe01db0574601e131de5ee /gdb/ada-lang.c
parent93f9561e0fa112bab102dc2c22dd114c84c06a16 (diff)
downloadgdb-75fd6a26f893fbee0ebd665612e115c0735274ab.zip
gdb-75fd6a26f893fbee0ebd665612e115c0735274ab.tar.gz
gdb-75fd6a26f893fbee0ebd665612e115c0735274ab.tar.bz2
Avoid crash in ada-lang.c:to_fixed_array_type
When debugging Ada programs compiled by certain versions of GNAT with -fgnat-encodings=minimal, gdb can crash. These crashes occur when running the gdb test suite, once some of the later patches in this series have been applied. This patch works around the bug by throwing an exception in the failing case. I did not implement a full fix because GNAT has been changed to emit better DWARF, and so in the near future this will stop being a problem. (Currently, users don't generally use -fgnat-encodings=minimal, and the GNAT default will only be changed in a fully-patched compiler.) gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (to_fixed_array_type): Error if decode_constrained_packed_array_type returns NULL.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a1f5d93..941b35f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8350,7 +8350,11 @@ to_fixed_array_type (struct type *type0, struct value *dval,
constrained_packed_array_p = ada_is_constrained_packed_array_type (type0);
if (constrained_packed_array_p)
- type0 = decode_constrained_packed_array_type (type0);
+ {
+ type0 = decode_constrained_packed_array_type (type0);
+ if (type0 == nullptr)
+ error (_("could not decode constrained packed array type"));
+ }
index_type_desc = ada_find_parallel_type (type0, xa_suffix);