aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.go
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2012-04-25 14:07:23 +0000
committerDoug Evans <dje@google.com>2012-04-25 14:07:23 +0000
commita766d390bb857383a5f9ae80a102e1f8705f4c2e (patch)
tree056e6d8d57aee5d234d9ed4619a27306dfec3dd7 /gdb/testsuite/gdb.go
parente65f9ffb8e49431537404712a5b1eed310964cb0 (diff)
downloadgdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.zip
gdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.tar.gz
gdb-a766d390bb857383a5f9ae80a102e1f8705f4c2e.tar.bz2
Initial pass at Go language support.
* NEWS: Mention Go. * Makefile.in (SFILES): Add go-exp.y, go-lang.c, go-typeprint.c, go-valprint.c. (COMMON_OBS): Add go-lang.o, go-val.print.o, go-typeprint.o. (YYFILES): Add go-exp.c. (YYOBJ): Add go-exp.o. (local-maintainer-clean): Delete go-exp.c. * defs.h (enum language): Add language_go. * dwarf2read.c: #include "go-lang.h". (fixup_go_packaging): New function. (process_full_comp_unit): Call it when processing Go CUs. (dwarf2_physname): Add Go support. (read_file_scope): Handle missing language spec for GNU Go. (set_cu_language): Handle DW_LANG_Go. * go-exp.y: New file. * go-lang.h: New file. * go-lang.c: New file. * go-typeprint.c: New file. * go-valprint.c: New file. * symtab.c: #include "go-lang.h". (symbol_set_language): Handle language_go. (symbol_find_demangled_name, symbol_set_names): Ditto. (symbol_natural_name, demangle_for_lookup, find_main_name): Ditto. testsuite/ * configure.ac: Create gdb.go/Makefile. * configure: Regenerate. * gdb.base/default.exp: Add "go" to "set language" testing. * gdb.go/Makefile.in: New file. * gdb.go/basic-types.exp: New file. * gdb.go/chan.exp: New file. * gdb.go/chan.go: New file. * gdb.go/handcall.exp: New file. * gdb.go/handcall.go: New file. * gdb.go/hello.exp: New file. * gdb.go/hello.go: New file. * gdb.go/integers.exp: New file. * gdb.go/integers.go: New file. * gdb.go/methods.exp: New file. * gdb.go/methods.go: New file. * gdb.go/package.exp: New file. * gdb.go/package1.go: New file. * gdb.go/package2.go: New file. * gdb.go/print.exp: New file. * gdb.go/strings.exp: New file. * gdb.go/strings.go: New file. * gdb.go/types.exp: New file. * gdb.go/types.go: New file. * gdb.go/unsafe.exp: New file. * gdb.go/unsafe.go: New file. * lib/future.exp: Add Go support. (gdb_find_go, gdb_find_go_linker): New procs. (gdb_default_target_compile): Add Go support. * lib/gdb.exp (skip_go_tests): New proc. * lib/go.exp: New file. doc/ * gdb.texinfo (Supported Languages): Add Go. (Go): New node.
Diffstat (limited to 'gdb/testsuite/gdb.go')
-rw-r--r--gdb/testsuite/gdb.go/Makefile.in20
-rw-r--r--gdb/testsuite/gdb.go/basic-types.exp118
-rw-r--r--gdb/testsuite/gdb.go/chan.exp52
-rw-r--r--gdb/testsuite/gdb.go/chan.go20
-rw-r--r--gdb/testsuite/gdb.go/handcall.exp45
-rw-r--r--gdb/testsuite/gdb.go/handcall.go15
-rw-r--r--gdb/testsuite/gdb.go/hello.exp60
-rw-r--r--gdb/testsuite/gdb.go/hello.go12
-rw-r--r--gdb/testsuite/gdb.go/integers.exp116
-rw-r--r--gdb/testsuite/gdb.go/integers.go22
-rw-r--r--gdb/testsuite/gdb.go/methods.exp50
-rw-r--r--gdb/testsuite/gdb.go/methods.go21
-rw-r--r--gdb/testsuite/gdb.go/package.exp50
-rw-r--r--gdb/testsuite/gdb.go/package1.go11
-rw-r--r--gdb/testsuite/gdb.go/package2.go7
-rw-r--r--gdb/testsuite/gdb.go/print.exp70
-rw-r--r--gdb/testsuite/gdb.go/strings.exp42
-rw-r--r--gdb/testsuite/gdb.go/strings.go10
-rw-r--r--gdb/testsuite/gdb.go/types.exp51
-rw-r--r--gdb/testsuite/gdb.go/types.go24
-rw-r--r--gdb/testsuite/gdb.go/unsafe.exp44
-rw-r--r--gdb/testsuite/gdb.go/unsafe.go11
22 files changed, 871 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.go/Makefile.in b/gdb/testsuite/gdb.go/Makefile.in
new file mode 100644
index 0000000..dfce2d6
--- /dev/null
+++ b/gdb/testsuite/gdb.go/Makefile.in
@@ -0,0 +1,20 @@
+VPATH = @srcdir@
+srcdir = @srcdir@
+
+EXECUTABLES = \
+ chan handcall hello integers methods package \
+ strings types unsafe
+
+all info install-info dvi install uninstall installcheck check:
+ @echo "Nothing to be done for $@..."
+
+clean mostlyclean:
+ -find . -name '*.o' -print | xargs rm -f
+ -find . -name '*.ali' -print | xargs rm -f
+ -rm -f *~ a.out
+ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
+
+distclean maintainer-clean realclean: clean
+ -rm -f Makefile config.status config.log
+ -rm -f *-init.exp gdb.log gdb.sum
+ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
diff --git a/gdb/testsuite/gdb.go/basic-types.exp b/gdb/testsuite/gdb.go/basic-types.exp
new file mode 100644
index 0000000..d3a542d
--- /dev/null
+++ b/gdb/testsuite/gdb.go/basic-types.exp
@@ -0,0 +1,118 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test basic builtin types.
+# NOTE: The tests here intentionally do not require a go compiler.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+proc test_integer_literal_types_accepted {} {
+ # Test various decimal values.
+
+ gdb_test "pt 123" "type = int"
+
+ gdb_test "pt void(42)" "type = void"
+ gdb_test "pt byte(42)" "type = uint8"
+ gdb_test "pt int(42)" "type = int"
+ gdb_test "pt uint(42)" "type = uint"
+ gdb_test "pt uintptr(42)" "type = uintptr"
+
+ gdb_test "pt int8(42)" "type = int8"
+ gdb_test "pt int16(42)" "type = int16"
+ gdb_test "pt int32(42)" "type = int32"
+ gdb_test "pt int64(42)" "type = int64"
+
+ gdb_test "pt uint8(42)" "type = uint8"
+ gdb_test "pt uint16(42)" "type = uint16"
+ gdb_test "pt uint32(42)" "type = uint32"
+ gdb_test "pt uint64(42)" "type = uint64"
+}
+
+proc test_logical_literal_types_accepted {} {
+ # Test the only possible values for a logical, TRUE and FALSE.
+
+ gdb_test "pt true" "type = bool"
+ gdb_test "pt false" "type = bool"
+
+ gdb_test "pt bool(0)" "type = bool"
+ gdb_test "pt bool(1)" "type = bool"
+}
+
+proc test_character_literal_types_accepted {} {
+ # Test various character values.
+
+ gdb_test "pt 'a'" "type = char"
+
+ # FIXME: Need more.
+}
+
+proc test_string_literal_types_accepted {} {
+ # Test various string values.
+
+ gdb_test "pt \"a simple string\"" "type = string"
+ gdb_test "pt `a simple raw string`" "type = string"
+
+ # FIXME: Need more.
+}
+
+proc test_float_literal_types_accepted {} {
+ # Test various floating point formats.
+
+ gdb_test "pt .44" "type = float64"
+ gdb_test "pt 44.0" "type = float64"
+ gdb_test "pt 10e20" "type = float64"
+ gdb_test "pt 10E20" "type = float64"
+
+ gdb_test "pt float32(.42)" "type = float32"
+
+ gdb_test "pt float64(.42)" "type = float64"
+}
+
+proc test_complex_literal_types_accepted {} {
+ # Test various complex formats.
+
+ gdb_test "pt complex64(.42)" "type = complex64"
+ setup_xfail "*-*-*"
+ gdb_test "pt complex64(.42i1.0)" "type = complex64"
+ setup_xfail "*-*-*"
+ gdb_test "pt complex64(i1.0)" "type = complex64"
+
+ gdb_test "pt complex128(.42)" "type = complex128"
+ setup_xfail "*-*-*"
+ gdb_test "pt complex128(.42i1.0)" "type = complex128"
+ setup_xfail "*-*-*"
+ gdb_test "pt complex128(i1.0)" "type = complex128"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+if [set_lang_go] {
+ test_integer_literal_types_accepted
+ test_logical_literal_types_accepted
+ test_character_literal_types_accepted
+ test_string_literal_types_accepted
+ test_float_literal_types_accepted
+ test_complex_literal_types_accepted
+} else {
+ warning "Go type tests suppressed."
+}
diff --git a/gdb/testsuite/gdb.go/chan.exp b/gdb/testsuite/gdb.go/chan.exp
new file mode 100644
index 0000000..317e214
--- /dev/null
+++ b/gdb/testsuite/gdb.go/chan.exp
@@ -0,0 +1,52 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Basic channel tests.
+# This is very much a work-in-progress.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "chan"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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_no_output "disable"
+
+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
+ pass "setting breakpoint 2"
+}
+
+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
diff --git a/gdb/testsuite/gdb.go/chan.go b/gdb/testsuite/gdb.go/chan.go
new file mode 100644
index 0000000..f237288
--- /dev/null
+++ b/gdb/testsuite/gdb.go/chan.go
@@ -0,0 +1,20 @@
+package main
+
+import "fmt"
+
+func generate() chan int {
+ ch := make(chan int)
+ go func() {
+ for i := 0; ; i++ {
+ ch <- i // set breakpoint 1 here
+ }
+ }()
+ return ch
+}
+
+func main() {
+ integers := generate()
+ for i := 0; i < 100; i++ { // Print the first hundred integers.
+ fmt.Println(<-integers) // set breakpoint 2 here
+ }
+}
diff --git a/gdb/testsuite/gdb.go/handcall.exp b/gdb/testsuite/gdb.go/handcall.exp
new file mode 100644
index 0000000..077186e
--- /dev/null
+++ b/gdb/testsuite/gdb.go/handcall.exp
@@ -0,0 +1,45 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test hand-calling go functions.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "handcall"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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/gdb/testsuite/gdb.go/handcall.go b/gdb/testsuite/gdb.go/handcall.go
new file mode 100644
index 0000000..f32b5e9
--- /dev/null
+++ b/gdb/testsuite/gdb.go/handcall.go
@@ -0,0 +1,15 @@
+package main
+
+func add (a,b int) (int) {
+ return a + b
+}
+
+func sub (a,b int) (int) {
+ return a - b
+}
+
+var v_int int
+
+func main () {
+ v_int = 42 // set breakpoint 1 here
+}
diff --git a/gdb/testsuite/gdb.go/hello.exp b/gdb/testsuite/gdb.go/hello.exp
new file mode 100644
index 0000000..e6abfb9
--- /dev/null
+++ b/gdb/testsuite/gdb.go/hello.exp
@@ -0,0 +1,60 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Basic tests.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "hello"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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 "print st" \
+ ".* = $hex \"Hello, world!\"" \
+ "String after assignment check"
diff --git a/gdb/testsuite/gdb.go/hello.go b/gdb/testsuite/gdb.go/hello.go
new file mode 100644
index 0000000..6e56112
--- /dev/null
+++ b/gdb/testsuite/gdb.go/hello.go
@@ -0,0 +1,12 @@
+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
+}
diff --git a/gdb/testsuite/gdb.go/integers.exp b/gdb/testsuite/gdb.go/integers.exp
new file mode 100644
index 0000000..202c56d
--- /dev/null
+++ b/gdb/testsuite/gdb.go/integers.exp
@@ -0,0 +1,116 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test integer expressions.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "integers"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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 "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"
+# 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 "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"
+# k should be equal to 3
+gdb_test "print k" " = 3"
+# But l should still be zero
+gdb_test "print l" " = 0"
+
+# Test addition
+gdb_test "print i + j" " = 3"
+gdb_test "print i + k" " = 4"
+gdb_test "print j + k" " = 5"
+gdb_test "print i + j + k" " = 6"
+
+# Test substraction
+gdb_test "print j - i" " = 1"
+gdb_test "print i - j" "= -1"
+gdb_test "print k -i -j" " = 0"
+gdb_test "print k -(i + j)" " = 0"
+
+# Test unany minus
+gdb_test "print -i" " = -1"
+gdb_test "print (-i)" " = -1"
+gdb_test "print -(i)" " = -1"
+gdb_test "print -(i+j)" " = -3"
+
+# Test boolean operators =, <>, <, <=, > and >=
+gdb_test "print i + 1 == j" " = true"
+gdb_test "print i + 1 != j" " = false"
+gdb_test "print i + 1 < j" " = false"
+gdb_test "print i + 1 <= j" " = true"
+gdb_test "print i + 1 > j" " = false"
+gdb_test "print i + 1 >= j" " = true"
+
+# Test multiplication
+gdb_test "print 2 * i" " = 2"
+gdb_test "print j * k" " = 6"
+gdb_test "print 3000*i" " = 3000"
+
+#Test div and mod operators
+gdb_test "print 35 / 2" " = 17"
+gdb_test "print 35 % 2" " = 1"
+
+# Test several operators together
+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"
+
+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
+ pass "setting breakpoint 2"
+}
+
+gdb_test "cont" \
+ "Breakpoint .*:${bp_location2}.*" \
+ "Going to second breakpoint"
+gdb_test "print i" \
+ ".* = 5.*" \
+ "Value of i after assignment"
diff --git a/gdb/testsuite/gdb.go/integers.go b/gdb/testsuite/gdb.go/integers.go
new file mode 100644
index 0000000..4430099
--- /dev/null
+++ b/gdb/testsuite/gdb.go/integers.go
@@ -0,0 +1,22 @@
+package main
+
+var i = 0
+var j = 0
+var k = 0
+var l = 0
+
+func main () {
+ i = 0
+ j = 0
+ k = 0
+ l = 0 // set breakpoint 1 here
+ i = 1
+ j = 2
+ k = 3
+ l = k
+
+ i = j + k
+
+ j = 0 // set breakpoint 2 here
+ k = 0
+}
diff --git a/gdb/testsuite/gdb.go/methods.exp b/gdb/testsuite/gdb.go/methods.exp
new file mode 100644
index 0000000..e63870a
--- /dev/null
+++ b/gdb/testsuite/gdb.go/methods.exp
@@ -0,0 +1,50 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test various aspects of methods.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "methods"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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}
+
+if { [go_runto_main] < 0 } {
+ untested $testfile
+ return -1
+}
+
+if { [gdb_breakpoint ${bp_location1}] } {
+ pass "setting breakpoint 1"
+}
+setup_xfail "*-*-*" ;# mangling issues IIRC
+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
+
+if { [gdb_breakpoint ${bp_location2}] } {
+ pass "setting breakpoint 2"
+}
+setup_xfail "*-*-*" ;# mangling issues IIRC
+gdb_test "cont" "Breakpoint .*:${bp_location2_regexp}.*" "Going to second breakpoint"
diff --git a/gdb/testsuite/gdb.go/methods.go b/gdb/testsuite/gdb.go/methods.go
new file mode 100644
index 0000000..563d0e4
--- /dev/null
+++ b/gdb/testsuite/gdb.go/methods.go
@@ -0,0 +1,21 @@
+package main
+
+import "fmt"
+
+type T struct { i int }
+
+func (t T) Foo () {
+ fmt.Println (t.i)
+}
+
+func (t *T) Bar () {
+ fmt.Println (t.i)
+}
+
+func main () {
+ fmt.Println ("Shall we?")
+ var t T
+ t.Foo ()
+ var pt = new (T)
+ pt.Bar ()
+}
diff --git a/gdb/testsuite/gdb.go/package.exp b/gdb/testsuite/gdb.go/package.exp
new file mode 100644
index 0000000..80d51cc
--- /dev/null
+++ b/gdb/testsuite/gdb.go/package.exp
@@ -0,0 +1,50 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test various aspects of packages.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "package"
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.go" "${binfile}2.o" object {debug go}] != "" } {
+ untested $testfile
+ return -1
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.go ${binfile}2.o" "${binfile}" executable "debug go libdir=${objdir}/${subdir}"] != "" } {
+ untested $testfile
+ return -1
+}
+
+clean_restart $testfile
+
+if { [go_runto_main] < 0 } {
+ untested methods
+ return -1
+}
+
+set bp_location1 {package2.Foo}
+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"
diff --git a/gdb/testsuite/gdb.go/package1.go b/gdb/testsuite/gdb.go/package1.go
new file mode 100644
index 0000000..ec538ba
--- /dev/null
+++ b/gdb/testsuite/gdb.go/package1.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+ "fmt"
+ "package2"
+)
+
+func main () {
+ fmt.Println ("Shall we?")
+ package2.Foo ()
+}
diff --git a/gdb/testsuite/gdb.go/package2.go b/gdb/testsuite/gdb.go/package2.go
new file mode 100644
index 0000000..de4c49a
--- /dev/null
+++ b/gdb/testsuite/gdb.go/package2.go
@@ -0,0 +1,7 @@
+package package2
+
+import "fmt"
+
+func Foo () {
+ fmt.Println ("Hi, I'm package2.Foo.")
+}
diff --git a/gdb/testsuite/gdb.go/print.exp b/gdb/testsuite/gdb.go/print.exp
new file mode 100644
index 0000000..84e6166
--- /dev/null
+++ b/gdb/testsuite/gdb.go/print.exp
@@ -0,0 +1,70 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test printing of various values.
+# NOTE: The tests here intentionally do not require a go compiler.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+proc test_float_accepted {} {
+ global gdb_prompt
+
+ # Test parsing of fp value with legit text following.
+ gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
+
+ # Test all the suffixes (including no suffix).
+ gdb_test "p 1." " = 1"
+ gdb_test "p 1.5" " = 1.5"
+ gdb_test "p 1.f" " = 1"
+ gdb_test "p 1.5f" " = 1.5"
+ gdb_test "p 1.l" " = 1"
+ gdb_test "p 1.5l" " = 1.5"
+
+ # Test hexadecimal floating point.
+ set test "p 0x1.1"
+ gdb_test_multiple $test $test {
+ -re " = 1\\.0625\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" {
+ # Older glibc does not support hex float, newer does.
+ xfail $test
+ }
+ }
+}
+
+proc test_float_rejected {} {
+ # Test bad suffixes.
+ test_print_reject "p 1.1x"
+ test_print_reject "p 1.1ff"
+ test_print_reject "p 1.1ll"
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+if [set_lang_go] {
+ test_float_accepted
+ test_float_rejected
+} else {
+ warning "Go print tests suppressed"
+}
diff --git a/gdb/testsuite/gdb.go/strings.exp b/gdb/testsuite/gdb.go/strings.exp
new file mode 100644
index 0000000..b1b3fed
--- /dev/null
+++ b/gdb/testsuite/gdb.go/strings.exp
@@ -0,0 +1,42 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "strings"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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/gdb/testsuite/gdb.go/strings.go b/gdb/testsuite/gdb.go/strings.go
new file mode 100644
index 0000000..fc62e39
--- /dev/null
+++ b/gdb/testsuite/gdb.go/strings.go
@@ -0,0 +1,10 @@
+package main
+
+import "fmt"
+
+var v_string string = "foo"
+
+func main () {
+ fmt.Println ("hello") // set breakpoint 1 here
+ fmt.Printf ("%s\n", v_string)
+}
diff --git a/gdb/testsuite/gdb.go/types.exp b/gdb/testsuite/gdb.go/types.exp
new file mode 100644
index 0000000..20ac910
--- /dev/null
+++ b/gdb/testsuite/gdb.go/types.exp
@@ -0,0 +1,51 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Various experiments with types.
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "types"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug go}] } {
+ return -1
+}
+
+if { [go_runto_main] < 0 } {
+ untested $testfile
+ return -1
+}
+
+# It's not clear yet what GCC will emit.
+# Pick something and xfail it until GCC solidifies.
+# And we still need to finish go-typeprint.c.
+
+setup_xfail "*-*-*"
+gdb_test "ptype T" "type T *T"
+
+setup_xfail "*-*-*"
+gdb_test "ptype T1" "type T1 *T2"
+setup_xfail "*-*-*"
+gdb_test "ptype T2" "type T2 *T1"
+
+setup_xfail "*-*-*"
+gdb_test "ptype S1" "type S1 struct {.*p_s2 *S2.*}"
+setup_xfail "*-*-*"
+gdb_test "ptype S2" "type S2 struct {.*p_s1 *S1.*}"
diff --git a/gdb/testsuite/gdb.go/types.go b/gdb/testsuite/gdb.go/types.go
new file mode 100644
index 0000000..be9179f
--- /dev/null
+++ b/gdb/testsuite/gdb.go/types.go
@@ -0,0 +1,24 @@
+package main
+
+import "fmt"
+
+// Self-referential type.
+type T *T
+
+// Mutually recursive types.
+type T1 *T2
+type T2 *T1
+
+// Mutually recursive struct types.
+type S1 struct { p_s2 *S2 }
+type S2 struct { p_s1 *S1 }
+
+func main () {
+ fmt.Println ("Shall we?")
+ var t T
+ fmt.Println (t)
+ var s1 S1
+ var s2 S2
+ fmt.Println (s1)
+ fmt.Println (s2)
+}
diff --git a/gdb/testsuite/gdb.go/unsafe.exp b/gdb/testsuite/gdb.go/unsafe.exp
new file mode 100644
index 0000000..1535ce2
--- /dev/null
+++ b/gdb/testsuite/gdb.go/unsafe.exp
@@ -0,0 +1,44 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test package "unsafe".
+
+load_lib "go.exp"
+
+if { [skip_go_tests] } { continue }
+
+set testfile "unsafe"
+set srcfile ${testfile}.go
+
+if { [prepare_for_testing ${testfile}.exp ${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/gdb/testsuite/gdb.go/unsafe.go b/gdb/testsuite/gdb.go/unsafe.go
new file mode 100644
index 0000000..95318bd
--- /dev/null
+++ b/gdb/testsuite/gdb.go/unsafe.go
@@ -0,0 +1,11 @@
+package main
+
+import ("fmt"
+ "unsafe")
+
+var mystring = "Shall we?"
+
+func main () {
+ fmt.Printf ("%d\n", unsafe.Sizeof (42)) // set breakpoint 1 here
+ fmt.Printf ("%d\n", unsafe.Sizeof (mystring))
+}