Skip to content

Commit

Permalink
copy over go testsuite files from upstream gdb
Browse files Browse the repository at this point in the history
Change-Id: I9592777604eaa0ce568def3f64b0e057e2580397
  • Loading branch information
cooljeanius committed Nov 16, 2024
1 parent 6f31604 commit 52a1722
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 123 deletions.
10 changes: 3 additions & 7 deletions src/gdb/testsuite/gdb.go/basic-types.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/gdb/testsuite/gdb.go/chan.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,32 +20,31 @@

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
}

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"

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"
15 changes: 3 additions & 12 deletions src/gdb/testsuite/gdb.go/handcall.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
2 changes: 1 addition & 1 deletion src/gdb/testsuite/gdb.go/handcall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
25 changes: 5 additions & 20 deletions src/gdb/testsuite/gdb.go/hello.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,41 +19,26 @@

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
}

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"
9 changes: 3 additions & 6 deletions src/gdb/testsuite/gdb.go/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
27 changes: 13 additions & 14 deletions src/gdb/testsuite/gdb.go/integers.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,40 +19,39 @@

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
}

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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
81 changes: 67 additions & 14 deletions src/gdb/testsuite/gdb.go/methods.exp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Loading

0 comments on commit 52a1722

Please sign in to comment.