binutils-gdb/gdb/testsuite/gdb.ada/var_arr_typedef.exp

45 lines
1.3 KiB
Plaintext
Raw Normal View History

# Copyright 2015-2017 Free Software Foundation, Inc.
gdb/gdbtypes: fix handling of typedef layers between array types When a dynamic array type contains a typedef-wrapped array, an assertion failure occurs during type resolution. This is what happens in the following Ada case: type Rec_Type is record I : Integer; B : Boolean; end record; type Vec_Type is array (1 .. 4) of Rec_Type; type Array_Type is array (Positive range <>) of Vec_Type; If users try to print or even pass to an inferior call a variable A of type Array_Type, GDB will raise an error: (gdb) print a ../../src/gdb/gdbtypes.c:1807: internal-error: resolve_dynamic_array: Assertion `TYPE_CODE (type) == TYPE_CODE_ARRAY' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) What happens is that during dynamic array type resolution, we first peel TYPE_CODE_TYPEDEF layers wrapping the array element type and check if its type is itself TYPE_CODE_ARRAY. If it is, we pass the typedef-wrapped type to a recursive call to resolve_dynamic_array whereas this function expects only TYPE_CODE_ARRAY types. This patch makes it pass the peeled type to the recursive call so that type resolution can continue smoothly. gdb/ChangeLog: * gdbtypes.c (resolve_dynamic_array): Pass the peeled element type to the recursive call instead of the original (maybe TYPE_CODE_TYPEDEF) type. gdb/testsuite/ChangeLog: * gdb.ada/var_arr_typedef.exp: New testcase. * gdb.ada/var_arr_typedef/pack.adb: New file. * gdb.ada/var_arr_typedef/pack.ads: New file. * gdb.ada/var_arr_typedef/var_arr_typedef.adb: New file.
2015-07-22 12:25:14 +02:00
#
# 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/>.
load_lib "ada.exp"
standard_ada_testfile var_arr_typedef
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
return -1
}
clean_restart ${testfile}
set bp_location [gdb_get_line_number "BREAK" ${testdir}/var_arr_typedef.adb]
runto "var_arr_typedef.adb:$bp_location"
set ra "\\(i => 3, b => false\\)"
set rb "\\(i => 2, b => true\\)"
set va "\\($ra, $ra, $rb, $rb\\)"
set vb "\\($rb, $rb, $ra, $ra\\)"
set a "\\($va, $va, $vb, $vb\\)"
gdb_test "print va" \
" = $va"
gdb_test "print vb" \
" = $vb"
gdb_test "print a" \
" = $a"