+2020-05-14 Tom de Vries <tdevries@suse.de>
+
+ * gdb.base/align.exp: Split into ...
+ * gdb.base/align.exp.in: ...
+ * gdb.base/align-c++.exp: ...
+ * gdb.base/align-c.exp: ... these.
+ * gdb.base/infcall-nested-structs.exp: Split into ...
+ * gdb.base/infcall-nested-structs.exp.in: ...
+ * gdb.base/infcall-nested-structs-c++.exp: ...
+ * gdb.base/infcall-nested-structs-c.exp: ... these.
+ * gdb.base/info-types.exp: Split into ...
+ * gdb.base/info-types.exp.in: ...
+ * gdb.base/info-types-c++.exp: ...
+ * gdb.base/info-types-c.exp: ... these.
+ * gdb.base/max-depth.exp: Split into ...
+ * gdb.base/max-depth.exp.in: ...
+ * gdb.base/max-depth-c++.exp: ...
+ * gdb.base/max-depth-c.exp: ... these.
+ * gdb.cp/infcall-nodebug.exp: Split into ...
+ * gdb.cp/infcall-nodebug.exp.in: ...
+ * gdb.cp/infcall-nodebug-c++-d0.exp: ...
+ * gdb.cp/infcall-nodebug-c++-d1.exp: ...
+ * gdb.cp/infcall-nodebug-c-d0.exp: ...
+ * gdb.cp/infcall-nodebug-c-d1.exp: ... these.
+
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Pedro Alves <palves@redhat.com>
--- /dev/null
+# Copyright 2018-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/>.
+
+# This file is part of the gdb testsuite
+
+# This tests that C++11 alignof works in gdb, and that it agrees with the
+# compiler.
+
+# Only test C++ if we are able.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang c++
+
+source $srcdir/$subdir/align.exp.in
--- /dev/null
+# Copyright 2018-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/>.
+
+# This file is part of the gdb testsuite
+
+# This tests that C11 _Alignof works in gdb, and that it agrees with the
+# compiler.
+
+set lang c
+
+source $srcdir/$subdir/align.exp.in
+++ /dev/null
-# Copyright 2018-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/>.
-
-# This file is part of the gdb testsuite
-
-# This tests that C11 _Alignof and C++11 alignof works in gdb, and
-# that it agrees with the compiler.
-
-# Only test C++ if we are able. Always use C.
-if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
- set lang {c}
-} else {
- set lang {c c++}
-}
-
-# The types we're going to test.
-
-set typelist {
- char {unsigned char}
- short {unsigned short}
- int {unsigned int}
- long {unsigned long}
- {long long} {unsigned long long}
- float
- double {long double}
-}
-
-if {[has_int128_c]} {
- # Note we don't check "unsigned __int128" yet because at least gcc
- # canonicalizes the name to "__int128 unsigned", and there isn't a
- # c-exp.y production for this.
- # https://sourceware.org/bugzilla/show_bug.cgi?id=20991
- lappend typelist __int128
-}
-
-# Build source file for testing alignment handling of language LANG.
-# Returns the name of the newly created source file.
-proc prepare_test_source_file { lang } {
- global typelist
-
- # Create the test file.
-
- if { $lang == "c++" } {
- set suffix "cpp"
- set align_func "alignof"
- } else {
- set suffix "c"
- set align_func "_Alignof"
- }
-
- set filename [standard_output_file "$lang/align.$suffix"]
- set outfile [open $filename w]
-
- # Prologue.
- puts -nonewline $outfile "#define DEF(T,U) struct align_pair_ ## T ## _x_ ## U "
- puts $outfile "{ T one; U two; }"
- if { $lang == "c++" } {
- puts -nonewline $outfile "#define DEF_WITH_1_STATIC(T,U) struct align_pair_static_ ## T ## _x_ ## U "
- puts $outfile "{ static T one; U two; }"
- puts -nonewline $outfile "#define DEF_WITH_2_STATIC(T,U) struct align_pair_static_ ## T ## _x_static_ ## U "
- puts $outfile "{ static T one; static U two; }"
- }
- if { $lang == "c" } {
- puts $outfile "unsigned a_void = ${align_func} (void);"
- }
-
- # First emit single items.
- foreach type $typelist {
- set utype [join [split $type] _]
- if {$type != $utype} {
- puts $outfile "typedef $type $utype;"
- }
- puts $outfile "$type item_$utype;"
- if { $lang == "c" } {
- puts $outfile "unsigned a_$utype\n = ${align_func} ($type);"
- }
- set utype [join [split $type] _]
- }
-
- # Now emit all pairs.
- foreach type $typelist {
- set utype [join [split $type] _]
- foreach inner $typelist {
- set uinner [join [split $inner] _]
- puts $outfile "DEF ($utype, $uinner);"
- set joined "${utype}_x_${uinner}"
- puts $outfile "struct align_pair_$joined item_${joined};"
- puts $outfile "unsigned a_${joined}"
- puts $outfile " = ${align_func} (struct align_pair_${joined});"
-
- if { $lang == "c++" } {
- puts $outfile "DEF_WITH_1_STATIC ($utype, $uinner);"
- set joined "static_${utype}_x_${uinner}"
- puts $outfile "struct align_pair_$joined item_${joined};"
- puts $outfile "unsigned a_${joined}"
- puts $outfile " = ${align_func} (struct align_pair_${joined});"
-
- puts $outfile "DEF_WITH_2_STATIC ($utype, $uinner);"
- set joined "static_${utype}_x_static_${uinner}"
- puts $outfile "struct align_pair_$joined item_${joined};"
- puts $outfile "unsigned a_${joined}"
- puts $outfile " = ${align_func} (struct align_pair_${joined});"
- }
- }
- }
-
- # Epilogue.
- puts $outfile {
- int main() {
- return 0;
- }
- }
-
- close $outfile
-
- return $filename
-}
-
-# Run the alignment test for the language LANG.
-proc run_alignment_test { lang } {
- global testfile srcfile typelist
- global subdir
-
- set filename [prepare_test_source_file $lang]
-
- set flags {debug}
- if { "$lang" == "c++" } {
- lappend flags "additional_flags=-std=c++11"
- }
- standard_testfile $filename
- if {[prepare_for_testing "failed to prepare" "$lang/$testfile" $srcfile $flags]} {
- return -1
- }
-
- if {![runto_main]} {
- perror "test suppressed"
- return
- }
-
- if { $lang == "c++" } {
- set align_func "alignof"
- } else {
- set align_func "_Alignof"
- }
-
- foreach type $typelist {
- set utype [join [split $type] _]
- if { $lang == "c" } {
- set expected [get_integer_valueof a_$utype 0]
- gdb_test "print ${align_func}($type)" " = $expected"
- }
-
- foreach inner $typelist {
- set uinner [join [split $inner] _]
- set expected [get_integer_valueof a_${utype}_x_${uinner} 0]
- gdb_test "print ${align_func}(struct align_pair_${utype}_x_${uinner})" \
- " = $expected"
-
- if { $lang == "c++" } {
- set expected [get_integer_valueof a_static_${utype}_x_${uinner} 0]
- gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_${uinner})" \
- " = $expected"
-
- set expected [get_integer_valueof a_static_${utype}_x_static_${uinner} 0]
- gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_static_${uinner})" \
- " = $expected"
- }
- }
- }
-
- if { $lang == "c" } {
- set expected [get_integer_valueof a_void 0]
- gdb_test "print ${align_func}(void)" " = $expected"
- }
-}
-
-# Create nested 'c' and 'c++' directories within this tests directory.
-foreach l $lang {
- set dir "$l"
- remote_exec host "rm -rf [standard_output_file ${dir}]"
- remote_exec host "mkdir -p [standard_output_file ${dir}]"
-}
-
-# Now run the test for each language.
-foreach_with_prefix l $lang {
- run_alignment_test $l
-}
--- /dev/null
+# Copyright 2018-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/>.
+
+# This file is part of the gdb testsuite
+
+# The types we're going to test.
+
+set typelist {
+ char {unsigned char}
+ short {unsigned short}
+ int {unsigned int}
+ long {unsigned long}
+ {long long} {unsigned long long}
+ float
+ double {long double}
+}
+
+if {[has_int128_c]} {
+ # Note we don't check "unsigned __int128" yet because at least gcc
+ # canonicalizes the name to "__int128 unsigned", and there isn't a
+ # c-exp.y production for this.
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=20991
+ lappend typelist __int128
+}
+
+# Build source file for testing alignment handling of language LANG.
+# Returns the name of the newly created source file.
+proc prepare_test_source_file { lang } {
+ global typelist
+
+ # Create the test file.
+
+ if { $lang == "c++" } {
+ set suffix "cpp"
+ set align_func "alignof"
+ } else {
+ set suffix "c"
+ set align_func "_Alignof"
+ }
+
+ set filename [standard_output_file "align.$suffix"]
+ set outfile [open $filename w]
+
+ # Prologue.
+ puts -nonewline $outfile "#define DEF(T,U) struct align_pair_ ## T ## _x_ ## U "
+ puts $outfile "{ T one; U two; }"
+ if { $lang == "c++" } {
+ puts -nonewline $outfile "#define DEF_WITH_1_STATIC(T,U) struct align_pair_static_ ## T ## _x_ ## U "
+ puts $outfile "{ static T one; U two; }"
+ puts -nonewline $outfile "#define DEF_WITH_2_STATIC(T,U) struct align_pair_static_ ## T ## _x_static_ ## U "
+ puts $outfile "{ static T one; static U two; }"
+ }
+ if { $lang == "c" } {
+ puts $outfile "unsigned a_void = ${align_func} (void);"
+ }
+
+ # First emit single items.
+ foreach type $typelist {
+ set utype [join [split $type] _]
+ if {$type != $utype} {
+ puts $outfile "typedef $type $utype;"
+ }
+ puts $outfile "$type item_$utype;"
+ if { $lang == "c" } {
+ puts $outfile "unsigned a_$utype\n = ${align_func} ($type);"
+ }
+ set utype [join [split $type] _]
+ }
+
+ # Now emit all pairs.
+ foreach type $typelist {
+ set utype [join [split $type] _]
+ foreach inner $typelist {
+ set uinner [join [split $inner] _]
+ puts $outfile "DEF ($utype, $uinner);"
+ set joined "${utype}_x_${uinner}"
+ puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "unsigned a_${joined}"
+ puts $outfile " = ${align_func} (struct align_pair_${joined});"
+
+ if { $lang == "c++" } {
+ puts $outfile "DEF_WITH_1_STATIC ($utype, $uinner);"
+ set joined "static_${utype}_x_${uinner}"
+ puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "unsigned a_${joined}"
+ puts $outfile " = ${align_func} (struct align_pair_${joined});"
+
+ puts $outfile "DEF_WITH_2_STATIC ($utype, $uinner);"
+ set joined "static_${utype}_x_static_${uinner}"
+ puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "unsigned a_${joined}"
+ puts $outfile " = ${align_func} (struct align_pair_${joined});"
+ }
+ }
+ }
+
+ # Epilogue.
+ puts $outfile {
+ int main() {
+ return 0;
+ }
+ }
+
+ close $outfile
+
+ return $filename
+}
+
+# Run the alignment test for the language LANG.
+proc run_alignment_test { lang } {
+ global testfile srcfile typelist
+ global subdir
+
+ set filename [prepare_test_source_file $lang]
+
+ set flags {debug}
+ if { "$lang" == "c++" } {
+ lappend flags "additional_flags=-std=c++11"
+ }
+ standard_testfile $filename
+ if {[prepare_for_testing "failed to prepare" "$testfile" $srcfile $flags]} {
+ return -1
+ }
+
+ if {![runto_main]} {
+ perror "test suppressed"
+ return
+ }
+
+ if { $lang == "c++" } {
+ set align_func "alignof"
+ } else {
+ set align_func "_Alignof"
+ }
+
+ foreach type $typelist {
+ set utype [join [split $type] _]
+ if { $lang == "c" } {
+ set expected [get_integer_valueof a_$utype 0]
+ gdb_test "print ${align_func}($type)" " = $expected"
+ }
+
+ foreach inner $typelist {
+ set uinner [join [split $inner] _]
+ set expected [get_integer_valueof a_${utype}_x_${uinner} 0]
+ gdb_test "print ${align_func}(struct align_pair_${utype}_x_${uinner})" \
+ " = $expected"
+
+ if { $lang == "c++" } {
+ set expected [get_integer_valueof a_static_${utype}_x_${uinner} 0]
+ gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_${uinner})" \
+ " = $expected"
+
+ set expected [get_integer_valueof a_static_${utype}_x_static_${uinner} 0]
+ gdb_test "print ${align_func}(struct align_pair_static_${utype}_x_static_${uinner})" \
+ " = $expected"
+ }
+ }
+ }
+
+ if { $lang == "c" } {
+ set expected [get_integer_valueof a_void 0]
+ gdb_test "print ${align_func}(void)" " = $expected"
+ }
+}
+
+run_alignment_test $lang
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2018-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/>.
+
+# Only test C++ if we are able.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang c++
+
+source $srcdir/$subdir/infcall-nested-structs.exp.in
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2018-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/>.
+
+set lang {c}
+
+source $srcdir/$subdir/infcall-nested-structs.exp.in
+++ /dev/null
-# This testcase is part of GDB, the GNU debugger.
-
-# Copyright 2018-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/>.
-
-
-# Some targets can't call functions, so don't even bother with this
-# test.
-
-if [target_info exists gdb,cannot_call_functions] {
- unsupported "this target can not call functions"
- continue
-}
-
-# Only test C++ if we are able. Always use C.
-if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
- set lang {c}
-} else {
- set lang {c c++}
-}
-
-foreach l $lang {
- set dir "$l"
- remote_exec host "rm -rf [standard_output_file ${dir}]"
- remote_exec host "mkdir -p [standard_output_file ${dir}]"
-}
-
-
-set int_types { tc ts ti tl tll }
-set float_types { tf td tld }
-set complex_types { tfc tdc tldc }
-
-set compile_flags {debug}
-if [support_complex_tests] {
- lappend compile_flags "additional_flags=-DTEST_COMPLEX"
- lappend compile_flags "additional_flags=-Wno-psabi"
-}
-
-# Given N (0..25), return the corresponding alphabetic letter in upper
-# case.
-
-proc I2A { n } {
- return [string range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" $n $n]
-}
-
-# Compile a variant of nested-structs.c using TYPES to specify the
-# types of the struct fields within the source. Run up to main.
-# Also updates the global "testfile" to reflect the most recent build.
-
-proc start_nested_structs_test { lang types } {
- global testfile
- global srcfile
- global binfile
- global subdir
- global srcdir
- global compile_flags
-
- standard_testfile .c
- set dir "$lang"
-
- # Create the additional flags
- set flags $compile_flags
- lappend flags $lang
- lappend flags "additional_flags=-O2"
-
- for {set n 0} {$n<[llength ${types}]} {incr n} {
- set m [I2A ${n}]
- set t [lindex ${types} $n]
- lappend flags "additional_flags=-Dt${m}=${t}"
- append testfile "-" "$t"
- }
-
- set binfile [standard_output_file ${dir}/${testfile}]
- if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
- unresolved "failed to compile"
- return 0
- }
-
- # Start with a fresh gdb.
- clean_restart ${binfile}
-
- # Make certain that the output is consistent
- gdb_test_no_output "set print sevenbit-strings"
- gdb_test_no_output "set print address off"
- gdb_test_no_output "set print pretty off"
- gdb_test_no_output "set width 0"
- gdb_test_no_output "set print elements 300"
-
- # Advance to main
- if { ![runto_main] } then {
- fail "can't run to main"
- return 0
- }
-
- # Now continue forward to a suitable location to run the tests.
- # Some targets only enable the FPU on first use, so ensure that we
- # have used the FPU before we make calls from GDB to code that
- # could use the FPU.
- gdb_breakpoint [gdb_get_line_number "Break Here"] temporary
- gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*"
-
- return 1
-}
-
-# Assuming GDB is stopped at main within a test binary, run some tests
-# passing structures, and reading return value structures.
-
-proc run_tests { lang types } {
- global gdb_prompt
-
- foreach {name} {struct_01_01 struct_01_02 struct_01_03 struct_01_04
- struct_02_01 struct_02_02 struct_02_03 struct_02_04
- struct_04_01 struct_04_02 struct_04_03 struct_04_04
- struct_05_01 struct_05_02 struct_05_03 struct_05_04
- struct_static_02_01 struct_static_02_02 struct_static_02_03 struct_static_02_04
- struct_static_04_01 struct_static_04_02 struct_static_04_03 struct_static_04_04
- struct_static_06_01 struct_static_06_02 struct_static_06_03 struct_static_06_04} {
-
- # Only run static member tests on C++
- if { $lang == "c" && [regexp "static" $name match] } {
- continue
- }
-
- gdb_test "p/d check_arg_${name} (ref_val_${name})" "= 1"
-
- set refval [ get_valueof "" "ref_val_${name}" "" ]
- verbose -log "Refval: ${refval}"
-
- set test "check return value ${name}"
- if { ${refval} != "" } {
-
- set answer [ get_valueof "" "rtn_str_${name} ()" "XXXX"]
- verbose -log "Answer: ${answer}"
-
- gdb_assert [string eq ${answer} ${refval}] ${test}
- } else {
- unresolved $test
- }
- }
-}
-
-# Set up a test prefix, compile the test binary, run to main, and then
-# run some tests.
-
-proc start_gdb_and_run_tests { lang types } {
- set prefix "types"
-
- foreach t $types {
- append prefix "-" "${t}"
- }
-
- foreach_with_prefix l $lang {
- with_test_prefix $prefix {
- if { [start_nested_structs_test $l $types] } {
- run_tests $l $prefix
- }
- }
- }
-}
-
-foreach ta $int_types {
- start_gdb_and_run_tests $lang $ta
-}
-
-if [support_complex_tests] {
- foreach ta $complex_types {
- start_gdb_and_run_tests $lang $ta
- }
-}
-
-if ![gdb_skip_float_test] {
- foreach ta $float_types {
- start_gdb_and_run_tests $lang $ta
- }
-
- foreach ta $int_types {
- foreach tb $float_types {
- start_gdb_and_run_tests $lang [list $ta $tb]
- }
- }
-
- foreach ta $float_types {
- foreach tb $int_types {
- start_gdb_and_run_tests $lang [list $ta $tb]
- }
-
- foreach tb $float_types {
- start_gdb_and_run_tests $lang [list $ta $tb]
- }
- }
-}
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2018-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/>.
+
+# Some targets can't call functions, so don't even bother with this
+# test.
+
+if [target_info exists gdb,cannot_call_functions] {
+ unsupported "this target can not call functions"
+ continue
+}
+
+set int_types { tc ts ti tl tll }
+set float_types { tf td tld }
+set complex_types { tfc tdc tldc }
+
+set compile_flags {debug}
+if [support_complex_tests] {
+ lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+ lappend compile_flags "additional_flags=-Wno-psabi"
+}
+
+# Given N (0..25), return the corresponding alphabetic letter in upper
+# case.
+
+proc I2A { n } {
+ return [string range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" $n $n]
+}
+
+# Compile a variant of nested-structs.c using TYPES to specify the
+# types of the struct fields within the source. Run up to main.
+# Also updates the global "testfile" to reflect the most recent build.
+
+proc start_nested_structs_test { lang types } {
+ global testfile
+ global srcfile
+ global binfile
+ global subdir
+ global srcdir
+ global compile_flags
+
+ standard_testfile infcall-nested-structs.c
+
+ # Create the additional flags
+ set flags $compile_flags
+ lappend flags $lang
+ lappend flags "additional_flags=-O2"
+
+ for {set n 0} {$n<[llength ${types}]} {incr n} {
+ set m [I2A ${n}]
+ set t [lindex ${types} $n]
+ lappend flags "additional_flags=-Dt${m}=${t}"
+ append testfile "-" "$t"
+ }
+
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
+ unresolved "failed to compile"
+ return 0
+ }
+
+ # Start with a fresh gdb.
+ clean_restart ${binfile}
+
+ # Make certain that the output is consistent
+ gdb_test_no_output "set print sevenbit-strings"
+ gdb_test_no_output "set print address off"
+ gdb_test_no_output "set print pretty off"
+ gdb_test_no_output "set width 0"
+ gdb_test_no_output "set print elements 300"
+
+ # Advance to main
+ if { ![runto_main] } then {
+ fail "can't run to main"
+ return 0
+ }
+
+ # Now continue forward to a suitable location to run the tests.
+ # Some targets only enable the FPU on first use, so ensure that we
+ # have used the FPU before we make calls from GDB to code that
+ # could use the FPU.
+ gdb_breakpoint [gdb_get_line_number "Break Here"] temporary
+ gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*"
+
+ return 1
+}
+
+# Assuming GDB is stopped at main within a test binary, run some tests
+# passing structures, and reading return value structures.
+
+proc run_tests { lang types } {
+ global gdb_prompt
+
+ foreach {name} {struct_01_01 struct_01_02 struct_01_03 struct_01_04
+ struct_02_01 struct_02_02 struct_02_03 struct_02_04
+ struct_04_01 struct_04_02 struct_04_03 struct_04_04
+ struct_05_01 struct_05_02 struct_05_03 struct_05_04
+ struct_static_02_01 struct_static_02_02 struct_static_02_03 struct_static_02_04
+ struct_static_04_01 struct_static_04_02 struct_static_04_03 struct_static_04_04
+ struct_static_06_01 struct_static_06_02 struct_static_06_03 struct_static_06_04} {
+
+ # Only run static member tests on C++
+ if { $lang == "c" && [regexp "static" $name match] } {
+ continue
+ }
+
+ gdb_test "p/d check_arg_${name} (ref_val_${name})" "= 1"
+
+ set refval [ get_valueof "" "ref_val_${name}" "" ]
+ verbose -log "Refval: ${refval}"
+
+ set test "check return value ${name}"
+ if { ${refval} != "" } {
+
+ set answer [ get_valueof "" "rtn_str_${name} ()" "XXXX"]
+ verbose -log "Answer: ${answer}"
+
+ gdb_assert [string eq ${answer} ${refval}] ${test}
+ } else {
+ unresolved $test
+ }
+ }
+}
+
+# Set up a test prefix, compile the test binary, run to main, and then
+# run some tests.
+
+proc start_gdb_and_run_tests { lang types } {
+ set prefix "types"
+
+ foreach t $types {
+ append prefix "-" "${t}"
+ }
+
+ with_test_prefix $prefix {
+ if { [start_nested_structs_test $lang $types] } {
+ run_tests $lang $prefix
+ }
+ }
+}
+
+foreach ta $int_types {
+ start_gdb_and_run_tests $lang $ta
+}
+
+if [support_complex_tests] {
+ foreach ta $complex_types {
+ start_gdb_and_run_tests $lang $ta
+ }
+}
+
+if ![gdb_skip_float_test] {
+ foreach ta $float_types {
+ start_gdb_and_run_tests $lang $ta
+ }
+
+ foreach ta $int_types {
+ foreach tb $float_types {
+ start_gdb_and_run_tests $lang [list $ta $tb]
+ }
+ }
+
+ foreach ta $float_types {
+ foreach tb $int_types {
+ start_gdb_and_run_tests $lang [list $ta $tb]
+ }
+
+ foreach tb $float_types {
+ start_gdb_and_run_tests $lang [list $ta $tb]
+ }
+ }
+}
--- /dev/null
+# Copyright 2019-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/>.
+
+# Only test C++ if we are able.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang c++
+
+source $srcdir/$subdir/info-types.exp.in
--- /dev/null
+# Copyright 2019-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/>.
+
+set lang {c}
+
+source $srcdir/$subdir/info-types.exp.in
+++ /dev/null
-# Copyright 2019-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/>.
-
-# Check that 'info types' produces the expected output for an inferior
-# containing a number of different types.
-
-# Only test C++ if we are able. Always use C.
-if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
- set lang {c}
-} else {
- set lang {c c++}
-}
-
-foreach l $lang {
- set dir "$l"
- remote_exec host "rm -rf [standard_output_file ${dir}]"
- remote_exec host "mkdir -p [standard_output_file ${dir}]"
-}
-
-# Run 'info types' test, compiling the test file for language LANG,
-# which should be either 'c' or 'c++'.
-proc run_test { lang } {
- global testfile
- global srcfile
- global binfile
- global subdir
- global srcdir
- global compile_flags
-
- standard_testfile .c
-
- if {[prepare_for_testing "failed to prepare" \
- "${lang}/${testfile}" $srcfile "debug $lang"]} {
- return -1
- }
-
- if ![runto_main] then {
- fail "can't run to main"
- return 0
- }
-
- if { $lang == "c++" } {
- set output_re \
- [multi_line \
- "98:\[\t \]+CL;" \
- "42:\[\t \]+anon_struct_t;" \
- "65:\[\t \]+anon_union_t;" \
- "21:\[\t \]+baz_t;" \
- "33:\[\t \]+enum_t;" \
- "56:\[\t \]+union_t;" \
- "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
- "45:\[\t \]+typedef anon_struct_t anon_struct_t;" \
- "68:\[\t \]+typedef anon_union_t anon_union_t;" \
- "28:\[\t \]+typedef baz_t baz;" \
- "31:\[\t \]+typedef baz_t \\* baz_ptr;" \
- "27:\[\t \]+typedef baz_t baz_t;" \
- "\[\t \]+double" \
- "\[\t \]+float" \
- "\[\t \]+int" \
- "103:\[\t \]+typedef CL my_cl;" \
- "38:\[\t \]+typedef enum_t my_enum_t;" \
- "17:\[\t \]+typedef float my_float_t;" \
- "16:\[\t \]+typedef int my_int_t;" \
- "104:\[\t \]+typedef CL \\* my_ptr;" \
- "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
- "47:\[\t \]+typedef anon_struct_t nested_anon_struct_t;" \
- "70:\[\t \]+typedef anon_union_t nested_anon_union_t;" \
- "30:\[\t \]+typedef baz_t nested_baz;" \
- "29:\[\t \]+typedef baz_t nested_baz_t;" \
- "39:\[\t \]+typedef enum_t nested_enum_t;" \
- "19:\[\t \]+typedef float nested_float_t;" \
- "18:\[\t \]+typedef int nested_int_t;" \
- "62:\[\t \]+typedef union_t nested_union_t;(" \
- "\[\t \]+unsigned int)?"]
- } else {
- set output_re \
- [multi_line \
- "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
- "45:\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
- "68:\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
- "28:\[\t \]+typedef struct baz_t baz;" \
- "31:\[\t \]+typedef struct baz_t \\* baz_ptr;" \
- "21:\[\t \]+struct baz_t;" \
- "\[\t \]+double" \
- "33:\[\t \]+enum enum_t;" \
- "\[\t \]+float" \
- "\[\t \]+int" \
- "38:\[\t \]+typedef enum enum_t my_enum_t;" \
- "17:\[\t \]+typedef float my_float_t;" \
- "16:\[\t \]+typedef int my_int_t;" \
- "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
- "47:\[\t \]+typedef struct {\\.\\.\\.} nested_anon_struct_t;" \
- "70:\[\t \]+typedef union {\\.\\.\\.} nested_anon_union_t;" \
- "30:\[\t \]+typedef struct baz_t nested_baz;" \
- "29:\[\t \]+typedef struct baz_t nested_baz_t;" \
- "39:\[\t \]+typedef enum enum_t nested_enum_t;" \
- "19:\[\t \]+typedef float nested_float_t;" \
- "18:\[\t \]+typedef int nested_int_t;" \
- "62:\[\t \]+typedef union union_t nested_union_t;" \
- "56:\[\t \]+union union_t;(" \
- "\[\t \]+unsigned int)?"]
- }
-
- set state 0
- gdb_test_multiple "info types" "" {
- -re "\r\nAll defined types:" {
- if { $state == 0 } { set state 1 }
- exp_continue
- }
- -re "\r\n\r\nFile .*[string_to_regexp $srcfile]:" {
- if { $state == 1 } { set state 2 }
- exp_continue
- }
- -re $output_re {
- if { $state == 2 } { set state 3 }
- exp_continue
- }
- -re "\r\n\r\nFile \[^\r\n\]*:" {
- exp_continue
- }
- -re -wrap "" {
- if { $state == 3} {
- pass $gdb_test_name
- } else {
- fail $gdb_test_name
- }
- }
- }
-}
-
-foreach_with_prefix l $lang {
- run_test $l
-}
--- /dev/null
+# Copyright 2019-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/>.
+
+# Check that 'info types' produces the expected output for an inferior
+# containing a number of different types.
+
+# Run 'info types' test, compiling the test file for language LANG,
+# which should be either 'c' or 'c++'.
+proc run_test { lang } {
+ global testfile
+ global srcfile
+ global binfile
+ global subdir
+ global srcdir
+ global compile_flags
+
+ standard_testfile info-types.c
+
+ if {[prepare_for_testing "failed to prepare" \
+ "${testfile}" $srcfile "debug $lang"]} {
+ return -1
+ }
+
+ if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+ }
+
+ if { $lang == "c++" } {
+ set output_re \
+ [multi_line \
+ "98:\[\t \]+CL;" \
+ "42:\[\t \]+anon_struct_t;" \
+ "65:\[\t \]+anon_union_t;" \
+ "21:\[\t \]+baz_t;" \
+ "33:\[\t \]+enum_t;" \
+ "56:\[\t \]+union_t;" \
+ "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
+ "45:\[\t \]+typedef anon_struct_t anon_struct_t;" \
+ "68:\[\t \]+typedef anon_union_t anon_union_t;" \
+ "28:\[\t \]+typedef baz_t baz;" \
+ "31:\[\t \]+typedef baz_t \\* baz_ptr;" \
+ "27:\[\t \]+typedef baz_t baz_t;" \
+ "\[\t \]+double" \
+ "\[\t \]+float" \
+ "\[\t \]+int" \
+ "103:\[\t \]+typedef CL my_cl;" \
+ "38:\[\t \]+typedef enum_t my_enum_t;" \
+ "17:\[\t \]+typedef float my_float_t;" \
+ "16:\[\t \]+typedef int my_int_t;" \
+ "104:\[\t \]+typedef CL \\* my_ptr;" \
+ "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
+ "47:\[\t \]+typedef anon_struct_t nested_anon_struct_t;" \
+ "70:\[\t \]+typedef anon_union_t nested_anon_union_t;" \
+ "30:\[\t \]+typedef baz_t nested_baz;" \
+ "29:\[\t \]+typedef baz_t nested_baz_t;" \
+ "39:\[\t \]+typedef enum_t nested_enum_t;" \
+ "19:\[\t \]+typedef float nested_float_t;" \
+ "18:\[\t \]+typedef int nested_int_t;" \
+ "62:\[\t \]+typedef union_t nested_union_t;(" \
+ "\[\t \]+unsigned int)?"]
+ } else {
+ set output_re \
+ [multi_line \
+ "52:\[\t \]+typedef enum {\\.\\.\\.} anon_enum_t;" \
+ "45:\[\t \]+typedef struct {\\.\\.\\.} anon_struct_t;" \
+ "68:\[\t \]+typedef union {\\.\\.\\.} anon_union_t;" \
+ "28:\[\t \]+typedef struct baz_t baz;" \
+ "31:\[\t \]+typedef struct baz_t \\* baz_ptr;" \
+ "21:\[\t \]+struct baz_t;" \
+ "\[\t \]+double" \
+ "33:\[\t \]+enum enum_t;" \
+ "\[\t \]+float" \
+ "\[\t \]+int" \
+ "38:\[\t \]+typedef enum enum_t my_enum_t;" \
+ "17:\[\t \]+typedef float my_float_t;" \
+ "16:\[\t \]+typedef int my_int_t;" \
+ "54:\[\t \]+typedef enum {\\.\\.\\.} nested_anon_enum_t;" \
+ "47:\[\t \]+typedef struct {\\.\\.\\.} nested_anon_struct_t;" \
+ "70:\[\t \]+typedef union {\\.\\.\\.} nested_anon_union_t;" \
+ "30:\[\t \]+typedef struct baz_t nested_baz;" \
+ "29:\[\t \]+typedef struct baz_t nested_baz_t;" \
+ "39:\[\t \]+typedef enum enum_t nested_enum_t;" \
+ "19:\[\t \]+typedef float nested_float_t;" \
+ "18:\[\t \]+typedef int nested_int_t;" \
+ "62:\[\t \]+typedef union union_t nested_union_t;" \
+ "56:\[\t \]+union union_t;(" \
+ "\[\t \]+unsigned int)?"]
+ }
+
+ set state 0
+ gdb_test_multiple "info types" "" {
+ -re "\r\nAll defined types:" {
+ if { $state == 0 } { set state 1 }
+ exp_continue
+ }
+ -re "\r\n\r\nFile .*[string_to_regexp $srcfile]:" {
+ if { $state == 1 } { set state 2 }
+ exp_continue
+ }
+ -re $output_re {
+ if { $state == 2 } { set state 3 }
+ exp_continue
+ }
+ -re "\r\n\r\nFile \[^\r\n\]*:" {
+ exp_continue
+ }
+ -re -wrap "" {
+ if { $state == 3} {
+ pass $gdb_test_name
+ } else {
+ fail $gdb_test_name
+ }
+ }
+ }
+}
+
+run_test $lang
--- /dev/null
+# Copyright 2019-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/>.
+
+# Only test C++ if we are able.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang c++
+
+source $srcdir/$subdir/max-depth.exp.in
--- /dev/null
+# Copyright 2019-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/>.
+
+set lang {c}
+
+source $srcdir/$subdir/max-depth.exp.in
+++ /dev/null
-# Copyright 2019-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/>.
-
-# Tests GDB's handling of 'set print max-depth'.
-
-# Only test C++ if we are able. Always use C.
-if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
- set lang {c}
-} else {
- set lang {c c++}
-}
-
-foreach l $lang {
- set dir "$l"
- remote_exec host "rm -rf [standard_output_file ${dir}]"
- remote_exec host "mkdir -p [standard_output_file ${dir}]"
-}
-
-proc compile_and_run_tests { lang } {
- global testfile
- global srcfile
- global binfile
- global hex
-
- standard_testfile .c
-
- # Create the additional flags.
- set flags "debug"
- lappend flags $lang
- if { "$lang" == "c++" } {
- lappend flags "additional_flags=-std=c++11"
- }
-
- set dir "$lang"
- set binfile [standard_output_file ${dir}/${testfile}]
- if { [prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" "${flags}"] } {
- return 0
- }
-
- # Advance to main.
- if { ![runto_main] } then {
- fail "can't run to main"
- return 0
- }
-
- # The max-depth setting has no effect as the anonymous scopes are
- # ignored and the members are aggregated into the parent scope.
- gdb_print_expr_at_depths "s1" {"{...}" \
- "{x = 0, y = 0}"\
- "{x = 0, y = 0}"}
-
- gdb_print_expr_at_depths "s2" {"{...}" \
- "{x = 0, y = 0, {z = 0, a = 0}}" \
- "{x = 0, y = 0, {z = 0, a = 0}}"}
-
- gdb_print_expr_at_depths "s3" {"{...}" \
- "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}" \
- "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}" \
- "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}"}
-
- # Increasing max-depth unfurls more of the object.
- gdb_print_expr_at_depths "s4" {"{...}" \
- "{x = 0, y = 0, l1 = {...}}" \
- "{x = 0, y = 0, l1 = {x = 0, y = 0, l2 = {...}}}" \
- "{x = 0, y = 0, l1 = {x = 0, y = 0, l2 = {x = 0, y = 0}}}"}
-
- # Check handling of unions, in this case 'raw' is printed instead of
- # just {...} as this is not useful.
- gdb_print_expr_at_depths "s5" {"{...}" \
- "{{raw = {...}, {x = 0, y = 0, z = 0}}}" \
- "{{raw = \\{0, 0, 0\\}, {x = 0, y = 0, z = 0}}}"}
-
- # Check handling of typedefs.
- gdb_print_expr_at_depths "s6" {"{...}" \
- "{{raw = {...}, {x = 0, y = 0, z = 0}}}" \
- "{{raw = \\{0, 0, 0\\}, {x = 0, y = 0, z = 0}}}"}
-
- # Multiple anonymous structures in parallel.
- gdb_print_expr_at_depths "s7" {"{...}" \
- "{{x = 0, y = 0}, {z = 0, a = 0}, {b = 0, c = 0}}" \
- "{{x = 0, y = 0}, {z = 0, a = 0}, {b = 0, c = 0}}"}
-
- # Flip flop between named and anonymous. Expected to unfurl to the
- # first non-anonymous type.
- gdb_print_expr_at_depths "s8" {"{...}" \
- "{x = 0, y = 0, d1 = {...}}" \
- "{x = 0, y = 0, d1 = {z = 0, a = 0, {b = 0, c = 0}}}"}
-
- # Imbalanced tree, this will unfurl one size more than the other as
- # one side has more anonymous levels.
- gdb_print_expr_at_depths "s9" {"{...}" \
- "{x = 0, y = 0, {k = 0, j = 0, d1 = {...}}, d2 = {...}}" \
- "{x = 0, y = 0, {k = 0, j = 0, d1 = {z = 0, a = 0, {b = 0, c = 0}}}, d2 = {z = 0, a = 0, {b = 0, c = 0}}}"}
-
- # Arrays are treated as an extra level, while scalars are not.
- gdb_print_expr_at_depths "s10" {"{...}" \
- "{x = {...}, y = 0, {k = {...}, j = 0, d1 = {...}}, d2 = {...}}" \
- "{x = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, y = 0, {k = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, j = 0, d1 = {z = 0, a = 0, {b = {...}, c = 0}}}, d2 = {z = 0, a = 0, {b = {...}, c = 0}}}" \
- "{x = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, y = 0, {k = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, j = 0, d1 = {z = 0, a = 0, {b = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, c = 0}}}, d2 = {z = 0, a = 0, {b = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, c = 0}}}"}
-
- # Strings are treated as scalars.
- gdb_print_expr_at_depths "s11" {"{...}" \
- "{x = 0, s = \"\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\", {z = 0, a = 0}}"}
-
-
- if { $lang == "c++" } {
- gdb_print_expr_at_depths "c1" {"{...}" \
- "{c1 = 1}" }
- gdb_print_expr_at_depths "c2" { "{...}" "{c2 = 2}" }
- gdb_print_expr_at_depths "c3" { "{...}" \
- "{<C2> = {...}, c3 = 3}" \
- "{<C2> = {c2 = 2}, c3 = 3}" }
- gdb_print_expr_at_depths "c4" { "{...}" "{c4 = 4}" }
- gdb_print_expr_at_depths "c5" { "{...}" \
- "{<C4> = {...}, c5 = 5}" \
- "{<C4> = {c4 = 4}, c5 = 5}" }
- gdb_print_expr_at_depths "c6" { "{...}" \
- "{<C5> = {...}, c6 = 6}" \
- "{<C5> = {<C4> = {...}, c5 = 5}, c6 = 6}" \
- "{<C5> = {<C4> = {c4 = 4}, c5 = 5}, c6 = 6}" }
- gdb_print_expr_at_depths "c7" { "{...}" \
- "{<C1> = {...}, <C3> = {...}, <C6> = {...}, c7 = 7}" \
- "{<C1> = {c1 = 1}, <C3> = {<C2> = {...}, c3 = 3}, <C6> = {<C5> = {...}, c6 = 6}, c7 = 7}" \
- "{<C1> = {c1 = 1}, <C3> = {<C2> = {c2 = 2}, c3 = 3}, <C6> = {<C5> = {<C4> = {...}, c5 = 5}, c6 = 6}, c7 = 7}" \
- "{<C1> = {c1 = 1}, <C3> = {<C2> = {c2 = 2}, c3 = 3}, <C6> = {<C5> = {<C4> = {c4 = 4}, c5 = 5}, c6 = 6}, c7 = 7}" }
-
- gdb_print_expr_at_depths "v1" [list "{...}" "{v1 = 1}" ]
- gdb_print_expr_at_depths "v2" [list "{...}" \
- "{<V1> = {...}, _vptr.V2 = $hex <VTT for V2>, v2 = 2}" \
- "{<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V2>, v2 = 2}" ]
- gdb_print_expr_at_depths "v3" [list "{...}" \
- "{<V1> = {...}, _vptr.V3 = $hex <VTT for V3>, v3 = 3}" \
- "{<V1> = {v1 = 1}, _vptr.V3 = $hex <VTT for V3>, v3 = 3}" ]
- gdb_print_expr_at_depths "v4" [list "{...}" \
- "{<V2> = {...}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" \
- "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <VTT for V4>, v2 = 2}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" \
- "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V4>, v2 = 2}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" ]
- gdb_print_expr_at_depths "v5" [list "{...}" \
- "{<V2> = {...}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" \
- "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <VTT for V5>, v2 = 2}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" \
- "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V5>, v2 = 2}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" ]
- gdb_print_expr_at_depths "v6" [list "{...}" \
- "{<V2> = {...}, <V3> = {...}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" \
- "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <vtable for V6\[^>\]+>, v2 = 2}, <V3> = {_vptr.V3 = $hex <VTT for V6>, v3 = 3}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" \
- "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <vtable for V6\[^>\]+>, v2 = 2}, <V3> = {_vptr.V3 = $hex <VTT for V6>, v3 = 3}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" ]
- gdb_print_expr_at_depths "v7" [list "{...}" \
- "{<V4> = {...}, <V5> = {...}, <V6> = {...}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
- "{<V4> = {<V2> = {...}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {...}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
- "{<V4> = {<V2> = {<V1> = {...}, _vptr.V2 = $hex <vtable for V7\[^>\]+>, v2 = 2}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {_vptr.V3 = $hex <VTT for V7>, v3 = 3}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
- "{<V4> = {<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <vtable for V7\[^>\]+>, v2 = 2}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {_vptr.V3 = $hex <VTT for V7>, v3 = 3}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" ]
- }
-}
-
-foreach_with_prefix l $lang {
- compile_and_run_tests $l
-}
--- /dev/null
+# Copyright 2019-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/>.
+
+# Tests GDB's handling of 'set print max-depth'.
+
+proc compile_and_run_tests { lang } {
+ global testfile
+ global srcfile
+ global binfile
+ global hex
+
+ standard_testfile max-depth.c
+
+ # Create the additional flags.
+ set flags "debug"
+ lappend flags $lang
+ if { "$lang" == "c++" } {
+ lappend flags "additional_flags=-std=c++11"
+ }
+
+ if { [prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" "${flags}"] } {
+ return 0
+ }
+
+ # Advance to main.
+ if { ![runto_main] } then {
+ fail "can't run to main"
+ return 0
+ }
+
+ # The max-depth setting has no effect as the anonymous scopes are
+ # ignored and the members are aggregated into the parent scope.
+ gdb_print_expr_at_depths "s1" {"{...}" \
+ "{x = 0, y = 0}"\
+ "{x = 0, y = 0}"}
+
+ gdb_print_expr_at_depths "s2" {"{...}" \
+ "{x = 0, y = 0, {z = 0, a = 0}}" \
+ "{x = 0, y = 0, {z = 0, a = 0}}"}
+
+ gdb_print_expr_at_depths "s3" {"{...}" \
+ "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}" \
+ "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}" \
+ "{x = 0, y = 0, {z = 0, a = 0, {b = 0, c = 0}}}"}
+
+ # Increasing max-depth unfurls more of the object.
+ gdb_print_expr_at_depths "s4" {"{...}" \
+ "{x = 0, y = 0, l1 = {...}}" \
+ "{x = 0, y = 0, l1 = {x = 0, y = 0, l2 = {...}}}" \
+ "{x = 0, y = 0, l1 = {x = 0, y = 0, l2 = {x = 0, y = 0}}}"}
+
+ # Check handling of unions, in this case 'raw' is printed instead of
+ # just {...} as this is not useful.
+ gdb_print_expr_at_depths "s5" {"{...}" \
+ "{{raw = {...}, {x = 0, y = 0, z = 0}}}" \
+ "{{raw = \\{0, 0, 0\\}, {x = 0, y = 0, z = 0}}}"}
+
+ # Check handling of typedefs.
+ gdb_print_expr_at_depths "s6" {"{...}" \
+ "{{raw = {...}, {x = 0, y = 0, z = 0}}}" \
+ "{{raw = \\{0, 0, 0\\}, {x = 0, y = 0, z = 0}}}"}
+
+ # Multiple anonymous structures in parallel.
+ gdb_print_expr_at_depths "s7" {"{...}" \
+ "{{x = 0, y = 0}, {z = 0, a = 0}, {b = 0, c = 0}}" \
+ "{{x = 0, y = 0}, {z = 0, a = 0}, {b = 0, c = 0}}"}
+
+ # Flip flop between named and anonymous. Expected to unfurl to the
+ # first non-anonymous type.
+ gdb_print_expr_at_depths "s8" {"{...}" \
+ "{x = 0, y = 0, d1 = {...}}" \
+ "{x = 0, y = 0, d1 = {z = 0, a = 0, {b = 0, c = 0}}}"}
+
+ # Imbalanced tree, this will unfurl one size more than the other as
+ # one side has more anonymous levels.
+ gdb_print_expr_at_depths "s9" {"{...}" \
+ "{x = 0, y = 0, {k = 0, j = 0, d1 = {...}}, d2 = {...}}" \
+ "{x = 0, y = 0, {k = 0, j = 0, d1 = {z = 0, a = 0, {b = 0, c = 0}}}, d2 = {z = 0, a = 0, {b = 0, c = 0}}}"}
+
+ # Arrays are treated as an extra level, while scalars are not.
+ gdb_print_expr_at_depths "s10" {"{...}" \
+ "{x = {...}, y = 0, {k = {...}, j = 0, d1 = {...}}, d2 = {...}}" \
+ "{x = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, y = 0, {k = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, j = 0, d1 = {z = 0, a = 0, {b = {...}, c = 0}}}, d2 = {z = 0, a = 0, {b = {...}, c = 0}}}" \
+ "{x = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, y = 0, {k = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, j = 0, d1 = {z = 0, a = 0, {b = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, c = 0}}}, d2 = {z = 0, a = 0, {b = \\{0, 0, 0, 0, 0, 0, 0, 0, 0, 0\\}, c = 0}}}"}
+
+ # Strings are treated as scalars.
+ gdb_print_expr_at_depths "s11" {"{...}" \
+ "{x = 0, s = \"\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\", {z = 0, a = 0}}"}
+
+
+ if { $lang == "c++" } {
+ gdb_print_expr_at_depths "c1" {"{...}" \
+ "{c1 = 1}" }
+ gdb_print_expr_at_depths "c2" { "{...}" "{c2 = 2}" }
+ gdb_print_expr_at_depths "c3" { "{...}" \
+ "{<C2> = {...}, c3 = 3}" \
+ "{<C2> = {c2 = 2}, c3 = 3}" }
+ gdb_print_expr_at_depths "c4" { "{...}" "{c4 = 4}" }
+ gdb_print_expr_at_depths "c5" { "{...}" \
+ "{<C4> = {...}, c5 = 5}" \
+ "{<C4> = {c4 = 4}, c5 = 5}" }
+ gdb_print_expr_at_depths "c6" { "{...}" \
+ "{<C5> = {...}, c6 = 6}" \
+ "{<C5> = {<C4> = {...}, c5 = 5}, c6 = 6}" \
+ "{<C5> = {<C4> = {c4 = 4}, c5 = 5}, c6 = 6}" }
+ gdb_print_expr_at_depths "c7" { "{...}" \
+ "{<C1> = {...}, <C3> = {...}, <C6> = {...}, c7 = 7}" \
+ "{<C1> = {c1 = 1}, <C3> = {<C2> = {...}, c3 = 3}, <C6> = {<C5> = {...}, c6 = 6}, c7 = 7}" \
+ "{<C1> = {c1 = 1}, <C3> = {<C2> = {c2 = 2}, c3 = 3}, <C6> = {<C5> = {<C4> = {...}, c5 = 5}, c6 = 6}, c7 = 7}" \
+ "{<C1> = {c1 = 1}, <C3> = {<C2> = {c2 = 2}, c3 = 3}, <C6> = {<C5> = {<C4> = {c4 = 4}, c5 = 5}, c6 = 6}, c7 = 7}" }
+
+ gdb_print_expr_at_depths "v1" [list "{...}" "{v1 = 1}" ]
+ gdb_print_expr_at_depths "v2" [list "{...}" \
+ "{<V1> = {...}, _vptr.V2 = $hex <VTT for V2>, v2 = 2}" \
+ "{<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V2>, v2 = 2}" ]
+ gdb_print_expr_at_depths "v3" [list "{...}" \
+ "{<V1> = {...}, _vptr.V3 = $hex <VTT for V3>, v3 = 3}" \
+ "{<V1> = {v1 = 1}, _vptr.V3 = $hex <VTT for V3>, v3 = 3}" ]
+ gdb_print_expr_at_depths "v4" [list "{...}" \
+ "{<V2> = {...}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" \
+ "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <VTT for V4>, v2 = 2}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" \
+ "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V4>, v2 = 2}, _vptr.V4 = $hex <vtable for V4\[^>\]+>, v4 = 4}" ]
+ gdb_print_expr_at_depths "v5" [list "{...}" \
+ "{<V2> = {...}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" \
+ "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <VTT for V5>, v2 = 2}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" \
+ "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <VTT for V5>, v2 = 2}, _vptr.V5 = $hex <vtable for V5\[^>\]+>, v5 = 1}" ]
+ gdb_print_expr_at_depths "v6" [list "{...}" \
+ "{<V2> = {...}, <V3> = {...}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" \
+ "{<V2> = {<V1> = {...}, _vptr.V2 = $hex <vtable for V6\[^>\]+>, v2 = 2}, <V3> = {_vptr.V3 = $hex <VTT for V6>, v3 = 3}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" \
+ "{<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <vtable for V6\[^>\]+>, v2 = 2}, <V3> = {_vptr.V3 = $hex <VTT for V6>, v3 = 3}, _vptr.V6 = $hex <vtable for V6\[^>\]+>, v6 = 1}" ]
+ gdb_print_expr_at_depths "v7" [list "{...}" \
+ "{<V4> = {...}, <V5> = {...}, <V6> = {...}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
+ "{<V4> = {<V2> = {...}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {...}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
+ "{<V4> = {<V2> = {<V1> = {...}, _vptr.V2 = $hex <vtable for V7\[^>\]+>, v2 = 2}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {_vptr.V3 = $hex <VTT for V7>, v3 = 3}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" \
+ "{<V4> = {<V2> = {<V1> = {v1 = 1}, _vptr.V2 = $hex <vtable for V7\[^>\]+>, v2 = 2}, _vptr.V4 = $hex <vtable for V7\[^>\]+>, v4 = 4}, <V5> = {_vptr.V5 = $hex <vtable for V7\[^>\]+>, v5 = 1}, <V6> = {<V3> = {_vptr.V3 = $hex <VTT for V7>, v3 = 3}, _vptr.V6 = $hex <vtable for V7\[^>\]+>, v6 = 1}, _vptr.V7 = $hex <vtable for V7\[^>\]+>, v7 = 1}" ]
+ }
+}
+
+compile_and_run_tests $lang
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+# Copyright 2018-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/>.
+
+# Only test C++ if we are able. Always use C.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang {c++}
+
+set debug nodebug
+
+source $srcdir/$subdir/infcall-nodebug.exp.in
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+# Copyright 2018-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/>.
+
+# Only test C++ if we are able. Always use C.
+if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
+ return -1
+}
+set lang {c++}
+
+set debug debug
+
+source $srcdir/$subdir/infcall-nodebug.exp.in
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+# Copyright 2018-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/>.
+
+set lang {c}
+
+set debug nodebug
+
+source $srcdir/$subdir/infcall-nodebug.exp.in
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+# Copyright 2018-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/>.
+
+set lang {c}
+
+set debug debug
+
+source $srcdir/$subdir/infcall-nodebug.exp.in
+++ /dev/null
-# This testcase is part of GDB, the GNU debugger.
-# Copyright 2018-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 function calls on C++ functions that have no debug information.
-# See gdb/22736. Put the called function in a different object to ensure
-# the rest of the test can be complied with debug information. Whilst we
-# are at it, also test functions with debug information and C functions too.
-
-if [target_info exists gdb,cannot_call_functions] {
- unsupported "this target can not call functions"
- continue
-}
-
-# Only test C++ if we are able. Always use C.
-if { [skip_cplus_tests] || [get_compiler_info "c++"] } {
- set lang {c}
-} else {
- set lang {c c++}
-}
-
-set main_basename infcall-nodebug-main
-set lib_basename infcall-nodebug-lib
-standard_testfile ${main_basename}.c ${lib_basename}.c
-
-set mainsrc "${srcdir}/${subdir}/${srcfile}"
-set libsrc "${srcdir}/${subdir}/${srcfile2}"
-
-# Build both source files to objects using language LANG. Use SYMBOLS to build
-# with either debug symbols or without - but always build the main file with
-# debug. Then make function calls across the files.
-
-proc build_and_run_test { lang symbols } {
-
- global main_basename lib_basename mainsrc libsrc binfile testfile
- global gdb_prompt
-
- if { $symbols == "debug" } {
- set debug_flags "debug"
- } else {
- set debug_flags ""
- }
-
- # Setup directory.
-
- set dir "$lang-$symbols"
- remote_exec build "rm -rf [standard_output_file ${dir}]"
- remote_exec build "mkdir -p [standard_output_file ${dir}]"
-
- # Compile both files to objects, then link together.
-
- set main_flags "$lang debug"
- set lib_flags "$lang $debug_flags"
- set main_o [standard_output_file ${dir}/${main_basename}.o]
- set lib_o [standard_output_file ${dir}/${lib_basename}.o]
- set binfile [standard_output_file ${dir}/${testfile}]
-
- if { [gdb_compile $mainsrc $main_o object ${main_flags}] != "" } {
- untested "failed to compile main file to object"
- return -1
- }
-
- if { [gdb_compile $libsrc $lib_o object ${lib_flags}] != "" } {
- untested "failed to compile secondary file to object"
- return -1
- }
-
- if { [gdb_compile "$main_o $lib_o" ${binfile} executable ""] != "" } {
- untested "failed to compile"
- return -1
- }
-
- # Startup and run to main.
-
- clean_restart $binfile
-
- if ![runto_main] then {
- fail "can't run to main"
- return
- }
-
- # Function call with cast.
-
- gdb_test "p (int)foo()" " = 1"
-
- # Function call without cast. Will error if there are no debug symbols.
-
- set test "p foo()"
- gdb_test_multiple $test $test {
- -re " = 1\r\n$gdb_prompt " {
- gdb_assert [ string equal $symbols "debug" ]
- pass $test
- }
- -re "has unknown return type; cast the call to its declared return type\r\n$gdb_prompt " {
- gdb_assert ![ string equal $symbols "debug" ]
- pass $test
- }
- }
-
-}
-
-foreach_with_prefix l $lang {
- foreach_with_prefix s {debug nodebug} {
- build_and_run_test $l $s
- }
-}
-
--- /dev/null
+# This testcase is part of GDB, the GNU debugger.
+# Copyright 2018-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 function calls on C++ functions that have no debug information.
+# See gdb/22736. Put the called function in a different object to ensure
+# the rest of the test can be complied with debug information. Whilst we
+# are at it, also test functions with debug information and C functions too.
+
+if [target_info exists gdb,cannot_call_functions] {
+ unsupported "this target can not call functions"
+ continue
+}
+
+set main_basename infcall-nodebug-main
+set lib_basename infcall-nodebug-lib
+standard_testfile ${main_basename}.c ${lib_basename}.c
+
+set mainsrc "${srcdir}/${subdir}/${srcfile}"
+set libsrc "${srcdir}/${subdir}/${srcfile2}"
+
+# Build both source files to objects using language LANG. Use SYMBOLS to build
+# with either debug symbols or without - but always build the main file with
+# debug. Then make function calls across the files.
+
+proc build_and_run_test { lang symbols } {
+
+ global main_basename lib_basename mainsrc libsrc binfile testfile
+ global gdb_prompt
+
+ if { $symbols == "debug" } {
+ set debug_flags "debug"
+ } else {
+ set debug_flags ""
+ }
+
+ # Compile both files to objects, then link together.
+
+ set main_flags "$lang debug"
+ set lib_flags "$lang $debug_flags"
+ set main_o [standard_output_file ${main_basename}.o]
+ set lib_o [standard_output_file ${lib_basename}.o]
+ set binfile [standard_output_file ${testfile}]
+
+ if { [gdb_compile $mainsrc $main_o object ${main_flags}] != "" } {
+ untested "failed to compile main file to object"
+ return -1
+ }
+
+ if { [gdb_compile $libsrc $lib_o object ${lib_flags}] != "" } {
+ untested "failed to compile secondary file to object"
+ return -1
+ }
+
+ if { [gdb_compile "$main_o $lib_o" ${binfile} executable ""] != "" } {
+ untested "failed to compile"
+ return -1
+ }
+
+ # Startup and run to main.
+
+ clean_restart $binfile
+
+ if ![runto_main] then {
+ fail "can't run to main"
+ return
+ }
+
+ # Function call with cast.
+
+ gdb_test "p (int)foo()" " = 1"
+
+ # Function call without cast. Will error if there are no debug symbols.
+
+ set test "p foo()"
+ gdb_test_multiple $test $test {
+ -re " = 1\r\n$gdb_prompt " {
+ gdb_assert [ string equal $symbols "debug" ]
+ pass $test
+ }
+ -re "has unknown return type; cast the call to its declared return type\r\n$gdb_prompt " {
+ gdb_assert ![ string equal $symbols "debug" ]
+ pass $test
+ }
+ }
+
+}
+
+build_and_run_test $lang $debug