diff options
author | Tom Tromey <tromey@adacore.com> | 2020-12-14 07:42:23 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-12-14 07:42:23 -0700 |
commit | e26624c669037529816f89ce1b9c78954c389ca1 (patch) | |
tree | e2b683793e2f22b56ce2dac69d4f67eccc21a848 /gdb/testsuite | |
parent | a3bdae4ef826f2b59cc475e530b2a4130185cfac (diff) | |
download | gdb-e26624c669037529816f89ce1b9c78954c389ca1.zip gdb-e26624c669037529816f89ce1b9c78954c389ca1.tar.gz gdb-e26624c669037529816f89ce1b9c78954c389ca1.tar.bz2 |
Be more careful when rewriting thick pointer array type
To handle thick pointers with -fgnat-encodings=minimal, gdb will
rewrite the underlying array type to remove the bounds. However, if
the same DWARF type is used both for a thick pointer and for an
ordinary array, this will have the side effect of removing the bounds
from the array. This breaks the printing of objects of this type.
This patch fixes the problem by copying the array type, its range, and
its bounds.
gdb/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (rewrite_array_type): New function.
(quirk_ada_thick_pointer_struct): Use rewrite_array_type.
gdb/testsuite/ChangeLog
2020-12-14 Tom Tromey <tromey@adacore.com>
* gdb.dwarf2/ada-thick-pointer.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp | 95 |
2 files changed, 99 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index dba9292..f0d452b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2020-12-14 Tom Tromey <tromey@adacore.com> + * gdb.dwarf2/ada-thick-pointer.exp: New file. + +2020-12-14 Tom Tromey <tromey@adacore.com> + * gdb.dwarf2/dw2-fixed-point.exp: Add test for division by zero. 2020-12-13 Tom de Vries <tdevries@suse.de> diff --git a/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp b/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp new file mode 100644 index 0000000..7077b4c --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp @@ -0,0 +1,95 @@ +# Copyright 2020 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test that handling of Ada thick pointers does not rewrite other +# similar types. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +standard_testfile main.c -debug.S + +# Set up the DWARF for the test. + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcdir subdir srcfile + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_Ada95} + {DW_AT_name $srcfile} + } { + declare_labels integer array array_pointer bounds_pointer + + integer: DW_TAG_base_type { + {DW_AT_byte_size 8 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name integer} + } + + array: DW_TAG_array_type { + {DW_AT_name array_type} + {DW_AT_type :$integer} + } { + DW_TAG_subrange_type { + {DW_AT_type :$integer} + {DW_AT_lower_bound 1 DW_FORM_data1} + {DW_AT_upper_bound 7 DW_FORM_data1} + } + } + + array_pointer: DW_TAG_pointer_type { + {DW_AT_type :$array} + {DW_AT_byte_size 8 DW_FORM_sdata} + } + + # This isn't exactly what GNAT emits, but it doesn't + # matter. + bounds_pointer: DW_TAG_pointer_type { + {DW_AT_type :$integer} + {DW_AT_byte_size 8 DW_FORM_sdata} + } + + DW_TAG_structure_type { + {DW_AT_name thick_pointer_type} + {DW_AT_byte_size 8 DW_FORM_sdata} + } { + DW_TAG_member { + {DW_AT_name P_ARRAY} + {DW_AT_type :$array_pointer} + {DW_AT_data_member_location 0 DW_FORM_sdata} + } + DW_TAG_member { + {DW_AT_name P_BOUNDS} + {DW_AT_type :$bounds_pointer} + {DW_AT_data_member_location 8 DW_FORM_sdata} + } + } + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +gdb_test_no_output "set language ada" +gdb_test "ptype array_type" "type = array \\(1 \\.\\. 7\\) of integer" |