From: Tom Tromey Date: Wed, 4 Nov 2020 15:49:16 +0000 (-0700) Subject: Avoid crash in ada-lang.c:to_fixed_array_type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75fd6a26f893fbee0ebd665612e115c0735274ab;p=binutils-gdb.git 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 * ada-lang.c (to_fixed_array_type): Error if decode_constrained_packed_array_type returns NULL. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 188bb1e8539..9b905ee091b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-11-04 Tom Tromey + + * ada-lang.c (to_fixed_array_type): Error if + decode_constrained_packed_array_type returns NULL. + 2020-11-04 Tom Tromey * dwarf2/leb.h (read_3_bytes): Use bfd_get_24. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a1f5d93fee3..941b35f6081 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);