828292f271
If we declare a type as being an access to array type, and then declare a variable of that type, for instance: type Some_Array is array [...]; type Array_Access is access all Some_Array; Table : Array_Access := [...]; The variable "Table" may be defined in the debugging information as being a typedef to the array pointer type. In the past, it was defined directly as the array pointer type, but this has been changed to make sure that the typedef type gets used. If the typedef type wasn't used, it would allow the compiler to stop emitting that typedef type when compiling with -feliminate-unused-debug-types. The removal of this typedef would be a problem, because GDB relies on the typedef to create symbols for pointer types, and without it, we would no longer be able to do "ptype array_access". This patch helps prevent incorrect output or even crashes when that extra typedef layer is used. The testing is already mostly covered by arrayptr.exp, but I still added a 'ptype' test, just for good measure. gdb/ChangeLog: (Eric Botcazou) * ada-lang.c (thin_descriptor_type): Deal with typedefs. (decode_constrained_packed_array): Likewise. (ada_evaluate_subexp) <TERNOP_SLICE>: Likewise. gdb/testsuite/ChangeLog (Joel Brobecker): * gdb.ada/arrayptr.exp: Add ptype test.
55 lines
1.7 KiB
Text
55 lines
1.7 KiB
Text
# Copyright 2008, 2009, 2010, 2011 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/>.
|
|
|
|
if $tracelevel then {
|
|
strace $tracelevel
|
|
}
|
|
|
|
load_lib "ada.exp"
|
|
|
|
set testdir "arrayptr"
|
|
set testfile "${testdir}/foo"
|
|
set srcfile ${srcdir}/${subdir}/${testfile}.adb
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
file mkdir ${objdir}/${subdir}/${testdir}
|
|
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
|
|
return -1
|
|
}
|
|
|
|
clean_restart ${testfile}
|
|
|
|
set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
|
|
if ![runto "foo.adb:$bp_location" ] then {
|
|
perror "Couldn't run ${testfile}"
|
|
return
|
|
}
|
|
|
|
gdb_test "print string_p" \
|
|
"= \\(foo\\.string_access\\) 0x\[0-9a-zA-Z\]+" \
|
|
"print string_p"
|
|
|
|
gdb_test "print string_p (3..4)" "= \"ll\""
|
|
|
|
gdb_test "print null_string" "= \\(foo\\.string_access\\) 0x0"
|
|
|
|
gdb_test "print arr_ptr" "= \\(access foo\\.little_array\\) 0x\[0-9a-zA-Z\]+"
|
|
|
|
gdb_test "print arr_ptr (2)" "= 22"
|
|
|
|
gdb_test "print arr_ptr (3..4)" "= \\(3 => 23, 24\\)"
|
|
|
|
gdb_test "ptype string_access" "= access array \\(<>\\) of character"
|
|
|