From 6dbc505a74ac6bb930a4b7306e60ea3a439bb886 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 15 May 2020 14:49:48 +0200 Subject: [gdb/testsuite] Rename *.exp.in to *.exp.tcl Say we have some common tcl code that we want to include in test-cases t1.exp and t1.exp. We could put the common code into a file common.exp alongside the test-cases, but that will make dejagnu treat that file as another test-case. To prevent this, we use a suffix, currently .in, in other words we put the common code in a file common.exp.in. The .in suffix however is also used in autoconf, which might cause confusion. Change the suffix from .in to .tcl. gdb/testsuite/ChangeLog: 2020-05-15 Tom de Vries * gdb.base/align.exp.in: Rename to ... * gdb.base/align.exp.tcl: ... this. * gdb.base/align-c++.exp: Update. * gdb.base/align-c.exp: Update. * gdb.base/all-architectures.exp.in: Rename to ... * gdb.base/all-architectures.exp: ... this. * gdb.base/all-architectures-0.exp: Update. * gdb.base/all-architectures-1.exp: Update. * gdb.base/all-architectures-2.exp: Update. * gdb.base/all-architectures-3.exp: Update. * gdb.base/all-architectures-4.exp: Update. * gdb.base/all-architectures-5.exp: Update. * gdb.base/all-architectures-6.exp: Update. * gdb.base/all-architectures-7.exp: Update. * gdb.base/infcall-nested-structs.exp.in: Rename to ... * gdb.base/infcall-nested-structs.exp.tcl: ... this. * gdb.base/infcall-nested-structs-c++.exp: Update. * gdb.base/infcall-nested-structs-c.exp: Update. * gdb.base/info-types.exp.in: Rename to ... * gdb.base/info-types.exp.tcl: ... this. * gdb.base/info-types-c++.exp: Update. * gdb.base/info-types-c.exp: Update. * gdb.base/max-depth.exp.in: Rename to ... * gdb.base/max-depth.exp.tcl: ... this. * gdb.base/max-depth-c++.exp: Update. * gdb.base/max-depth-c.exp: Update. * gdb.cp/cpexprs.exp.in: Rename to ... * gdb.cp/cpexprs.exp.tcl: ... this. * gdb.cp/cpexprs-debug-types.exp: Update. * gdb.cp/cpexprs.exp: Update. * gdb.cp/infcall-nodebug.exp.in: Rename to ... * gdb.cp/infcall-nodebug.exp.tcl: ... this. * gdb.cp/infcall-nodebug-c++-d0.exp: Update. * gdb.cp/infcall-nodebug-c++-d1.exp: Update. * gdb.cp/infcall-nodebug-c-d0.exp: Update. * gdb.cp/infcall-nodebug-c-d1.exp: Update. * gdb.dwarf2/clang-debug-names.exp.in: Rename to ... * gdb.dwarf2/clang-debug-names.exp.tcl: ... this. * gdb.dwarf2/clang-debug-names-2.exp: Update. * gdb.dwarf2/clang-debug-names.exp: Update. --- gdb/testsuite/ChangeLog | 43 ++ gdb/testsuite/gdb.base/align-c++.exp | 2 +- gdb/testsuite/gdb.base/align-c.exp | 2 +- gdb/testsuite/gdb.base/align.exp.in | 179 ----- gdb/testsuite/gdb.base/align.exp.tcl | 179 +++++ gdb/testsuite/gdb.base/all-architectures-0.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-1.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-2.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-3.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-4.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-5.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-6.exp | 2 +- gdb/testsuite/gdb.base/all-architectures-7.exp | 2 +- gdb/testsuite/gdb.base/all-architectures.exp.in | 341 --------- gdb/testsuite/gdb.base/all-architectures.exp.tcl | 341 +++++++++ .../gdb.base/infcall-nested-structs-c++.exp | 2 +- .../gdb.base/infcall-nested-structs-c.exp | 2 +- .../gdb.base/infcall-nested-structs.exp.in | 184 ----- .../gdb.base/infcall-nested-structs.exp.tcl | 184 +++++ gdb/testsuite/gdb.base/info-types-c++.exp | 2 +- gdb/testsuite/gdb.base/info-types-c.exp | 2 +- gdb/testsuite/gdb.base/info-types.exp.in | 130 ---- gdb/testsuite/gdb.base/info-types.exp.tcl | 130 ++++ gdb/testsuite/gdb.base/max-depth-c++.exp | 2 +- gdb/testsuite/gdb.base/max-depth-c.exp | 2 +- gdb/testsuite/gdb.base/max-depth.exp.in | 151 ---- gdb/testsuite/gdb.base/max-depth.exp.tcl | 151 ++++ gdb/testsuite/gdb.cp/cpexprs-debug-types.exp | 2 +- gdb/testsuite/gdb.cp/cpexprs.exp | 2 +- gdb/testsuite/gdb.cp/cpexprs.exp.in | 761 --------------------- gdb/testsuite/gdb.cp/cpexprs.exp.tcl | 761 +++++++++++++++++++++ gdb/testsuite/gdb.cp/infcall-nodebug-c++-d0.exp | 2 +- gdb/testsuite/gdb.cp/infcall-nodebug-c++-d1.exp | 2 +- gdb/testsuite/gdb.cp/infcall-nodebug-c-d0.exp | 2 +- gdb/testsuite/gdb.cp/infcall-nodebug-c-d1.exp | 2 +- gdb/testsuite/gdb.cp/infcall-nodebug.exp.in | 101 --- gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl | 101 +++ gdb/testsuite/gdb.dwarf2/clang-debug-names-2.exp | 2 +- gdb/testsuite/gdb.dwarf2/clang-debug-names.exp | 2 +- gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.in | 121 ---- gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl | 121 ++++ 41 files changed, 2035 insertions(+), 1992 deletions(-) delete mode 100644 gdb/testsuite/gdb.base/align.exp.in create mode 100644 gdb/testsuite/gdb.base/align.exp.tcl delete mode 100644 gdb/testsuite/gdb.base/all-architectures.exp.in create mode 100644 gdb/testsuite/gdb.base/all-architectures.exp.tcl delete mode 100644 gdb/testsuite/gdb.base/infcall-nested-structs.exp.in create mode 100644 gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl delete mode 100644 gdb/testsuite/gdb.base/info-types.exp.in create mode 100644 gdb/testsuite/gdb.base/info-types.exp.tcl delete mode 100644 gdb/testsuite/gdb.base/max-depth.exp.in create mode 100644 gdb/testsuite/gdb.base/max-depth.exp.tcl delete mode 100644 gdb/testsuite/gdb.cp/cpexprs.exp.in create mode 100644 gdb/testsuite/gdb.cp/cpexprs.exp.tcl delete mode 100644 gdb/testsuite/gdb.cp/infcall-nodebug.exp.in create mode 100644 gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl delete mode 100644 gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.in create mode 100644 gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl (limited to 'gdb') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5a523c2..30a150d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,46 @@ +2020-05-15 Tom de Vries + + * gdb.base/align.exp.in: Rename to ... + * gdb.base/align.exp.tcl: ... this. + * gdb.base/align-c++.exp: Update. + * gdb.base/align-c.exp: Update. + * gdb.base/all-architectures.exp.in: Rename to ... + * gdb.base/all-architectures.exp: ... this. + * gdb.base/all-architectures-0.exp: Update. + * gdb.base/all-architectures-1.exp: Update. + * gdb.base/all-architectures-2.exp: Update. + * gdb.base/all-architectures-3.exp: Update. + * gdb.base/all-architectures-4.exp: Update. + * gdb.base/all-architectures-5.exp: Update. + * gdb.base/all-architectures-6.exp: Update. + * gdb.base/all-architectures-7.exp: Update. + * gdb.base/infcall-nested-structs.exp.in: Rename to ... + * gdb.base/infcall-nested-structs.exp.tcl: ... this. + * gdb.base/infcall-nested-structs-c++.exp: Update. + * gdb.base/infcall-nested-structs-c.exp: Update. + * gdb.base/info-types.exp.in: Rename to ... + * gdb.base/info-types.exp.tcl: ... this. + * gdb.base/info-types-c++.exp: Update. + * gdb.base/info-types-c.exp: Update. + * gdb.base/max-depth.exp.in: Rename to ... + * gdb.base/max-depth.exp.tcl: ... this. + * gdb.base/max-depth-c++.exp: Update. + * gdb.base/max-depth-c.exp: Update. + * gdb.cp/cpexprs.exp.in: Rename to ... + * gdb.cp/cpexprs.exp.tcl: ... this. + * gdb.cp/cpexprs-debug-types.exp: Update. + * gdb.cp/cpexprs.exp: Update. + * gdb.cp/infcall-nodebug.exp.in: Rename to ... + * gdb.cp/infcall-nodebug.exp.tcl: ... this. + * gdb.cp/infcall-nodebug-c++-d0.exp: Update. + * gdb.cp/infcall-nodebug-c++-d1.exp: Update. + * gdb.cp/infcall-nodebug-c-d0.exp: Update. + * gdb.cp/infcall-nodebug-c-d1.exp: Update. + * gdb.dwarf2/clang-debug-names.exp.in: Rename to ... + * gdb.dwarf2/clang-debug-names.exp.tcl: ... this. + * gdb.dwarf2/clang-debug-names-2.exp: Update. + * gdb.dwarf2/clang-debug-names.exp: Update. + 2020-05-15 Andrew Burgess * lib/check-test-names.exp: Remove code that prevents this file diff --git a/gdb/testsuite/gdb.base/align-c++.exp b/gdb/testsuite/gdb.base/align-c++.exp index 09632d8..6266d11 100644 --- a/gdb/testsuite/gdb.base/align-c++.exp +++ b/gdb/testsuite/gdb.base/align-c++.exp @@ -24,4 +24,4 @@ if { [skip_cplus_tests] || [get_compiler_info "c++"] } { } set lang c++ -source $srcdir/$subdir/align.exp.in +source $srcdir/$subdir/align.exp.tcl diff --git a/gdb/testsuite/gdb.base/align-c.exp b/gdb/testsuite/gdb.base/align-c.exp index d7852f4..d42abc8 100644 --- a/gdb/testsuite/gdb.base/align-c.exp +++ b/gdb/testsuite/gdb.base/align-c.exp @@ -20,4 +20,4 @@ set lang c -source $srcdir/$subdir/align.exp.in +source $srcdir/$subdir/align.exp.tcl diff --git a/gdb/testsuite/gdb.base/align.exp.in b/gdb/testsuite/gdb.base/align.exp.in deleted file mode 100644 index 0653371..0000000 --- a/gdb/testsuite/gdb.base/align.exp.in +++ /dev/null @@ -1,179 +0,0 @@ -# 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 . - -# 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 diff --git a/gdb/testsuite/gdb.base/align.exp.tcl b/gdb/testsuite/gdb.base/align.exp.tcl new file mode 100644 index 0000000..0653371 --- /dev/null +++ b/gdb/testsuite/gdb.base/align.exp.tcl @@ -0,0 +1,179 @@ +# 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 . + +# 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 diff --git a/gdb/testsuite/gdb.base/all-architectures-0.exp b/gdb/testsuite/gdb.base/all-architectures-0.exp index 767daac..d861c41 100644 --- a/gdb/testsuite/gdb.base/all-architectures-0.exp +++ b/gdb/testsuite/gdb.base/all-architectures-0.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 0 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-1.exp b/gdb/testsuite/gdb.base/all-architectures-1.exp index 91aad9d..0e6379e 100644 --- a/gdb/testsuite/gdb.base/all-architectures-1.exp +++ b/gdb/testsuite/gdb.base/all-architectures-1.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 1 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-2.exp b/gdb/testsuite/gdb.base/all-architectures-2.exp index c24a332..6216d48 100644 --- a/gdb/testsuite/gdb.base/all-architectures-2.exp +++ b/gdb/testsuite/gdb.base/all-architectures-2.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 2 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-3.exp b/gdb/testsuite/gdb.base/all-architectures-3.exp index a88a38b..bd873a9 100644 --- a/gdb/testsuite/gdb.base/all-architectures-3.exp +++ b/gdb/testsuite/gdb.base/all-architectures-3.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 3 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-4.exp b/gdb/testsuite/gdb.base/all-architectures-4.exp index f6c9fc4..17b0160 100644 --- a/gdb/testsuite/gdb.base/all-architectures-4.exp +++ b/gdb/testsuite/gdb.base/all-architectures-4.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 4 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-5.exp b/gdb/testsuite/gdb.base/all-architectures-5.exp index e84441b..613ae6f 100644 --- a/gdb/testsuite/gdb.base/all-architectures-5.exp +++ b/gdb/testsuite/gdb.base/all-architectures-5.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 5 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-6.exp b/gdb/testsuite/gdb.base/all-architectures-6.exp index 702b523..3dceb5e 100644 --- a/gdb/testsuite/gdb.base/all-architectures-6.exp +++ b/gdb/testsuite/gdb.base/all-architectures-6.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 6 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures-7.exp b/gdb/testsuite/gdb.base/all-architectures-7.exp index 2d0705b..ba7640c 100644 --- a/gdb/testsuite/gdb.base/all-architectures-7.exp +++ b/gdb/testsuite/gdb.base/all-architectures-7.exp @@ -14,4 +14,4 @@ # along with this program. If not, see . */ set test_slice 7 -source $srcdir/$subdir/all-architectures.exp.in +source $srcdir/$subdir/all-architectures.exp.tcl diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.in b/gdb/testsuite/gdb.base/all-architectures.exp.in deleted file mode 100644 index ebdd344..0000000 --- a/gdb/testsuite/gdb.base/all-architectures.exp.in +++ /dev/null @@ -1,341 +0,0 @@ -# Copyright (C) 2016-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 . - -# This file is part of the gdb testsuite. - -# Test manually setting _all_ combinations of all supported bfd -# architectures and OS ABIs. This ensures that gdbarch initialization -# routines handle unusual combinations gracefully, at least without -# crashing. - -# While at it, because the number of possible combinations is quite -# large, embed other checks that might be useful to do with all -# supported archs. - -# One such test is ensuring that printing float, double and long -# double types works in cross/bi-arch scenarios. Some of GDB's float -# format conversion routines used to fail to consider that even if -# host and target floating formats match, their sizes may still -# differ. E.g., on x86, long double is 80-bit extended precision on -# both 32-bit vs 64-bit, but it's stored as 96 bit on 32-bit, and 128 -# bit on 64-bit. This resulted in GDB accessing memory out of bounds. -# This test catches the issue when run against gdb linked with -# libmcheck, or run under Valgrind. - -# Note: this test is actually split in several driver .exp files, in -# order to be able to parallelize the work. Each driver .exp file -# exercises a different slice of the supported architectures. See -# all-architectures-*.exp and the TEST_SLICE variable. - -clean_restart - -# By default, preparation steps don't output a PASS message. This is -# because the testcase has several thousand such steps. -set want_tests_messages 0 - -# Call this when an "internal" preparation-like step test passed. -# Logs the pass in gdb.log, but not in gdb.sum. - -proc internal_pass {message} { - global want_tests_messages - - if {$want_tests_messages} { - pass $message - } else { - # Skip the sum file, but still log an internal pass in the log - # file. - global pf_prefix - - verbose -log "IPASS: $pf_prefix $message" - } -} - -# The number of times gdb_test_internal was called, and the number of -# time that resulted in an internal pass. If these don't match, then -# some test failed. -set test_count 0 -set internal_pass_count 0 - -# Like gdb_test, but calls internal_pass instead of pass, on success. - -proc gdb_test_internal {cmd pattern {message ""}} { - global test_count internal_pass_count - global gdb_prompt - - incr test_count - - if {$message == ""} { - set message $cmd - } - - gdb_test_multiple $cmd $message { - -re "$pattern\r\n$gdb_prompt $" { - internal_pass $message - incr internal_pass_count - } - } -} - -gdb_test_internal "set max-completions unlimited" \ - "^set max-completions unlimited" - -# Return a list of all the accepted values of "set WHAT". - -proc get_set_option_choices {what} { - global gdb_prompt - - set values {} - - set test "complete set $what" - gdb_test_multiple "complete set $what " "$test" { - -re "set $what (\[^\r\n\]+)\r\n" { - lappend values $expect_out(1,string) - exp_continue - } - -re "$gdb_prompt " { - internal_pass $test - } - } - return $values -} - -set supported_archs [get_set_option_choices "architecture"] -# There should be at least one more than "auto". -gdb_assert {[llength $supported_archs] > 1} "at least one architecture" - -set supported_osabis [get_set_option_choices "osabi"] -# There should be at least one more than "auto" and "default". -gdb_assert {[llength $supported_osabis] > 2} "at least one osabi" - -if {[lsearch $supported_archs "mips"] >= 0} { - set supported_mipsfpu [get_set_option_choices "mipsfpu"] - set supported_mips_abi [get_set_option_choices "mips abi"] - - gdb_assert {[llength $supported_mipsfpu] != 0} "at least one mipsfpu" - gdb_assert {[llength $supported_mips_abi] != 0} "at least one mips abi" -} - -if {[lsearch $supported_archs "arm"] >= 0} { - set supported_arm_fpu [get_set_option_choices "arm fpu"] - set supported_arm_abi [get_set_option_choices "arm abi"] - - gdb_assert {[llength $supported_arm_fpu] != 0} "at least one arm fpu" - gdb_assert {[llength $supported_arm_abi] != 0} "at least one arm abi" -} - -# Exercise printing float, double and long double. - -proc print_floats {} { - gdb_test_internal "ptype 1.0L" "type = long double" "ptype, long double" - gdb_test_internal "print 1.0L" " = 1" "print, long double" - - gdb_test_internal "ptype 1.0" "type = double" "ptype, double" - gdb_test_internal "print 1.0" " = 1" "print, double" - - gdb_test_internal "ptype 1.0f" "type = float" "ptype, float" - gdb_test_internal "print 1.0f" " = 1" "print, float" -} - -# Run tests on the current architecture. - -proc do_arch_tests {} { - print_floats - - # GDB can't access memory because there is no loaded executable - # nor live inferior. - gdb_test_internal "disassemble 0x0,+4" \ - "Cannot access memory at address 0x0" -} - -# Given we can't change arch, osabi, endianness, etc. atomically, we -# need to silently ignore the case of the current OS ABI (not the one -# we'll switch to) not having a handler for the arch. -set osabi_warning \ - [multi_line \ - "warning: A handler for the OS ABI .* is not built into this configuration" \ - "of GDB. Attempting to continue with the default .* settings." \ - "" \ - "" \ - ] - -set endian_warning "(Little|Big) endian target not supported by GDB\r\n" - -# Like gdb_test_no_output, but use internal_pass instead of pass, and -# ignore "no handler for OS ABI" warnings. - -proc gdb_test_no_output_osabi {cmd test} { - global osabi_warning - global gdb_prompt - - gdb_test_multiple "$cmd" $test { - -re "^${cmd}\r\n(${osabi_warning})?$gdb_prompt $" { - internal_pass $test - } - } -} - -# It'd be nicer/safer to restart GDB on each iteration, but, that -# increases the testcase's run time several times fold. At the time -# of writting, it'd jump from 20s to 4min on x86-64 GNU/Linux with -# --enable-targets=all. - -set num_slices 8 -set num_archs [llength $supported_archs] -set archs_per_slice [expr (($num_archs + $num_slices - 1) / $num_slices)] - -with_test_prefix "tests" { - foreach_with_prefix osabi $supported_osabis { - - gdb_test_no_output_osabi "set osabi $osabi" \ - "set osabi" - - set arch_count 0 - foreach_with_prefix arch $supported_archs { - - incr arch_count - - # Skip architectures outside our slice. - if {$arch_count < [expr $test_slice * $archs_per_slice]} { - continue - } - if {$arch_count >= [expr ($test_slice + 1) * $archs_per_slice]} { - continue - } - - if {$arch == "auto"} { - continue - } - set default_endian "" - foreach_with_prefix endian {"auto" "big" "little"} { - - set test "set endian" - if {$endian == $default_endian} { - continue - } elseif {$endian == "auto"} { - gdb_test_multiple "set endian $endian" $test { - -re "^set endian $endian\r\n(${osabi_warning})?The target endianness is set automatically \\(currently .* endian\\)\r\n$gdb_prompt $" { - internal_pass $test - } - } - } else { - gdb_test_multiple "set endian $endian" $test { - -re "^set endian $endian\r\n${endian_warning}.*\r\n$gdb_prompt $" { - internal_pass $test - continue - } - -re "^set endian $endian\r\n(${osabi_warning})?The target is assumed to be $endian endian\r\n$gdb_prompt $" { - internal_pass $test - } - } - } - - # Skip setting the same architecture again. - if {$endian == "auto"} { - set arch_re [string_to_regexp $arch] - set test "set architecture $arch" - gdb_test_multiple $test $test { - -re "^set architecture $arch_re\r\n(${osabi_warning})?The target architecture is assumed to be $arch_re\r\n$gdb_prompt $" { - internal_pass $test - } - -re "Architecture .* not recognized.*$gdb_prompt $" { - # GDB is missing support for a few - # machines that bfd supports. - if {$arch == "powerpc:EC603e" - || $arch == "powerpc:e500mc" - || $arch == "powerpc:e500mc64" - || $arch == "powerpc:vle" - || $arch == "powerpc:titan" - || $arch == "powerpc:e5500" - || $arch == "powerpc:e6500"} { - if {$want_tests_messages} { - kfail $test "gdb/19797" - } - } else { - fail "$test (arch not recognized)" - } - continue - } - } - - # Record what is the default endianess. As an - # optimization, we'll skip testing the manual "set - # endian DEFAULT" case. - set test "show endian" - gdb_test_multiple "show endian" $test { - -re "currently little endian.*$gdb_prompt $" { - set default_endian "little" - internal_pass $test - } - -re "currently big endian.*$gdb_prompt $" { - set default_endian "big" - internal_pass $test - } - } - } - - # Some architectures have extra settings that affect - # the ABI. Specify the extra testing axes in a - # declarative form. - # - # A list of {COMMAND, VAR, OPTIONS-LIST} elements. - set all_axes {} - - if {$arch == "mips"} { - lappend all_axes [list "set mips abi" mips_abi $supported_mips_abi] - lappend all_axes [list "set mipsfpu" mipsfpu $supported_mipsfpu] - } elseif {$arch == "arm"} { - lappend all_axes [list "set arm abi" arm_abi $supported_arm_abi] - lappend all_axes [list "set arm fpu" arm_fpu $supported_arm_fpu] - } - - # Run testing axis CUR_AXIS. This is a recursive - # procedure that tries all combinations of options of - # all the testing axes. - proc run_axis {all_axes cur_axis} { - if {$cur_axis == [llength $all_axes]} { - do_arch_tests - return - } - - # Unpack the axis. - set axis [lindex $all_axes $cur_axis] - set cmd [lindex $axis 0] - set var [lindex $axis 1] - set options [lindex $axis 2] - - foreach v $options { - with_test_prefix "$var=$v" { - gdb_test_no_output_osabi "$cmd $v" "$cmd" - run_axis $all_axes [expr $cur_axis + 1] - } - } - } - - run_axis $all_axes 0 - } - } - } -} - -# A test that: -# -# - ensures there's a PASS if all internal tests actually passed -# -# - ensures there's at least one test that is interpreted as a -# regression (a matching PASS->FAIL) if some of the internal tests -# failed, instead of looking like it could be a new FAIL that could -# be ignored. -# -gdb_assert {$internal_pass_count == $test_count} "all passed" diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.tcl b/gdb/testsuite/gdb.base/all-architectures.exp.tcl new file mode 100644 index 0000000..ebdd344 --- /dev/null +++ b/gdb/testsuite/gdb.base/all-architectures.exp.tcl @@ -0,0 +1,341 @@ +# Copyright (C) 2016-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 . + +# This file is part of the gdb testsuite. + +# Test manually setting _all_ combinations of all supported bfd +# architectures and OS ABIs. This ensures that gdbarch initialization +# routines handle unusual combinations gracefully, at least without +# crashing. + +# While at it, because the number of possible combinations is quite +# large, embed other checks that might be useful to do with all +# supported archs. + +# One such test is ensuring that printing float, double and long +# double types works in cross/bi-arch scenarios. Some of GDB's float +# format conversion routines used to fail to consider that even if +# host and target floating formats match, their sizes may still +# differ. E.g., on x86, long double is 80-bit extended precision on +# both 32-bit vs 64-bit, but it's stored as 96 bit on 32-bit, and 128 +# bit on 64-bit. This resulted in GDB accessing memory out of bounds. +# This test catches the issue when run against gdb linked with +# libmcheck, or run under Valgrind. + +# Note: this test is actually split in several driver .exp files, in +# order to be able to parallelize the work. Each driver .exp file +# exercises a different slice of the supported architectures. See +# all-architectures-*.exp and the TEST_SLICE variable. + +clean_restart + +# By default, preparation steps don't output a PASS message. This is +# because the testcase has several thousand such steps. +set want_tests_messages 0 + +# Call this when an "internal" preparation-like step test passed. +# Logs the pass in gdb.log, but not in gdb.sum. + +proc internal_pass {message} { + global want_tests_messages + + if {$want_tests_messages} { + pass $message + } else { + # Skip the sum file, but still log an internal pass in the log + # file. + global pf_prefix + + verbose -log "IPASS: $pf_prefix $message" + } +} + +# The number of times gdb_test_internal was called, and the number of +# time that resulted in an internal pass. If these don't match, then +# some test failed. +set test_count 0 +set internal_pass_count 0 + +# Like gdb_test, but calls internal_pass instead of pass, on success. + +proc gdb_test_internal {cmd pattern {message ""}} { + global test_count internal_pass_count + global gdb_prompt + + incr test_count + + if {$message == ""} { + set message $cmd + } + + gdb_test_multiple $cmd $message { + -re "$pattern\r\n$gdb_prompt $" { + internal_pass $message + incr internal_pass_count + } + } +} + +gdb_test_internal "set max-completions unlimited" \ + "^set max-completions unlimited" + +# Return a list of all the accepted values of "set WHAT". + +proc get_set_option_choices {what} { + global gdb_prompt + + set values {} + + set test "complete set $what" + gdb_test_multiple "complete set $what " "$test" { + -re "set $what (\[^\r\n\]+)\r\n" { + lappend values $expect_out(1,string) + exp_continue + } + -re "$gdb_prompt " { + internal_pass $test + } + } + return $values +} + +set supported_archs [get_set_option_choices "architecture"] +# There should be at least one more than "auto". +gdb_assert {[llength $supported_archs] > 1} "at least one architecture" + +set supported_osabis [get_set_option_choices "osabi"] +# There should be at least one more than "auto" and "default". +gdb_assert {[llength $supported_osabis] > 2} "at least one osabi" + +if {[lsearch $supported_archs "mips"] >= 0} { + set supported_mipsfpu [get_set_option_choices "mipsfpu"] + set supported_mips_abi [get_set_option_choices "mips abi"] + + gdb_assert {[llength $supported_mipsfpu] != 0} "at least one mipsfpu" + gdb_assert {[llength $supported_mips_abi] != 0} "at least one mips abi" +} + +if {[lsearch $supported_archs "arm"] >= 0} { + set supported_arm_fpu [get_set_option_choices "arm fpu"] + set supported_arm_abi [get_set_option_choices "arm abi"] + + gdb_assert {[llength $supported_arm_fpu] != 0} "at least one arm fpu" + gdb_assert {[llength $supported_arm_abi] != 0} "at least one arm abi" +} + +# Exercise printing float, double and long double. + +proc print_floats {} { + gdb_test_internal "ptype 1.0L" "type = long double" "ptype, long double" + gdb_test_internal "print 1.0L" " = 1" "print, long double" + + gdb_test_internal "ptype 1.0" "type = double" "ptype, double" + gdb_test_internal "print 1.0" " = 1" "print, double" + + gdb_test_internal "ptype 1.0f" "type = float" "ptype, float" + gdb_test_internal "print 1.0f" " = 1" "print, float" +} + +# Run tests on the current architecture. + +proc do_arch_tests {} { + print_floats + + # GDB can't access memory because there is no loaded executable + # nor live inferior. + gdb_test_internal "disassemble 0x0,+4" \ + "Cannot access memory at address 0x0" +} + +# Given we can't change arch, osabi, endianness, etc. atomically, we +# need to silently ignore the case of the current OS ABI (not the one +# we'll switch to) not having a handler for the arch. +set osabi_warning \ + [multi_line \ + "warning: A handler for the OS ABI .* is not built into this configuration" \ + "of GDB. Attempting to continue with the default .* settings." \ + "" \ + "" \ + ] + +set endian_warning "(Little|Big) endian target not supported by GDB\r\n" + +# Like gdb_test_no_output, but use internal_pass instead of pass, and +# ignore "no handler for OS ABI" warnings. + +proc gdb_test_no_output_osabi {cmd test} { + global osabi_warning + global gdb_prompt + + gdb_test_multiple "$cmd" $test { + -re "^${cmd}\r\n(${osabi_warning})?$gdb_prompt $" { + internal_pass $test + } + } +} + +# It'd be nicer/safer to restart GDB on each iteration, but, that +# increases the testcase's run time several times fold. At the time +# of writting, it'd jump from 20s to 4min on x86-64 GNU/Linux with +# --enable-targets=all. + +set num_slices 8 +set num_archs [llength $supported_archs] +set archs_per_slice [expr (($num_archs + $num_slices - 1) / $num_slices)] + +with_test_prefix "tests" { + foreach_with_prefix osabi $supported_osabis { + + gdb_test_no_output_osabi "set osabi $osabi" \ + "set osabi" + + set arch_count 0 + foreach_with_prefix arch $supported_archs { + + incr arch_count + + # Skip architectures outside our slice. + if {$arch_count < [expr $test_slice * $archs_per_slice]} { + continue + } + if {$arch_count >= [expr ($test_slice + 1) * $archs_per_slice]} { + continue + } + + if {$arch == "auto"} { + continue + } + set default_endian "" + foreach_with_prefix endian {"auto" "big" "little"} { + + set test "set endian" + if {$endian == $default_endian} { + continue + } elseif {$endian == "auto"} { + gdb_test_multiple "set endian $endian" $test { + -re "^set endian $endian\r\n(${osabi_warning})?The target endianness is set automatically \\(currently .* endian\\)\r\n$gdb_prompt $" { + internal_pass $test + } + } + } else { + gdb_test_multiple "set endian $endian" $test { + -re "^set endian $endian\r\n${endian_warning}.*\r\n$gdb_prompt $" { + internal_pass $test + continue + } + -re "^set endian $endian\r\n(${osabi_warning})?The target is assumed to be $endian endian\r\n$gdb_prompt $" { + internal_pass $test + } + } + } + + # Skip setting the same architecture again. + if {$endian == "auto"} { + set arch_re [string_to_regexp $arch] + set test "set architecture $arch" + gdb_test_multiple $test $test { + -re "^set architecture $arch_re\r\n(${osabi_warning})?The target architecture is assumed to be $arch_re\r\n$gdb_prompt $" { + internal_pass $test + } + -re "Architecture .* not recognized.*$gdb_prompt $" { + # GDB is missing support for a few + # machines that bfd supports. + if {$arch == "powerpc:EC603e" + || $arch == "powerpc:e500mc" + || $arch == "powerpc:e500mc64" + || $arch == "powerpc:vle" + || $arch == "powerpc:titan" + || $arch == "powerpc:e5500" + || $arch == "powerpc:e6500"} { + if {$want_tests_messages} { + kfail $test "gdb/19797" + } + } else { + fail "$test (arch not recognized)" + } + continue + } + } + + # Record what is the default endianess. As an + # optimization, we'll skip testing the manual "set + # endian DEFAULT" case. + set test "show endian" + gdb_test_multiple "show endian" $test { + -re "currently little endian.*$gdb_prompt $" { + set default_endian "little" + internal_pass $test + } + -re "currently big endian.*$gdb_prompt $" { + set default_endian "big" + internal_pass $test + } + } + } + + # Some architectures have extra settings that affect + # the ABI. Specify the extra testing axes in a + # declarative form. + # + # A list of {COMMAND, VAR, OPTIONS-LIST} elements. + set all_axes {} + + if {$arch == "mips"} { + lappend all_axes [list "set mips abi" mips_abi $supported_mips_abi] + lappend all_axes [list "set mipsfpu" mipsfpu $supported_mipsfpu] + } elseif {$arch == "arm"} { + lappend all_axes [list "set arm abi" arm_abi $supported_arm_abi] + lappend all_axes [list "set arm fpu" arm_fpu $supported_arm_fpu] + } + + # Run testing axis CUR_AXIS. This is a recursive + # procedure that tries all combinations of options of + # all the testing axes. + proc run_axis {all_axes cur_axis} { + if {$cur_axis == [llength $all_axes]} { + do_arch_tests + return + } + + # Unpack the axis. + set axis [lindex $all_axes $cur_axis] + set cmd [lindex $axis 0] + set var [lindex $axis 1] + set options [lindex $axis 2] + + foreach v $options { + with_test_prefix "$var=$v" { + gdb_test_no_output_osabi "$cmd $v" "$cmd" + run_axis $all_axes [expr $cur_axis + 1] + } + } + } + + run_axis $all_axes 0 + } + } + } +} + +# A test that: +# +# - ensures there's a PASS if all internal tests actually passed +# +# - ensures there's at least one test that is interpreted as a +# regression (a matching PASS->FAIL) if some of the internal tests +# failed, instead of looking like it could be a new FAIL that could +# be ignored. +# +gdb_assert {$internal_pass_count == $test_count} "all passed" diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp b/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp index 9da0621..4741e0d 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp +++ b/gdb/testsuite/gdb.base/infcall-nested-structs-c++.exp @@ -21,4 +21,4 @@ if { [skip_cplus_tests] || [get_compiler_info "c++"] } { } set lang c++ -source $srcdir/$subdir/infcall-nested-structs.exp.in +source $srcdir/$subdir/infcall-nested-structs.exp.tcl diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp b/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp index a715c5b..1e876e3 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp +++ b/gdb/testsuite/gdb.base/infcall-nested-structs-c.exp @@ -17,4 +17,4 @@ set lang {c} -source $srcdir/$subdir/infcall-nested-structs.exp.in +source $srcdir/$subdir/infcall-nested-structs.exp.tcl diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.in b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.in deleted file mode 100644 index f740961..0000000 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.in +++ /dev/null @@ -1,184 +0,0 @@ -# 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 . - -# 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] - } - } -} diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl new file mode 100644 index 0000000..f740961 --- /dev/null +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl @@ -0,0 +1,184 @@ +# 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 . + +# 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] + } + } +} diff --git a/gdb/testsuite/gdb.base/info-types-c++.exp b/gdb/testsuite/gdb.base/info-types-c++.exp index 4f44369..587a39f 100644 --- a/gdb/testsuite/gdb.base/info-types-c++.exp +++ b/gdb/testsuite/gdb.base/info-types-c++.exp @@ -19,4 +19,4 @@ if { [skip_cplus_tests] || [get_compiler_info "c++"] } { } set lang c++ -source $srcdir/$subdir/info-types.exp.in +source $srcdir/$subdir/info-types.exp.tcl diff --git a/gdb/testsuite/gdb.base/info-types-c.exp b/gdb/testsuite/gdb.base/info-types-c.exp index 800d638..0b6e81d 100644 --- a/gdb/testsuite/gdb.base/info-types-c.exp +++ b/gdb/testsuite/gdb.base/info-types-c.exp @@ -15,4 +15,4 @@ set lang {c} -source $srcdir/$subdir/info-types.exp.in +source $srcdir/$subdir/info-types.exp.tcl diff --git a/gdb/testsuite/gdb.base/info-types.exp.in b/gdb/testsuite/gdb.base/info-types.exp.in deleted file mode 100644 index 8c065b1..0000000 --- a/gdb/testsuite/gdb.base/info-types.exp.in +++ /dev/null @@ -1,130 +0,0 @@ -# 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 . - -# 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 diff --git a/gdb/testsuite/gdb.base/info-types.exp.tcl b/gdb/testsuite/gdb.base/info-types.exp.tcl new file mode 100644 index 0000000..8c065b1 --- /dev/null +++ b/gdb/testsuite/gdb.base/info-types.exp.tcl @@ -0,0 +1,130 @@ +# 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 . + +# 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 diff --git a/gdb/testsuite/gdb.base/max-depth-c++.exp b/gdb/testsuite/gdb.base/max-depth-c++.exp index b88b2c1..9f732d0 100644 --- a/gdb/testsuite/gdb.base/max-depth-c++.exp +++ b/gdb/testsuite/gdb.base/max-depth-c++.exp @@ -19,4 +19,4 @@ if { [skip_cplus_tests] || [get_compiler_info "c++"] } { } set lang c++ -source $srcdir/$subdir/max-depth.exp.in +source $srcdir/$subdir/max-depth.exp.tcl diff --git a/gdb/testsuite/gdb.base/max-depth-c.exp b/gdb/testsuite/gdb.base/max-depth-c.exp index 3bd9309..7657720 100644 --- a/gdb/testsuite/gdb.base/max-depth-c.exp +++ b/gdb/testsuite/gdb.base/max-depth-c.exp @@ -15,4 +15,4 @@ set lang {c} -source $srcdir/$subdir/max-depth.exp.in +source $srcdir/$subdir/max-depth.exp.tcl diff --git a/gdb/testsuite/gdb.base/max-depth.exp.in b/gdb/testsuite/gdb.base/max-depth.exp.in deleted file mode 100644 index 8c0d712..0000000 --- a/gdb/testsuite/gdb.base/max-depth.exp.in +++ /dev/null @@ -1,151 +0,0 @@ -# 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 . - -# 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" { "{...}" \ - "{ = {...}, c3 = 3}" \ - "{ = {c2 = 2}, c3 = 3}" } - gdb_print_expr_at_depths "c4" { "{...}" "{c4 = 4}" } - gdb_print_expr_at_depths "c5" { "{...}" \ - "{ = {...}, c5 = 5}" \ - "{ = {c4 = 4}, c5 = 5}" } - gdb_print_expr_at_depths "c6" { "{...}" \ - "{ = {...}, c6 = 6}" \ - "{ = { = {...}, c5 = 5}, c6 = 6}" \ - "{ = { = {c4 = 4}, c5 = 5}, c6 = 6}" } - gdb_print_expr_at_depths "c7" { "{...}" \ - "{ = {...}, = {...}, = {...}, c7 = 7}" \ - "{ = {c1 = 1}, = { = {...}, c3 = 3}, = { = {...}, c6 = 6}, c7 = 7}" \ - "{ = {c1 = 1}, = { = {c2 = 2}, c3 = 3}, = { = { = {...}, c5 = 5}, c6 = 6}, c7 = 7}" \ - "{ = {c1 = 1}, = { = {c2 = 2}, c3 = 3}, = { = { = {c4 = 4}, c5 = 5}, c6 = 6}, c7 = 7}" } - - gdb_print_expr_at_depths "v1" [list "{...}" "{v1 = 1}" ] - gdb_print_expr_at_depths "v2" [list "{...}" \ - "{ = {...}, _vptr.V2 = $hex , v2 = 2}" \ - "{ = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}" ] - gdb_print_expr_at_depths "v3" [list "{...}" \ - "{ = {...}, _vptr.V3 = $hex , v3 = 3}" \ - "{ = {v1 = 1}, _vptr.V3 = $hex , v3 = 3}" ] - gdb_print_expr_at_depths "v4" [list "{...}" \ - "{ = {...}, _vptr.V4 = $hex \]+>, v4 = 4}" \ - "{ = { = {...}, _vptr.V2 = $hex , v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}" \ - "{ = { = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}" ] - gdb_print_expr_at_depths "v5" [list "{...}" \ - "{ = {...}, _vptr.V5 = $hex \]+>, v5 = 1}" \ - "{ = { = {...}, _vptr.V2 = $hex , v2 = 2}, _vptr.V5 = $hex \]+>, v5 = 1}" \ - "{ = { = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}, _vptr.V5 = $hex \]+>, v5 = 1}" ] - gdb_print_expr_at_depths "v6" [list "{...}" \ - "{ = {...}, = {...}, _vptr.V6 = $hex \]+>, v6 = 1}" \ - "{ = { = {...}, _vptr.V2 = $hex \]+>, v2 = 2}, = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}" \ - "{ = { = {v1 = 1}, _vptr.V2 = $hex \]+>, v2 = 2}, = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}" ] - gdb_print_expr_at_depths "v7" [list "{...}" \ - "{ = {...}, = {...}, = {...}, _vptr.V7 = $hex \]+>, v7 = 1}" \ - "{ = { = {...}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {...}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" \ - "{ = { = { = {...}, _vptr.V2 = $hex \]+>, v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" \ - "{ = { = { = {v1 = 1}, _vptr.V2 = $hex \]+>, v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" ] - } -} - -compile_and_run_tests $lang diff --git a/gdb/testsuite/gdb.base/max-depth.exp.tcl b/gdb/testsuite/gdb.base/max-depth.exp.tcl new file mode 100644 index 0000000..8c0d712 --- /dev/null +++ b/gdb/testsuite/gdb.base/max-depth.exp.tcl @@ -0,0 +1,151 @@ +# 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 . + +# 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" { "{...}" \ + "{ = {...}, c3 = 3}" \ + "{ = {c2 = 2}, c3 = 3}" } + gdb_print_expr_at_depths "c4" { "{...}" "{c4 = 4}" } + gdb_print_expr_at_depths "c5" { "{...}" \ + "{ = {...}, c5 = 5}" \ + "{ = {c4 = 4}, c5 = 5}" } + gdb_print_expr_at_depths "c6" { "{...}" \ + "{ = {...}, c6 = 6}" \ + "{ = { = {...}, c5 = 5}, c6 = 6}" \ + "{ = { = {c4 = 4}, c5 = 5}, c6 = 6}" } + gdb_print_expr_at_depths "c7" { "{...}" \ + "{ = {...}, = {...}, = {...}, c7 = 7}" \ + "{ = {c1 = 1}, = { = {...}, c3 = 3}, = { = {...}, c6 = 6}, c7 = 7}" \ + "{ = {c1 = 1}, = { = {c2 = 2}, c3 = 3}, = { = { = {...}, c5 = 5}, c6 = 6}, c7 = 7}" \ + "{ = {c1 = 1}, = { = {c2 = 2}, c3 = 3}, = { = { = {c4 = 4}, c5 = 5}, c6 = 6}, c7 = 7}" } + + gdb_print_expr_at_depths "v1" [list "{...}" "{v1 = 1}" ] + gdb_print_expr_at_depths "v2" [list "{...}" \ + "{ = {...}, _vptr.V2 = $hex , v2 = 2}" \ + "{ = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}" ] + gdb_print_expr_at_depths "v3" [list "{...}" \ + "{ = {...}, _vptr.V3 = $hex , v3 = 3}" \ + "{ = {v1 = 1}, _vptr.V3 = $hex , v3 = 3}" ] + gdb_print_expr_at_depths "v4" [list "{...}" \ + "{ = {...}, _vptr.V4 = $hex \]+>, v4 = 4}" \ + "{ = { = {...}, _vptr.V2 = $hex , v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}" \ + "{ = { = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}" ] + gdb_print_expr_at_depths "v5" [list "{...}" \ + "{ = {...}, _vptr.V5 = $hex \]+>, v5 = 1}" \ + "{ = { = {...}, _vptr.V2 = $hex , v2 = 2}, _vptr.V5 = $hex \]+>, v5 = 1}" \ + "{ = { = {v1 = 1}, _vptr.V2 = $hex , v2 = 2}, _vptr.V5 = $hex \]+>, v5 = 1}" ] + gdb_print_expr_at_depths "v6" [list "{...}" \ + "{ = {...}, = {...}, _vptr.V6 = $hex \]+>, v6 = 1}" \ + "{ = { = {...}, _vptr.V2 = $hex \]+>, v2 = 2}, = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}" \ + "{ = { = {v1 = 1}, _vptr.V2 = $hex \]+>, v2 = 2}, = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}" ] + gdb_print_expr_at_depths "v7" [list "{...}" \ + "{ = {...}, = {...}, = {...}, _vptr.V7 = $hex \]+>, v7 = 1}" \ + "{ = { = {...}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {...}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" \ + "{ = { = { = {...}, _vptr.V2 = $hex \]+>, v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" \ + "{ = { = { = {v1 = 1}, _vptr.V2 = $hex \]+>, v2 = 2}, _vptr.V4 = $hex \]+>, v4 = 4}, = {_vptr.V5 = $hex \]+>, v5 = 1}, = { = {_vptr.V3 = $hex , v3 = 3}, _vptr.V6 = $hex \]+>, v6 = 1}, _vptr.V7 = $hex \]+>, v7 = 1}" ] + } +} + +compile_and_run_tests $lang diff --git a/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp b/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp index b93f2e8..ece7bc9 100644 --- a/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp +++ b/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp @@ -17,4 +17,4 @@ # Run cpexprs.exp with -fdebug-types-section. set flags {additional_flags=-fdebug-types-section} -source $srcdir/$subdir/cpexprs.exp.in +source $srcdir/$subdir/cpexprs.exp.tcl diff --git a/gdb/testsuite/gdb.cp/cpexprs.exp b/gdb/testsuite/gdb.cp/cpexprs.exp index b16a5ea..62f13a3 100644 --- a/gdb/testsuite/gdb.cp/cpexprs.exp +++ b/gdb/testsuite/gdb.cp/cpexprs.exp @@ -21,4 +21,4 @@ # Run cpexprs.exp. set flags {} -source $srcdir/$subdir/cpexprs.exp.in +source $srcdir/$subdir/cpexprs.exp.tcl diff --git a/gdb/testsuite/gdb.cp/cpexprs.exp.in b/gdb/testsuite/gdb.cp/cpexprs.exp.in deleted file mode 100644 index ef30215..0000000 --- a/gdb/testsuite/gdb.cp/cpexprs.exp.in +++ /dev/null @@ -1,761 +0,0 @@ -# cpexprs.exp - C++ expressions tests -# -# Copyright 2008-2020 Free Software Foundation, Inc. -# -# Contributed by Red Hat, originally written by Keith Seitz. -# -# 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 . - -# This file is part of the gdb testsuite. - -# A helper proc which sets a breakpoint at FUNC and attempts to -# run to the breakpoint. -proc test_breakpoint {func} { - global DEC - - # Return to the top of the test function every time. - delete_breakpoints - if { ! [gdb_breakpoint test_function] } { - fail "set test_function breakpoint for $func" - } elseif { [gdb_test "continue" \ - "Continuing.\r\n\r\nBreakpoint $DEC+,.*test_function.*" \ - ""] != 0 } { - fail "continue to test_function for $func" - } else { - gdb_breakpoint "$func" - set i [expr {[string last : $func] + 1}] - set efunc [string_to_regexp [string range $func $i end]] - gdb_test "continue" \ - "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ - "continue to $func" - } -} - -# Add a function to the list of tested functions -# FUNC is the name of the function (which will be passed to gdb commands) -# TYPE is the type of the function, as expected from the "print" command -# PRINT is the name of the function, as expected result of the print command -# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited -# funcs) -# LST is either the expected result of the list command (the comment from -# the source code) *OR* "-", in which case FUNC will be used -# -# Usage: -# add NAME TYPE PRINT LST -# add NAME TYPE PRINT - -proc add_type_regexp {func type print lst} { - global all_functions CONVAR ADDR - - set all_functions($func,type) $type - if {$print == "-"} { - set print $func - } - - # An exception: since gdb canonicalizes C++ output, - # "(void)" must be mutated to "()". - regsub {\(void\)} $print {()} print - - set all_functions($func,print) \ - "$CONVAR = {$type} $ADDR <[string_to_regexp $print].*>" - if {$lst == "-"} { - set lst "$func" - } - set all_functions($func,list) ".*// [string_to_regexp $lst]" -} - -proc add {func type print lst} { - add_type_regexp $func [string_to_regexp $type] $print $lst -} - -proc get {func cmd} { - global all_functions - return $all_functions($func,$cmd) -} - -# Returns a list of function names for a given command -proc get_functions {cmd} { - global all_functions - set result {} - foreach i [array names all_functions *,$cmd] { - if {$all_functions($i) != ""} { - set idx [string last , $i] - if {$idx != -1} { - lappend result [string range $i 0 [expr {$idx - 1}]] - } - } - } - - return [lsort $result] -} - -# Some convenience variables for this test -set DEC {[0-9]}; # a decimal number -set HEX {[0-9a-fA-F]}; # a hexidecimal number -set CONVAR "\\\$$DEC+"; # convenience variable regexp -set ADDR "0x$HEX+"; # address - -# An array of functions/methods that we are testing... -# Each element consists is indexed by NAME,COMMAND, where -# NAME is the function name and COMMAND is the gdb command that -# we are testing. The value of the array for any index pair is -# the expected result of running COMMAND with the NAME as argument. - -# The array holding all functions/methods to test. Valid subindexes -# are (none need character escaping -- "add" will take care of that): - -# add name type print_name list -# NAME,type: value is type of function -# NAME,print: value is print name of function (careful w/inherited/virtual!) -# NAME,list: value is comment in source code on first line of function -# (without the leading "//") -array set all_functions {} - -# "Normal" functions/methods -add {test_function} \ - {int (int, char **)} \ - - \ - - -add {derived::a_function} \ - {void (const derived * const)} \ - - \ - - -add {base1::a_function} \ - {void (const base1 * const)} \ - - \ - - -add {base2::a_function} \ - {void (const base2 * const)} \ - - \ - - - -# Constructors - -# On targets using the ARM EABI, the constructor is expected to return -# "this". -proc ctor_ret { type } { - if { [istarget arm*-*eabi*] || [is_aarch32_target] } { - return "$type *" - } else { - return "void " - } -} - -proc ctor_prefix { type } { - set ret [ctor_ret $type] - return "${ret}($type * const" -} - -proc ctor { type arglist } { - if { $arglist != "" } { - set arglist ", $arglist" - } - return "[ctor_prefix $type]$arglist)" -} - -add {derived::derived} \ - [ctor derived ""] \ - - \ - - -add_type_regexp {base1::base1(void)} \ - "[string_to_regexp [ctor_prefix base1]], (const )?void \\*\\*( const)?\\)" \ - - \ - - -add {base1::base1(int)} \ - [ctor base1 "int"] \ - - \ - - -add_type_regexp {base2::base2} \ - "[string_to_regexp [ctor_prefix base2]], (const )?void \\*\\*( const)?\\)" \ - - \ - - -add {base::base(void)} \ - [ctor base ""] \ - - \ - - -add {base::base(int)} \ - [ctor base "int"] \ - - \ - - - -# Destructors - -# On targets using the ARM EABI, some destructors are expected -# to return "this". Others are void. For internal reasons, -# GCC returns void * instead of $type *; RealView appears to do -# the same. -proc dtor { type } { - if { [istarget arm*-*eabi*] || [is_aarch32_target] } { - set ret "void *" - } else { - set ret "void " - } - return "${ret}($type * const)" -} - -add {base::~base} \ - [dtor base] \ - - \ - - - -# Overloaded methods (all are const) -add {base::overload(void) const} \ - {int (const base * const)} \ - - \ - {base::overload(void) const} -add {base::overload(int) const} \ - {int (const base * const, int)} \ - - \ - - -add {base::overload(short) const} \ - {int (const base * const, short)} \ - - \ - - -add {base::overload(long) const} \ - {int (const base * const, long)} \ - - \ - - -add {base::overload(char*) const} \ - {int (const base * const, char *)} \ - - \ - - -add {base::overload(base&) const} \ - {int (const base * const, base &)} \ - - \ - - - -# Operators -add {base::operator+} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator++} \ - {base (base * const)} \ - - \ - - -add {base::operator+=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator-} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator--} \ - {base (base * const)} \ - - \ - - -add {base::operator-=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator*} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator*=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator/} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator/=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator%} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator%=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator<} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator<=} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator>} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator>=} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator!=} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator==} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator!} \ - {bool (const base * const)} \ - - \ - - -add {base::operator&&} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator||} \ - {bool (const base * const, const base &)} \ - - \ - - -add {base::operator<<} \ - {int (const base * const, int)} \ - - \ - - -add {base::operator<<=} \ - {base (base * const, int)} \ - - \ - - -add {base::operator>>} \ - {int (const base * const, int)} \ - - \ - - -add {base::operator>>=} \ - {base (base * const, int)} \ - - \ - - -add {base::operator~} \ - {int (const base * const)} \ - - \ - - -add {base::operator&} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator&=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator|} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator|=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator^} \ - {int (const base * const, const base &)} \ - - \ - - -add {base::operator^=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator=} \ - {base (base * const, const base &)} \ - - \ - - -add {base::operator()} \ - {void (const base * const)} \ - - \ - - -add {base::operator[]} \ - {int (const base * const, int)} \ - - \ - - -add {base::operator new} \ - {void *(size_t)} \ - - \ - - -add {base::operator delete} \ - {void (void *)} \ - - \ - - -add {base::operator new[]} \ - {void *(size_t)} \ - - \ - - -add {base::operator delete[]} \ - {void (void *)} \ - - \ - - -add {base::operator char*} \ - {char *(const base * const)} \ - - \ - - -add {base::operator fluff*} \ - {fluff *(const base * const)} \ - - \ - - -add {base::operator fluff**} \ - {fluff **(const base * const)} \ - - \ - - -add {base::operator int} \ - {int (const base * const)} \ - - \ - - -add {base::operator fluff const* const*} \ - {const fluff * const *(const base * const)} \ - - \ - - - -# Templates -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - - -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - - -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - - -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - - -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - - -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {flubber} \ - {void (void)} \ - - \ - flubber -add {tclass::do_something} \ - {void (tclass * const)} \ - - \ - {tclass::do_something} -add {policy1::policy} \ - [ctor "policy >" "int"] \ - {policy >::policy} \ - {policy::policy} -add {policy2::policy} \ - [ctor "policy >" int] \ - {policy >::policy} \ - {policy::policy} -add {policy3::policy} \ - [ctor "policy >" "int"] \ - {policy >::policy} \ - {policy::policy} -add {policy4::policy} \ - [ctor "policy >" "int"] \ - {policy >::policy} \ - {policy::policy} -add {policy1::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policy2::function} \ - {void (void)} \ - {operation_2::function} \ - {operation_2::function} -add {policy3::function} \ - {void (void)} \ - {operation_3::function} \ - {operation_3::function} -add {policy4::function} \ - {void (void)} \ - {operation_4::function} \ - {operation_4::function} -add {policyd >::policyd} \ - [ctor "policyd >" "int"] \ - - \ - {policyd::policyd} -add {policyd1::policyd} \ - [ctor "policyd >" "int"] \ - {policyd >::policyd} \ - {policyd::policyd} -add {policyd >::~policyd} \ - [dtor "policyd >"] \ - - \ - {policyd::~policyd} -add {policyd1::~policyd} \ - [dtor "policyd >"] \ - {policyd >::~policyd} \ - {policyd::~policyd} -add {policyd >::policyd} \ - [ctor "policyd >" "long"] \ - - \ - {policyd::policyd} -add {policyd2::policyd} \ - [ctor "policyd >" "long"] \ - {policyd >::policyd} \ - {policyd::policyd} -add {policyd >::~policyd} \ - [dtor "policyd >"] \ - - \ - {policyd::~policyd} -add {policyd2::~policyd} \ - [dtor "policyd >"] \ - {policyd >::~policyd} \ - {policyd::~policyd} -add {policyd >::policyd} \ - [ctor "policyd >" "char"] \ - - \ - {policyd::policyd} -add {policyd3::policyd} \ - [ctor "policyd >" "char"] \ - {policyd >::policyd} \ - {policyd::policyd} -add {policyd >::~policyd} \ - [dtor "policyd >"] \ - - \ - {policyd::~policyd} -add {policyd3::~policyd} \ - [dtor "policyd >"] \ - {policyd >::~policyd} \ - {policyd::~policyd} -add {policyd >::policyd} \ - [ctor "policyd >" "base"] \ - - \ - {policyd::policyd} -add {policyd4::policyd} \ - [ctor "policyd >" "base"] \ - {policyd >::policyd} \ - {policyd::policyd} -add {policyd >::~policyd} \ - [dtor "policyd >"] \ - - \ - {policyd::~policyd} -add {policyd4::~policyd} \ - [dtor "policyd >"] \ - {policyd >::~policyd} \ - {policyd::~policyd} -add {policyd, operation_1 > >::policyd} \ - [ctor "policyd, operation_1 > >" "tclass"] \ - - \ - {policyd::policyd} -add {policyd5::policyd} \ - [ctor "policyd, operation_1 > >" "tclass"] \ - {policyd, operation_1 > >::policyd} \ - {policyd::policyd} -add {policyd, operation_1 > >::~policyd} \ - [dtor "policyd, operation_1 > >"] \ - - \ - {policyd::~policyd} -add {policyd5::~policyd} \ - [dtor "policyd, operation_1 > >"] \ - {policyd, operation_1 > >::~policyd} \ - {policyd::~policyd} -add {policyd >::function} \ - {void (void)} \ - {operation_1::function}\ - {operation_1::function} -add {policyd1::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd2::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd >::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd3::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd >::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd4::function} \ - {void (void)} \ - {operation_1::function} \ - {operation_1::function} -add {policyd, operation_1 > >::function} \ - {void (void)} \ - {operation_1 >::function} \ - {operation_1::function} -add {policyd5::function} \ - {void (void)} \ - {operation_1 >::function} \ - {operation_1::function} - -# Start the test -if {[skip_cplus_tests]} { continue } - -# -# test running programs -# - -standard_testfile cpexprs.cc - -if {[get_compiler_info "c++"]} { - return -1 -} - -# Include required flags. -set flags "$flags debug c++" - -if {[prepare_for_testing "failed to prepare" $testfile $srcfile "$flags"]} { - return -1 -} - -if {![runto_main]} { - perror "couldn't run to breakpoint" - continue -} - -# Set the listsize to one. This will help with testing "list". -gdb_test "set listsize 1" - -# "print METHOD" -foreach name [get_functions print] { - gdb_test "print $name" [get $name print] -} - -# "list METHOD" -foreach name [get_functions list] { - gdb_test "list $name" [get $name list] -} - -# Running to breakpoint -- use any function we can "list" -foreach name [get_functions list] { - # Skip "test_function", since test_breakpoint uses it - if {[string compare $name "test_function"] != 0} { - test_breakpoint $name - } -} - -# Test c/v gets recognized even without quoting. -foreach cv {{} { const} { volatile} { const volatile}} { - set test "p 'CV::m(int)$cv'" - gdb_test_multiple $test $test { - -re "( = {.*} 0x\[0-9a-f\]+ )\r\n$gdb_prompt $" { - # = {void (CV * const, CV::t)} 0x400944 - set correct $expect_out(1,string) - pass $test - } - } - gdb_test "p CV::m(int)$cv" [string_to_regexp $correct] -} - -# Test TYPENAME:: gets recognized even in parentheses. -gdb_test "p CV_f(int)" { = {int \(int\)} 0x[0-9a-f]+ } -gdb_test "p CV_f(CV::t)" { = {int \(int\)} 0x[0-9a-f]+ } -gdb_test "p CV_f(CV::i)" " = 43" - -gdb_test "p CV_f('cpexprs.cc'::CV::t)" \ - { = {int \(int\)} 0x[0-9a-f]+ } - -# Make sure conversion operator names are canonicalized and properly -# "spelled." -gdb_test "p base::operator const fluff * const *" \ - [get "base::operator fluff const* const*" print] \ - "canonicalized conversion operator name 1" -gdb_test "p base::operator const fluff* const*" \ - [get "base::operator fluff const* const*" print] \ - "canonicalized conversion operator name 2" -gdb_test "p base::operator derived*" \ - "There is no field named operator derived\\*" \ - "undefined conversion operator" - -gdb_exit -return 0 diff --git a/gdb/testsuite/gdb.cp/cpexprs.exp.tcl b/gdb/testsuite/gdb.cp/cpexprs.exp.tcl new file mode 100644 index 0000000..ef30215 --- /dev/null +++ b/gdb/testsuite/gdb.cp/cpexprs.exp.tcl @@ -0,0 +1,761 @@ +# cpexprs.exp - C++ expressions tests +# +# Copyright 2008-2020 Free Software Foundation, Inc. +# +# Contributed by Red Hat, originally written by Keith Seitz. +# +# 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 . + +# This file is part of the gdb testsuite. + +# A helper proc which sets a breakpoint at FUNC and attempts to +# run to the breakpoint. +proc test_breakpoint {func} { + global DEC + + # Return to the top of the test function every time. + delete_breakpoints + if { ! [gdb_breakpoint test_function] } { + fail "set test_function breakpoint for $func" + } elseif { [gdb_test "continue" \ + "Continuing.\r\n\r\nBreakpoint $DEC+,.*test_function.*" \ + ""] != 0 } { + fail "continue to test_function for $func" + } else { + gdb_breakpoint "$func" + set i [expr {[string last : $func] + 1}] + set efunc [string_to_regexp [string range $func $i end]] + gdb_test "continue" \ + "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ + "continue to $func" + } +} + +# Add a function to the list of tested functions +# FUNC is the name of the function (which will be passed to gdb commands) +# TYPE is the type of the function, as expected from the "print" command +# PRINT is the name of the function, as expected result of the print command +# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited +# funcs) +# LST is either the expected result of the list command (the comment from +# the source code) *OR* "-", in which case FUNC will be used +# +# Usage: +# add NAME TYPE PRINT LST +# add NAME TYPE PRINT - +proc add_type_regexp {func type print lst} { + global all_functions CONVAR ADDR + + set all_functions($func,type) $type + if {$print == "-"} { + set print $func + } + + # An exception: since gdb canonicalizes C++ output, + # "(void)" must be mutated to "()". + regsub {\(void\)} $print {()} print + + set all_functions($func,print) \ + "$CONVAR = {$type} $ADDR <[string_to_regexp $print].*>" + if {$lst == "-"} { + set lst "$func" + } + set all_functions($func,list) ".*// [string_to_regexp $lst]" +} + +proc add {func type print lst} { + add_type_regexp $func [string_to_regexp $type] $print $lst +} + +proc get {func cmd} { + global all_functions + return $all_functions($func,$cmd) +} + +# Returns a list of function names for a given command +proc get_functions {cmd} { + global all_functions + set result {} + foreach i [array names all_functions *,$cmd] { + if {$all_functions($i) != ""} { + set idx [string last , $i] + if {$idx != -1} { + lappend result [string range $i 0 [expr {$idx - 1}]] + } + } + } + + return [lsort $result] +} + +# Some convenience variables for this test +set DEC {[0-9]}; # a decimal number +set HEX {[0-9a-fA-F]}; # a hexidecimal number +set CONVAR "\\\$$DEC+"; # convenience variable regexp +set ADDR "0x$HEX+"; # address + +# An array of functions/methods that we are testing... +# Each element consists is indexed by NAME,COMMAND, where +# NAME is the function name and COMMAND is the gdb command that +# we are testing. The value of the array for any index pair is +# the expected result of running COMMAND with the NAME as argument. + +# The array holding all functions/methods to test. Valid subindexes +# are (none need character escaping -- "add" will take care of that): + +# add name type print_name list +# NAME,type: value is type of function +# NAME,print: value is print name of function (careful w/inherited/virtual!) +# NAME,list: value is comment in source code on first line of function +# (without the leading "//") +array set all_functions {} + +# "Normal" functions/methods +add {test_function} \ + {int (int, char **)} \ + - \ + - +add {derived::a_function} \ + {void (const derived * const)} \ + - \ + - +add {base1::a_function} \ + {void (const base1 * const)} \ + - \ + - +add {base2::a_function} \ + {void (const base2 * const)} \ + - \ + - + +# Constructors + +# On targets using the ARM EABI, the constructor is expected to return +# "this". +proc ctor_ret { type } { + if { [istarget arm*-*eabi*] || [is_aarch32_target] } { + return "$type *" + } else { + return "void " + } +} + +proc ctor_prefix { type } { + set ret [ctor_ret $type] + return "${ret}($type * const" +} + +proc ctor { type arglist } { + if { $arglist != "" } { + set arglist ", $arglist" + } + return "[ctor_prefix $type]$arglist)" +} + +add {derived::derived} \ + [ctor derived ""] \ + - \ + - +add_type_regexp {base1::base1(void)} \ + "[string_to_regexp [ctor_prefix base1]], (const )?void \\*\\*( const)?\\)" \ + - \ + - +add {base1::base1(int)} \ + [ctor base1 "int"] \ + - \ + - +add_type_regexp {base2::base2} \ + "[string_to_regexp [ctor_prefix base2]], (const )?void \\*\\*( const)?\\)" \ + - \ + - +add {base::base(void)} \ + [ctor base ""] \ + - \ + - +add {base::base(int)} \ + [ctor base "int"] \ + - \ + - + +# Destructors + +# On targets using the ARM EABI, some destructors are expected +# to return "this". Others are void. For internal reasons, +# GCC returns void * instead of $type *; RealView appears to do +# the same. +proc dtor { type } { + if { [istarget arm*-*eabi*] || [is_aarch32_target] } { + set ret "void *" + } else { + set ret "void " + } + return "${ret}($type * const)" +} + +add {base::~base} \ + [dtor base] \ + - \ + - + +# Overloaded methods (all are const) +add {base::overload(void) const} \ + {int (const base * const)} \ + - \ + {base::overload(void) const} +add {base::overload(int) const} \ + {int (const base * const, int)} \ + - \ + - +add {base::overload(short) const} \ + {int (const base * const, short)} \ + - \ + - +add {base::overload(long) const} \ + {int (const base * const, long)} \ + - \ + - +add {base::overload(char*) const} \ + {int (const base * const, char *)} \ + - \ + - +add {base::overload(base&) const} \ + {int (const base * const, base &)} \ + - \ + - + +# Operators +add {base::operator+} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator++} \ + {base (base * const)} \ + - \ + - +add {base::operator+=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator-} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator--} \ + {base (base * const)} \ + - \ + - +add {base::operator-=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator*} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator*=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator/} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator/=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator%} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator%=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator<} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator==} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!} \ + {bool (const base * const)} \ + - \ + - +add {base::operator&&} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator||} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<<} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator<<=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator>>} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator>>=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator~} \ + {int (const base * const)} \ + - \ + - +add {base::operator&} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator&=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator|} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator|=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator^} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator^=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator()} \ + {void (const base * const)} \ + - \ + - +add {base::operator[]} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator new} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete} \ + {void (void *)} \ + - \ + - +add {base::operator new[]} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete[]} \ + {void (void *)} \ + - \ + - +add {base::operator char*} \ + {char *(const base * const)} \ + - \ + - +add {base::operator fluff*} \ + {fluff *(const base * const)} \ + - \ + - +add {base::operator fluff**} \ + {fluff **(const base * const)} \ + - \ + - +add {base::operator int} \ + {int (const base * const)} \ + - \ + - +add {base::operator fluff const* const*} \ + {const fluff * const *(const base * const)} \ + - \ + - + +# Templates +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + {tclass::do_something} +add {policy1::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy2::policy} \ + [ctor "policy >" int] \ + {policy >::policy} \ + {policy::policy} +add {policy3::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy4::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policy2::function} \ + {void (void)} \ + {operation_2::function} \ + {operation_2::function} +add {policy3::function} \ + {void (void)} \ + {operation_3::function} \ + {operation_3::function} +add {policy4::function} \ + {void (void)} \ + {operation_4::function} \ + {operation_4::function} +add {policyd >::policyd} \ + [ctor "policyd >" "int"] \ + - \ + {policyd::policyd} +add {policyd1::policyd} \ + [ctor "policyd >" "int"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd1::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "long"] \ + - \ + {policyd::policyd} +add {policyd2::policyd} \ + [ctor "policyd >" "long"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd2::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "char"] \ + - \ + {policyd::policyd} +add {policyd3::policyd} \ + [ctor "policyd >" "char"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd3::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "base"] \ + - \ + {policyd::policyd} +add {policyd4::policyd} \ + [ctor "policyd >" "base"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd4::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd, operation_1 > >::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + - \ + {policyd::policyd} +add {policyd5::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + {policyd, operation_1 > >::policyd} \ + {policyd::policyd} +add {policyd, operation_1 > >::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + - \ + {policyd::~policyd} +add {policyd5::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + {policyd, operation_1 > >::~policyd} \ + {policyd::~policyd} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function}\ + {operation_1::function} +add {policyd1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd2::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd3::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd4::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd, operation_1 > >::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} +add {policyd5::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} + +# Start the test +if {[skip_cplus_tests]} { continue } + +# +# test running programs +# + +standard_testfile cpexprs.cc + +if {[get_compiler_info "c++"]} { + return -1 +} + +# Include required flags. +set flags "$flags debug c++" + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile "$flags"]} { + return -1 +} + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# Set the listsize to one. This will help with testing "list". +gdb_test "set listsize 1" + +# "print METHOD" +foreach name [get_functions print] { + gdb_test "print $name" [get $name print] +} + +# "list METHOD" +foreach name [get_functions list] { + gdb_test "list $name" [get $name list] +} + +# Running to breakpoint -- use any function we can "list" +foreach name [get_functions list] { + # Skip "test_function", since test_breakpoint uses it + if {[string compare $name "test_function"] != 0} { + test_breakpoint $name + } +} + +# Test c/v gets recognized even without quoting. +foreach cv {{} { const} { volatile} { const volatile}} { + set test "p 'CV::m(int)$cv'" + gdb_test_multiple $test $test { + -re "( = {.*} 0x\[0-9a-f\]+ )\r\n$gdb_prompt $" { + # = {void (CV * const, CV::t)} 0x400944 + set correct $expect_out(1,string) + pass $test + } + } + gdb_test "p CV::m(int)$cv" [string_to_regexp $correct] +} + +# Test TYPENAME:: gets recognized even in parentheses. +gdb_test "p CV_f(int)" { = {int \(int\)} 0x[0-9a-f]+ } +gdb_test "p CV_f(CV::t)" { = {int \(int\)} 0x[0-9a-f]+ } +gdb_test "p CV_f(CV::i)" " = 43" + +gdb_test "p CV_f('cpexprs.cc'::CV::t)" \ + { = {int \(int\)} 0x[0-9a-f]+ } + +# Make sure conversion operator names are canonicalized and properly +# "spelled." +gdb_test "p base::operator const fluff * const *" \ + [get "base::operator fluff const* const*" print] \ + "canonicalized conversion operator name 1" +gdb_test "p base::operator const fluff* const*" \ + [get "base::operator fluff const* const*" print] \ + "canonicalized conversion operator name 2" +gdb_test "p base::operator derived*" \ + "There is no field named operator derived\\*" \ + "undefined conversion operator" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d0.exp b/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d0.exp index f06ab08..806d03b 100644 --- a/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d0.exp +++ b/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d0.exp @@ -22,4 +22,4 @@ set lang {c++} set debug nodebug -source $srcdir/$subdir/infcall-nodebug.exp.in +source $srcdir/$subdir/infcall-nodebug.exp.tcl diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d1.exp b/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d1.exp index d9dd14f..dfafe52 100644 --- a/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d1.exp +++ b/gdb/testsuite/gdb.cp/infcall-nodebug-c++-d1.exp @@ -22,4 +22,4 @@ set lang {c++} set debug debug -source $srcdir/$subdir/infcall-nodebug.exp.in +source $srcdir/$subdir/infcall-nodebug.exp.tcl diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug-c-d0.exp b/gdb/testsuite/gdb.cp/infcall-nodebug-c-d0.exp index cd65dd0..b74f933 100644 --- a/gdb/testsuite/gdb.cp/infcall-nodebug-c-d0.exp +++ b/gdb/testsuite/gdb.cp/infcall-nodebug-c-d0.exp @@ -18,4 +18,4 @@ set lang {c} set debug nodebug -source $srcdir/$subdir/infcall-nodebug.exp.in +source $srcdir/$subdir/infcall-nodebug.exp.tcl diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug-c-d1.exp b/gdb/testsuite/gdb.cp/infcall-nodebug-c-d1.exp index 4cb26ad..b9d6863 100644 --- a/gdb/testsuite/gdb.cp/infcall-nodebug-c-d1.exp +++ b/gdb/testsuite/gdb.cp/infcall-nodebug-c-d1.exp @@ -18,4 +18,4 @@ set lang {c} set debug debug -source $srcdir/$subdir/infcall-nodebug.exp.in +source $srcdir/$subdir/infcall-nodebug.exp.tcl diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug.exp.in b/gdb/testsuite/gdb.cp/infcall-nodebug.exp.in deleted file mode 100644 index 2346619..0000000 --- a/gdb/testsuite/gdb.cp/infcall-nodebug.exp.in +++ /dev/null @@ -1,101 +0,0 @@ -# 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 . - -# 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 diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl b/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl new file mode 100644 index 0000000..2346619 --- /dev/null +++ b/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl @@ -0,0 +1,101 @@ +# 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 . + +# 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 diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names-2.exp b/gdb/testsuite/gdb.dwarf2/clang-debug-names-2.exp index 185dddf..43d7801 100644 --- a/gdb/testsuite/gdb.dwarf2/clang-debug-names-2.exp +++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names-2.exp @@ -29,7 +29,7 @@ lassign \ main_start main_length set asm_file [standard_output_file $srcfile2] -source $srcdir/$subdir/clang-debug-names.exp.in +source $srcdir/$subdir/clang-debug-names.exp.tcl if { [build_executable_from_specs "failed to prepare" ${testfile} "" \ $srcfile "nodebug" $asm_file "nodebug" $srcfile3 "debug"] } { diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp index b5af898..149c126 100644 --- a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp +++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp @@ -26,7 +26,7 @@ lassign [function_range main ${srcdir}/${subdir}/${srcfile}] \ main_start main_length set asm_file [standard_output_file $srcfile2] -source $srcdir/$subdir/clang-debug-names.exp.in +source $srcdir/$subdir/clang-debug-names.exp.tcl if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.in b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.in deleted file mode 100644 index 39e0e1e..0000000 --- a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.in +++ /dev/null @@ -1,121 +0,0 @@ -# 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 . - -# Set up the DWARF for the test. - -set main_str_label [Dwarf::_compute_label info_string3] -set int_str_label [Dwarf::_compute_label info_string4] -set main_die_label [Dwarf::_compute_label main_die_label] -set int_die_label [Dwarf::_compute_label int_die_label] - -set debug_str \ - [list \ - "$main_str_label:" \ - " .asciz \"main\"" \ - "$int_str_label:" \ - " .asciz \"int\""] - -set debug_names \ - [list \ - " .4byte .Ldebug_names_end - .Ldebug_names_start" \ - ".Ldebug_names_start:" \ - " .short 5 # Header: version" \ - " .short 0 # Header: padding" \ - " .long 1 # Header: compilation unit count" \ - " .long 0 # Header: local type unit count" \ - " .long 0 # Header: foreign type unit count" \ - " .long 2 # Header: bucket count" \ - " .long 2 # Header: name count" \ - " .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \ - " # Header: abbreviation table size" \ - " .long 8 # Header: augmentation string size" \ - " .ascii \"LLVM0700\" # Header: augmentation string" \ - " .long .Lcu1_begin # Compilation unit 0" \ - " .long 1 # Bucket 0" \ - " .long 0 # Bucket 1" \ - " .long 193495088 # Hash in Bucket 0" \ - " .long 2090499946 # Hash in Bucket 0" \ - " .long $int_str_label # String in Bucket 0: int" \ - " .long $main_str_label # String in Bucket 0: main" \ - " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \ - " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \ - ".Lnames_abbrev_start0:" \ - " .byte 46 # Abbrev code" \ - " .byte 46 # DW_TAG_subprogram" \ - " .byte 3 # DW_IDX_die_offset" \ - " .byte 19 # DW_FORM_ref4" \ - " .byte 0 # End of abbrev" \ - " .byte 0 # End of abbrev" \ - " .byte 36 # Abbrev code" \ - " .byte 36 # DW_TAG_base_type" \ - " .byte 3 # DW_IDX_die_offset" \ - " .byte 19 # DW_FORM_ref4" \ - " .byte 0 # End of abbrev" \ - " .byte 0 # End of abbrev" \ - " .byte 0 # End of abbrev list" \ - ".Lnames_abbrev_end0:" \ - ".Lnames_entries0:" \ - ".Lnames1:" \ - " .byte 36 # Abbreviation code" \ - " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \ - " .long 0 # End of list: int" \ - ".Lnames0:" \ - " .byte 46 # Abbreviation code" \ - " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \ - " .long 0 # End of list: main" \ - " .p2align 2" \ - ".Ldebug_names_end:"] - -Dwarf::assemble $asm_file { - global srcdir subdir srcfile - global main_start main_length - - cu {} { - DW_TAG_compile_unit { - {DW_AT_language @DW_LANG_C} - {DW_AT_name clang-debug-names.c} - {DW_AT_comp_dir /tmp} - - } { - global int_die_label - global main_die_label - - define_label $int_die_label - base_type { - {name "int"} - {encoding @DW_ATE_signed} - {byte_size 4 DW_FORM_sdata} - } - - define_label $main_die_label - subprogram { - {name main} - {type :$int_die_label} - {low_pc $main_start addr} - {high_pc "$main_start + $main_length" addr} - } - } - } - - _defer_output .debug_str { - global debug_str - _emit [join $debug_str "\n"] - } - - _defer_output .debug_names { - global debug_names - _emit [join $debug_names "\n"] - } -} diff --git a/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl new file mode 100644 index 0000000..39e0e1e --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/clang-debug-names.exp.tcl @@ -0,0 +1,121 @@ +# 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 . + +# Set up the DWARF for the test. + +set main_str_label [Dwarf::_compute_label info_string3] +set int_str_label [Dwarf::_compute_label info_string4] +set main_die_label [Dwarf::_compute_label main_die_label] +set int_die_label [Dwarf::_compute_label int_die_label] + +set debug_str \ + [list \ + "$main_str_label:" \ + " .asciz \"main\"" \ + "$int_str_label:" \ + " .asciz \"int\""] + +set debug_names \ + [list \ + " .4byte .Ldebug_names_end - .Ldebug_names_start" \ + ".Ldebug_names_start:" \ + " .short 5 # Header: version" \ + " .short 0 # Header: padding" \ + " .long 1 # Header: compilation unit count" \ + " .long 0 # Header: local type unit count" \ + " .long 0 # Header: foreign type unit count" \ + " .long 2 # Header: bucket count" \ + " .long 2 # Header: name count" \ + " .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 " \ + " # Header: abbreviation table size" \ + " .long 8 # Header: augmentation string size" \ + " .ascii \"LLVM0700\" # Header: augmentation string" \ + " .long .Lcu1_begin # Compilation unit 0" \ + " .long 1 # Bucket 0" \ + " .long 0 # Bucket 1" \ + " .long 193495088 # Hash in Bucket 0" \ + " .long 2090499946 # Hash in Bucket 0" \ + " .long $int_str_label # String in Bucket 0: int" \ + " .long $main_str_label # String in Bucket 0: main" \ + " .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0" \ + " .long .Lnames0-.Lnames_entries0 # Offset in Bucket 0" \ + ".Lnames_abbrev_start0:" \ + " .byte 46 # Abbrev code" \ + " .byte 46 # DW_TAG_subprogram" \ + " .byte 3 # DW_IDX_die_offset" \ + " .byte 19 # DW_FORM_ref4" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev" \ + " .byte 36 # Abbrev code" \ + " .byte 36 # DW_TAG_base_type" \ + " .byte 3 # DW_IDX_die_offset" \ + " .byte 19 # DW_FORM_ref4" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev" \ + " .byte 0 # End of abbrev list" \ + ".Lnames_abbrev_end0:" \ + ".Lnames_entries0:" \ + ".Lnames1:" \ + " .byte 36 # Abbreviation code" \ + " .long $int_die_label - .Lcu1_begin # DW_IDX_die_offset" \ + " .long 0 # End of list: int" \ + ".Lnames0:" \ + " .byte 46 # Abbreviation code" \ + " .long $main_die_label - .Lcu1_begin # DW_IDX_die_offset" \ + " .long 0 # End of list: main" \ + " .p2align 2" \ + ".Ldebug_names_end:"] + +Dwarf::assemble $asm_file { + global srcdir subdir srcfile + global main_start main_length + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C} + {DW_AT_name clang-debug-names.c} + {DW_AT_comp_dir /tmp} + + } { + global int_die_label + global main_die_label + + define_label $int_die_label + base_type { + {name "int"} + {encoding @DW_ATE_signed} + {byte_size 4 DW_FORM_sdata} + } + + define_label $main_die_label + subprogram { + {name main} + {type :$int_die_label} + {low_pc $main_start addr} + {high_pc "$main_start + $main_length" addr} + } + } + } + + _defer_output .debug_str { + global debug_str + _emit [join $debug_str "\n"] + } + + _defer_output .debug_names { + global debug_names + _emit [join $debug_names "\n"] + } +} -- cgit v1.1