binutils-gdb/gdb/testsuite/gdb.go/hello.go

10 lines
149 B
Go
Raw Normal View History

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.
2012-04-25 22:07:23 +08:00
package main
import "fmt"
func main () {
fmt.Println ("Before assignment")
[gdb/testsuite] Fix hello.go xpass With gdb.go/hello.go, we run into an xpass: ... Thread 1 "hello" hit Breakpoint 1, main.main () at hello.go:7^M 7 func main () {^M (gdb) print st^M $1 = 0x0 ""^M (gdb) XPASS: gdb.go/hello.exp: starting string check ... The xfail is setup as follows: ... \# This used to print "", i.e., the local "st" initialized as "". setup_xfail "*-*-*" gdb_test "print st" \ ".* = $hex \"\"" \ "starting string check" ... It's not clear what gccgo/gc PR this xfail refers to. It's also not clear why the empty string is both: - listed as reason for xfail, and - used in the pass pattern. Furthermore, there's a comment in the hello.go testcase: ... st := "Hello, world!" // this intentionally shadows the global "st" ... while there's no global st variable present, only a variable myst: ... var myst = "Shall we?" ... Fix this by splitting up the test-case in two test-cases, hello.{go,exp} and global-local-var-shadow.{go,exp}. In hello.exp we no longer attempt to print st before its declaration. In hello.go we remove the myst variable as well the comment related to shadowing. In global-local-var-shadow.go, we rename myst to st, such that the comment related to shadowing is correct. In global-local-var-shadow.exp we attempt to print the value of st before the local definition, which should print the value of the global definition, and xfail this with reference to GCC PR93844. Tested on x86_64-linux, with gccgo 10. gdb/testsuite/ChangeLog: 2020-02-20 Tom de Vries <tdevries@suse.de> PR go/17018 * gdb.go/hello.exp: Copy ... * gdb.go/global-local-var-shadow.exp: ... here. New file. Expect print of st to print value of global definition. Add xfail for GCC PR93844. * gdb.go/hello.exp: Remove printing of st before definition. * gdb.go/hello.go: Copy ... * gdb.go/global-local-var-shadow.go: ... here. New test. Rename myst to st. * gdb.go/hello.go: Remove myst. Remove comment about shadowing.
2020-02-21 00:46:17 +08:00
st := "Hello, world!"
fmt.Println (st) // set breakpoint 1 here
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.
2012-04-25 22:07:23 +08:00
}