diff options
Diffstat (limited to 'libgo/go/runtime/testdata')
-rw-r--r-- | libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go | 40 | ||||
-rw-r--r-- | libgo/go/runtime/testdata/testprogcxx/main.go | 35 | ||||
-rw-r--r-- | libgo/go/runtime/testdata/testprogcxx/traceback.cc | 19 | ||||
-rw-r--r-- | libgo/go/runtime/testdata/testprogcxx/traceback.go | 24 |
4 files changed, 118 insertions, 0 deletions
diff --git a/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go b/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go new file mode 100644 index 00000000000..83357fdd5d9 --- /dev/null +++ b/libgo/go/runtime/testdata/testprogcgo/traceback_gccgo.go @@ -0,0 +1,40 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build gccgo + +package main + +// This program will crash. +// We want the stack trace to include the C functions. + +/* +#cgo CFLAGS: -g -O0 + +#include <stdint.h> + +char *p; + +static int CFunction3(void) { + *p = 0; + return 0; +} + +static int CFunction2(void) { + return CFunction3(); +} + +static int CFunction1(void) { + return CFunction2(); +} +*/ +import "C" + +func init() { + register("CrashTracebackGccgo", CrashTracebackGccgo) +} + +func CrashTracebackGccgo() { + C.CFunction1() +} diff --git a/libgo/go/runtime/testdata/testprogcxx/main.go b/libgo/go/runtime/testdata/testprogcxx/main.go new file mode 100644 index 00000000000..0ecab1079c6 --- /dev/null +++ b/libgo/go/runtime/testdata/testprogcxx/main.go @@ -0,0 +1,35 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "os" + +var cmds = map[string]func(){} + +func register(name string, f func()) { + if cmds[name] != nil { + panic("duplicate registration: " + name) + } + cmds[name] = f +} + +func registerInit(name string, f func()) { + if len(os.Args) >= 2 && os.Args[1] == name { + f() + } +} + +func main() { + if len(os.Args) < 2 { + println("usage: " + os.Args[0] + " name-of-test") + return + } + f := cmds[os.Args[1]] + if f == nil { + println("unknown function: " + os.Args[1]) + return + } + f() +} diff --git a/libgo/go/runtime/testdata/testprogcxx/traceback.cc b/libgo/go/runtime/testdata/testprogcxx/traceback.cc new file mode 100644 index 00000000000..d4bd26cf768 --- /dev/null +++ b/libgo/go/runtime/testdata/testprogcxx/traceback.cc @@ -0,0 +1,19 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +char *p; + +static int cxxFunction3() { + *p = 0; + return 0; +} + +static int cxxFunction2() { + return cxxFunction3(); +} + +extern "C" +int cxxFunction1() { + return cxxFunction2(); +} diff --git a/libgo/go/runtime/testdata/testprogcxx/traceback.go b/libgo/go/runtime/testdata/testprogcxx/traceback.go new file mode 100644 index 00000000000..0e40ca8ffbb --- /dev/null +++ b/libgo/go/runtime/testdata/testprogcxx/traceback.go @@ -0,0 +1,24 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +// This program will crash. +// We want the stack trace to include the C++ functions, +// even though we compile with -g0. + +/* +#cgo CXXFLAGS: -g0 -O0 + +extern int cxxFunction1(void); +*/ +import "C" + +func init() { + register("CrashTracebackNodebug", CrashTracebackNodebug) +} + +func CrashTracebackNodebug() { + C.cxxFunction1() +} |