aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
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
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')
-rw-r--r--gdb/testsuite/ChangeLog33
-rwxr-xr-xgdb/testsuite/configure3
-rw-r--r--gdb/testsuite/configure.ac2
-rw-r--r--gdb/testsuite/gdb.base/default.exp2
-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
-rw-r--r--gdb/testsuite/lib/future.exp94
-rw-r--r--gdb/testsuite/lib/gdb.exp6
-rw-r--r--gdb/testsuite/lib/go.exp37
29 files changed, 1041 insertions, 7 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8c1fd30..6c2ca58 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,36 @@
+2012-04-25 Doug Evans <dje@google.com>
+
+ * 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.
+
2012-04-25 Tom Tromey <tromey@redhat.com>
* gdb.threads/linux-dp.exp: Unset 'seen' before 'array set'.
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index fb70b3d..0c8c344 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -3448,7 +3448,7 @@ done
-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -4158,6 +4158,7 @@ do
"gdb.disasm/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.disasm/Makefile" ;;
"gdb.dwarf2/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.dwarf2/Makefile" ;;
"gdb.fortran/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.fortran/Makefile" ;;
+ "gdb.go/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.go/Makefile" ;;
"gdb.server/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.server/Makefile" ;;
"gdb.java/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.java/Makefile" ;;
"gdb.hp/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.hp/Makefile" ;;
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 5735805..d9ab9f7 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -91,7 +91,7 @@ AC_OUTPUT([Makefile \
gdb.ada/Makefile \
gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile \
gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
- gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile \
+ gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile \
gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile \
gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \
gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile \
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index c656a20..e2859d5 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -528,7 +528,7 @@ gdb_test "set history size" "Argument required .integer to set it to.*" "set his
#test set history
gdb_test "set history" "\"set history\" must be followed by the name of a history subcommand.(\[^\r\n\]*\[\r\n\])+List of set history subcommands:(\[^\r\n\]*\[\r\n\])+set history expansion -- Set history expansion on command input(\[^\r\n\]*\[\r\n\])+set history filename -- Set the filename in which to record the command history(\[^\r\n\]*\[\r\n\])+set history save -- Set saving of the history record on exit(\[^\r\n\]*\[\r\n\])+set history size -- Set the size of the command history(\[^\r\n\]*\[\r\n\])+Type \"help set history\" followed by set history subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set history"
#test set language
-gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, c, c.., asm, minimal, d, fortran, objective-c, java, modula-2, opencl, pascal." "set language"
+gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, c, c.., asm, minimal, d, fortran, objective-c, go, java, modula-2, opencl, pascal." "set language"
#test set listsize
gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
#test set print "p" abbreviation
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))
+}
diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index 4e26dcb..40456c0 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -60,6 +60,30 @@ proc gdb_find_gfortran {} {
return $CC
}
+proc gdb_find_go {} {
+ global tool_root_dir
+
+ set GO ""
+
+ if {![is_remote host]} {
+ set file [lookfor_file $tool_root_dir gccgo]
+ if { $file != "" } {
+ set root [file dirname $file]
+ set GO "$file -B$root/gcc/"
+ }
+ }
+
+ if { $GO == "" } {
+ set GO [transform gccgo]
+ }
+
+ return $GO
+}
+
+proc gdb_find_go_linker {} {
+ return [find_go]
+}
+
proc gdb_default_target_compile {source destfile type options} {
global target_triplet
global tool_root_dir
@@ -74,6 +98,11 @@ proc gdb_default_target_compile {source destfile type options} {
set libs ""
set compiler_type "c"
set compiler ""
+ set linker ""
+ # linker_opts_order is one of "sources-then-flags", "flags-then-sources".
+ # The order shouldn't matter. It's done this way to preserve
+ # existing behavior.
+ set linker_opts_order "sources-then-flags"
set ldflags ""
set dest [target_info name]
@@ -138,6 +167,26 @@ proc gdb_default_target_compile {source destfile type options} {
}
}
+ if { $i == "go" } {
+ set compiler_type "go"
+ if {[board_info $dest exists goflags]} {
+ append add_flags " [target_info goflags]"
+ }
+ if {[board_info $dest exists gocompiler]} {
+ set compiler [target_info gocompiler]
+ } else {
+ set compiler [find_go]
+ }
+ if {[board_info $dest exists golinker]} {
+ set linker [target_info golinker]
+ } else {
+ set linker [find_go_linker]
+ }
+ if {[board_info $dest exists golinker_opts_order]} {
+ set linker_opts_order [target_info golinker_opts_order]
+ }
+ }
+
if {[regexp "^dest=" $i]} {
regsub "^dest=" $i "" tmp
if {[board_info $tmp exists name]} {
@@ -193,6 +242,8 @@ proc gdb_default_target_compile {source destfile type options} {
global F77_FOR_TARGET
global F90_FOR_TARGET
global GNATMAKE_FOR_TARGET
+ global GO_FOR_TARGET
+ global GO_LD_FOR_TARGET
if {[info exists GNATMAKE_FOR_TARGET]} {
if { $compiler_type == "ada" } {
@@ -224,6 +275,19 @@ proc gdb_default_target_compile {source destfile type options} {
}
}
+ if { $compiler_type == "go" } {
+ if {[info exists GO_FOR_TARGET]} {
+ set compiler $GO_FOR_TARGET
+ }
+ if {[info exists GO_LD_FOR_TARGET]} {
+ set linker $GO_LD_FOR_TARGET
+ }
+ }
+
+ if { $type == "executable" && $linker != "" } {
+ set compiler $linker
+ }
+
if { $compiler == "" } {
set compiler [board_info $dest compiler]
if { $compiler == "" } {
@@ -366,10 +430,26 @@ proc gdb_default_target_compile {source destfile type options} {
# This is obscure: we put SOURCES at the end when building an
# object, because otherwise, in some situations, libtool will
# become confused about the name of the actual source file.
- if {$type == "object"} {
- set opts "$add_flags $sources"
- } else {
- set opts "$sources $add_flags"
+ switch $type {
+ "object" {
+ set opts "$add_flags $sources"
+ }
+ "executable" {
+ switch $linker_opts_order {
+ "flags-then-sources" {
+ set opts "$add_flags $sources"
+ }
+ "sources-then-flags" {
+ set opts "$sources $add_flags"
+ }
+ default {
+ error "Invalid value for board_info linker_opts_order"
+ }
+ }
+ }
+ default {
+ set opts "$sources $add_flags"
+ }
}
if {[is_remote host]} {
@@ -431,6 +511,12 @@ if {[info procs find_gfortran] == ""} {
set use_gdb_compile 1
}
+if {[info procs find_go_linker] == ""} {
+ rename gdb_find_go find_go
+ rename gdb_find_go_linker find_go_linker
+ # No need to set use_gdb_compile.
+}
+
if {$use_gdb_compile} {
catch {rename default_target_compile {}}
rename gdb_default_target_compile default_target_compile
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index ccf5e98..83faf59 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1440,6 +1440,12 @@ proc skip_ada_tests {} {
return 0
}
+# Return a 1 if I don't even want to try to test GO.
+
+proc skip_go_tests {} {
+ return 0
+}
+
# Return a 1 if I don't even want to try to test java.
proc skip_java_tests {} {
diff --git a/gdb/testsuite/lib/go.exp b/gdb/testsuite/lib/go.exp
new file mode 100644
index 0000000..e8466bb
--- /dev/null
+++ b/gdb/testsuite/lib/go.exp
@@ -0,0 +1,37 @@
+# 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/>.
+
+# FIXME: Presumably skip_go_tests should be defined here,
+# but for consistency with other languages it currently lives in gdb.exp.
+
+# Auxiliary function to set the language to Go.
+# The result is 1 (true) for success, 0 (false) for failure.
+
+proc set_lang_go {} {
+ if [gdb_test_no_output "set language go"] {
+ return 0
+ }
+ if [gdb_test "show language" ".* source language is \"go\"." \
+ "set language to \"go\""] {
+ return 0
+ }
+ return 1
+}
+
+# Go version of runto_main.
+
+proc go_runto_main { } {
+ return [runto main.main]
+}