diff --git a/src/gdb/testsuite/gdb.go/basic-types.exp b/src/gdb/testsuite/gdb.go/basic-types.exp index c1417bb3e..1ba84fa0d 100644 --- a/src/gdb/testsuite/gdb.go/basic-types.exp +++ b/src/gdb/testsuite/gdb.go/basic-types.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -20,7 +20,7 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests proc test_integer_literal_types_accepted {} { # Test various decimal values. @@ -100,11 +100,7 @@ proc test_complex_literal_types_accepted {} { gdb_test "pt complex128(i1.0)" "type = complex128" } -# Start with a fresh gdb. - -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir +clean_restart if [set_lang_go] { test_integer_literal_types_accepted diff --git a/src/gdb/testsuite/gdb.go/chan.exp b/src/gdb/testsuite/gdb.go/chan.exp index fc6ed1506..0e5a2b855 100644 --- a/src/gdb/testsuite/gdb.go/chan.exp +++ b/src/gdb/testsuite/gdb.go/chan.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -20,11 +20,11 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } @@ -32,7 +32,6 @@ set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] if { [go_runto_main] < 0 } { - untested $testfile return -1 } @@ -40,7 +39,7 @@ if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { pass "setting breakpoint 1" } -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint" gdb_test_no_output "disable" @@ -48,4 +47,4 @@ if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { pass "setting breakpoint 2" } -gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" +gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "going to second breakpoint" diff --git a/src/gdb/testsuite/gdb.go/handcall.exp b/src/gdb/testsuite/gdb.go/handcall.exp index f9a872080..9bee36787 100644 --- a/src/gdb/testsuite/gdb.go/handcall.exp +++ b/src/gdb/testsuite/gdb.go/handcall.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,26 +19,17 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } -set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] - if { [go_runto_main] < 0 } { - untested $testfile return -1 } -if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { - pass "setting breakpoint 1" -} - -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" - gdb_test "print add (1, 2)" " = 3" gdb_test "print main.add (1, 2)" " = 3" diff --git a/src/gdb/testsuite/gdb.go/handcall.go b/src/gdb/testsuite/gdb.go/handcall.go index f32b5e9a4..c09d997f1 100644 --- a/src/gdb/testsuite/gdb.go/handcall.go +++ b/src/gdb/testsuite/gdb.go/handcall.go @@ -11,5 +11,5 @@ func sub (a,b int) (int) { var v_int int func main () { - v_int = 42 // set breakpoint 1 here + v_int = 42 } diff --git a/src/gdb/testsuite/gdb.go/hello.exp b/src/gdb/testsuite/gdb.go/hello.exp index 2f94110c0..c1eb87ea8 100644 --- a/src/gdb/testsuite/gdb.go/hello.exp +++ b/src/gdb/testsuite/gdb.go/hello.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,19 +19,17 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] -set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] if { [go_runto_main] < 0 } { - untested $testfile return -1 } @@ -39,21 +37,8 @@ if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { pass "setting breakpoint 1" } -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" - -# This used to print "", i.e., the local "st" initialized as "". -setup_xfail "*-*-*" - -gdb_test "print st" \ - ".* = $hex \"\"" \ - "Starting string check" - -if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { - pass "setting breakpoint 2" -} - -gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint" +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint" gdb_test "print st" \ ".* = $hex \"Hello, world!\"" \ - "String after assignment check" + "string after assignment check" diff --git a/src/gdb/testsuite/gdb.go/hello.go b/src/gdb/testsuite/gdb.go/hello.go index 6e561129c..67114dde7 100644 --- a/src/gdb/testsuite/gdb.go/hello.go +++ b/src/gdb/testsuite/gdb.go/hello.go @@ -2,11 +2,8 @@ package main import "fmt" -var myst = "Shall we?" - func main () { - fmt.Println ("Before assignment") // set breakpoint 1 here - st := "Hello, world!" // this intentionally shadows the global "st" - fmt.Println (st) // set breakpoint 2 here - fmt.Println (myst) // set breakpoint 2 here + fmt.Println ("Before assignment") + st := "Hello, world!" + fmt.Println (st) // set breakpoint 1 here } diff --git a/src/gdb/testsuite/gdb.go/integers.exp b/src/gdb/testsuite/gdb.go/integers.exp index ce889be0a..78375426a 100644 --- a/src/gdb/testsuite/gdb.go/integers.exp +++ b/src/gdb/testsuite/gdb.go/integers.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,11 +19,11 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } @@ -31,7 +31,6 @@ set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] if { [go_runto_main] < 0 } { - untested $testfile return -1 } @@ -39,20 +38,20 @@ if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { pass "setting breakpoint 1" } -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "going to first breakpoint" -gdb_test "print i" ".* = 0" "Print i before assigned to 1" +gdb_test "print i" ".* = 0" "print i before assigned to 1" -gdb_test "next" "i = 1" "Next to 'i = 1' line" -gdb_test "next" "j = 2" "Next to 'j = 2' line" +gdb_test "next" "i = 1" "next to 'i = 1' line" +gdb_test "next" "j = 2" "next to 'j = 2' line" # At that point, # i should be equal to 1 gdb_test "print i" " = 1" # but j should still be equal to zero -gdb_test "print j" " = 0" "Test j value before assignment" +gdb_test "print j" " = 0" "test j value before assignment" -gdb_test "next" "k = 3" "Next to 'k = 3' line" -gdb_test "next" "l = k" "Next to 'l = k' line" +gdb_test "next" "k = 3" "next to 'k = 3' line" +gdb_test "next" "l = k" "next to 'l = k' line" #j should be equal to 2 gdb_test "print j" " = 2" @@ -67,7 +66,7 @@ gdb_test "print i + k" " = 4" gdb_test "print j + k" " = 5" gdb_test "print i + j + k" " = 6" -# Test substraction +# Test subtraction gdb_test "print j - i" " = 1" gdb_test "print i - j" "= -1" gdb_test "print k -i -j" " = 0" @@ -101,7 +100,7 @@ gdb_test "print i+10*j+100*k" " = 321" gdb_test " print (i + 5) * (j + 7)" " = 54" gdb_test "set var i = 2" " = 2" -gdb_test "print i" " = 2" "Testing new i value" +gdb_test "print i" " = 2" "testing new i value" if { [gdb_breakpoint ${srcfile}:${bp_location2}] } { pass "setting breakpoint 2" @@ -112,4 +111,4 @@ gdb_test "cont" \ "Going to second breakpoint" gdb_test "print i" \ ".* = 5.*" \ - "Value of i after assignment" + "value of i after assignment" diff --git a/src/gdb/testsuite/gdb.go/methods.exp b/src/gdb/testsuite/gdb.go/methods.exp index f9087b724..6a42d3468 100644 --- a/src/gdb/testsuite/gdb.go/methods.exp +++ b/src/gdb/testsuite/gdb.go/methods.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,31 +19,84 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } set bp_location1 {main.T.Foo} -set bp_location2 {(*main.T).Bar} -set bp_location2_regexp {\(*main.T\).Bar} +set bp_location2 {main.T.Bar} if { [go_runto_main] < 0 } { - untested $testfile return -1 } -if { [gdb_breakpoint ${bp_location1}] } { - pass "setting breakpoint 1" +set found_wrong_foo 0 +set found_wrong_bar 0 +gdb_test_multiple "maintenance print symbols" "" { + -re "^\r\n void main.Foo.N6_main.T\[^\r\n\]*(?=\r\n)" { + set found_wrong_foo 1 + exp_continue + } + -re "^\r\n void main.Bar.pN6_main.T\[^\r\n\]*(?=\r\n)" { + set found_wrong_bar 1 + exp_continue + } + -re "^\r\n void main.T.Bar\[^\r\n\]*(?=\r\n)" { + exp_continue + } + -re "^\r\n$gdb_prompt $" { + pass $gdb_test_name + } + -re "\r\n\[^\r\n\]*(?=\r\n)" { + exp_continue + } } -setup_xfail "*-*-*" ;# mangling issues IIRC -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" -if { [gdb_breakpoint ${bp_location2}] } { - pass "setting breakpoint 2" +if { $found_wrong_foo } { + # We have with gccgo-6/7: + # <1><553>: Abbrev Number: 21 (DW_TAG_subprogram) + # <554> DW_AT_name : main.Foo.N6_main.T + setup_xfail "*-*-*" +} else { + # We have with gccgo-8/9/10: + # <1><1e24>: Abbrev Number: 40 (DW_TAG_subprogram) + # <1e25> DW_AT_name : main.Foo.main.T + # <1e2c> DW_AT_linkage_name: main.T.Foo + + # For reference: with go1.11.13: + # <1><6c46b>: Abbrev Number: 2 (DW_TAG_subprogram) + # <6c46c> DW_AT_name : main.T.Foo +} + +if { [gdb_breakpoint ${bp_location1} message]} { + gdb_test "cont" "Breakpoint .*, ${bp_location1}.*" \ + "going to first breakpoint" +} + +if { $found_wrong_bar == 1 } { + # We have with gccgo-6/7: + # <1><528>: Abbrev Number: 19 (DW_TAG_subprogram) + # <529> DW_AT_name : main.Bar.pN6_main.T + setup_xfail "*-*-*" +} else { + # We have with gccgo-8/9/10: + # <1><6e4>: Abbrev Number: 24 (DW_TAG_subprogram) + # <6e5> DW_AT_name : main.Bar..1main.T + # <6ec> DW_AT_linkage_name: main.T.Bar + + # For reference: with go1.11.13: + # <1><6c49a>: Abbrev Number: 2 (DW_TAG_subprogram) + # <6c49b> DW_AT_name : main.(*T).Bar + + # It has been clarified in PR gcc/93866 that it's ok that symbols names + # diverge between gc and gccgo. So, we accept the main.T.Bar as valid. +} + +if { [gdb_breakpoint ${bp_location2} message] } { + gdb_test "cont" "Breakpoint .*, ${bp_location2}.*" \ + "going to second breakpoint" } -setup_xfail "*-*-*" ;# mangling issues IIRC -gdb_test "cont" "Breakpoint .*:${bp_location2_regexp}.*" "Going to second breakpoint" diff --git a/src/gdb/testsuite/gdb.go/package.exp b/src/gdb/testsuite/gdb.go/package.exp index c1d77d1cd..f1640a89d 100644 --- a/src/gdb/testsuite/gdb.go/package.exp +++ b/src/gdb/testsuite/gdb.go/package.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,24 +19,23 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile package1.go package2.go if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.go" "${binfile}2.o" object {debug go}] != "" } { - untested $testfile + untested "failed to compile" return -1 } if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.go ${binfile}2.o" "${binfile}" executable "debug go libdir=[standard_output_file {}]"] != "" } { - untested $testfile + untested "failed to compile" return -1 } clean_restart $testfile if { [go_runto_main] < 0 } { - untested methods return -1 } @@ -46,4 +45,4 @@ set bp_location1_regexp {package2[.]Foo.*package2[.]go:} if { [gdb_breakpoint ${bp_location1}] } { pass "setting breakpoint 1" } -gdb_test "cont" "Breakpoint .*${bp_location1_regexp}.*" "Going to first breakpoint" +gdb_test "cont" "Breakpoint .*${bp_location1_regexp}.*" "going to first breakpoint" diff --git a/src/gdb/testsuite/gdb.go/print.exp b/src/gdb/testsuite/gdb.go/print.exp index a62ab4178..20ab041d6 100644 --- a/src/gdb/testsuite/gdb.go/print.exp +++ b/src/gdb/testsuite/gdb.go/print.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -20,7 +20,7 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests proc test_float_accepted {} { global gdb_prompt @@ -56,11 +56,7 @@ proc test_float_rejected {} { test_print_reject "p 1.1ll" } -# Start with a fresh gdb. - -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir +clean_restart if [set_lang_go] { test_float_accepted diff --git a/src/gdb/testsuite/gdb.go/strings.exp b/src/gdb/testsuite/gdb.go/strings.exp index 625e79ef0..50e68c84e 100644 --- a/src/gdb/testsuite/gdb.go/strings.exp +++ b/src/gdb/testsuite/gdb.go/strings.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -17,25 +17,16 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } -set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] - if { [go_runto_main] < 0 } { - untested $testfile return -1 } -if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { - pass "setting breakpoint 1" -} - -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" - gdb_test {print "abc" + "def"} {.* = "abcdef"} diff --git a/src/gdb/testsuite/gdb.go/strings.go b/src/gdb/testsuite/gdb.go/strings.go index fc62e3964..c80f0815f 100644 --- a/src/gdb/testsuite/gdb.go/strings.go +++ b/src/gdb/testsuite/gdb.go/strings.go @@ -5,6 +5,6 @@ import "fmt" var v_string string = "foo" func main () { - fmt.Println ("hello") // set breakpoint 1 here + fmt.Println ("hello") fmt.Printf ("%s\n", v_string) } diff --git a/src/gdb/testsuite/gdb.go/types.exp b/src/gdb/testsuite/gdb.go/types.exp index bcc9c7ec0..cc0c9ca8b 100644 --- a/src/gdb/testsuite/gdb.go/types.exp +++ b/src/gdb/testsuite/gdb.go/types.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,16 +19,15 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } if { [go_runto_main] < 0 } { - untested $testfile return -1 } diff --git a/src/gdb/testsuite/gdb.go/unsafe.exp b/src/gdb/testsuite/gdb.go/unsafe.exp index 41c41ea3f..04f214174 100644 --- a/src/gdb/testsuite/gdb.go/unsafe.exp +++ b/src/gdb/testsuite/gdb.go/unsafe.exp @@ -1,6 +1,6 @@ # This testcase is part of GDB, the GNU debugger. -# Copyright 2012-2013 Free Software Foundation, Inc. +# Copyright 2012-2024 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 @@ -19,25 +19,16 @@ load_lib "go.exp" -if { [skip_go_tests] } { continue } +require allow_go_tests support_go_compile standard_testfile .go -if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } { +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug go}] } { return -1 } -set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] - if { [go_runto_main] < 0 } { - untested $testfile return -1 } -if { [gdb_breakpoint ${srcfile}:${bp_location1}] } { - pass "setting breakpoint 1" -} - -gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint" - gdb_test "print unsafe.Sizeof(42)" ".* = 4" diff --git a/src/gdb/testsuite/gdb.go/unsafe.go b/src/gdb/testsuite/gdb.go/unsafe.go index 95318bd6d..ac8a6f679 100644 --- a/src/gdb/testsuite/gdb.go/unsafe.go +++ b/src/gdb/testsuite/gdb.go/unsafe.go @@ -6,6 +6,6 @@ import ("fmt" var mystring = "Shall we?" func main () { - fmt.Printf ("%d\n", unsafe.Sizeof (42)) // set breakpoint 1 here + fmt.Printf ("%d\n", unsafe.Sizeof (42)) fmt.Printf ("%d\n", unsafe.Sizeof (mystring)) }