aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Harmstone <mark@harmstone.com>2025-08-29 20:43:57 +0100
committerMark Harmstone <mark@harmstone.com>2025-09-01 21:58:44 +0100
commit3b3f336af29c6f25b7ded05ae037b5ab57b2ae67 (patch)
treefb5c376db1fb9a4e4b70b4d946adedeac2ad3213 /gcc
parent70954659527858fc9ffa2655b0dd5265c2453be8 (diff)
downloadgcc-3b3f336af29c6f25b7ded05ae037b5ab57b2ae67.zip
gcc-3b3f336af29c6f25b7ded05ae037b5ab57b2ae67.tar.gz
gcc-3b3f336af29c6f25b7ded05ae037b5ab57b2ae67.tar.bz2
Fix assertion when trying to represent Ada arrays in CodeView
The LF_ARRAY CodeView type represents a C- or C++-style array, which a length known at compile time. We were crashing when using -gcodeview with Ada (bug #121157), as the DW_AT_upper_bound value is not an unsigned integer but something more complicated: 0x00000123: DW_TAG_array_type DW_AT_type (0x0000014d "character") DW_AT_sibling (0x00000142) 0x0000012c: DW_TAG_subrange_type DW_AT_type (0x00000142 "integer") DW_AT_lower_bound (DW_OP_push_object_address, DW_OP_plus_uconst 0x8, DW_OP_deref, DW_OP_deref_size 0x4) DW_AT_upper_bound (DW_OP_push_object_address, DW_OP_plus_uconst 0x8, DW_OP_deref, DW_OP_plus_uconst 0x4, DW_OP_deref_size 0x4) It doesn't look like we can represent Ada arrays in CodeView, so return 0 in get_type_num_array_type so that they come through as an unknown type. gcc/ * dwarf2codeview.cc (get_type_num_array_type): Don't try to encode non-C-style arrays.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/dwarf2codeview.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index d98b50c..154cd94 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -6748,10 +6748,23 @@ get_type_num_array_type (dw_die_ref type, bool in_struct)
c = first_child;
do
{
+ dw_attr_node *upper_bound;
+
c = dw_get_die_sib (c);
if (dw_get_die_tag (c) != DW_TAG_subrange_type)
continue;
+ /* Check that each DW_TAG_subrange_type DIE has a DW_AT_upper_bound
+ attribute that's an unsigned integer. This is the case for C and
+ C++, but not for other languages such as Ada. */
+ upper_bound = get_AT (c, DW_AT_upper_bound);
+ if (!upper_bound)
+ return 0;
+
+ if (AT_class (upper_bound) != dw_val_class_unsigned_const
+ && AT_class (upper_bound) != dw_val_class_unsigned_const_implicit)
+ return 0;
+
dimensions++;
}
while (c != first_child);