aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2015-04-28 22:44:40 -0400
committerMinux Ma <minux@golang.org>2015-04-29 04:44:38 +0000
commit7e49c8193c27e59935aafea4ebee0c2416831e4a (patch)
tree5b7edf79b369d1ccc8268a3b5f2e9c5a5fb44d2f /src/runtime
parent6abfdc3fdd49d7691e1cdc3028849fa40e4a41f2 (diff)
downloadgo-7e49c8193c27e59935aafea4ebee0c2416831e4a.tar.xz
runtime: skip gdb goroutine backtrace test on non-x86
Gdb is not able to backtrace our non-standard stack frames on RISC architectures without frame pointer. Change-Id: Id62a566ce2d743602ded2da22ff77b9ae34bc5ae Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/9456 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime-gdb_test.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
index d6d0003572..fe7d38a39c 100644
--- a/src/runtime/runtime-gdb_test.go
+++ b/src/runtime/runtime-gdb_test.go
@@ -64,7 +64,7 @@ func TestGdbPython(t *testing.T) {
t.Fatalf("building source %v\n%s", err, out)
}
- got, _ := exec.Command("gdb", "-nx", "-q", "--batch", "-iex",
+ args := []string{"-nx", "-q", "--batch", "-iex",
fmt.Sprintf("add-auto-load-safe-path %s/src/runtime", runtime.GOROOT()),
"-ex", "br main.go:10",
"-ex", "run",
@@ -79,11 +79,22 @@ func TestGdbPython(t *testing.T) {
"-ex", "echo END\n",
"-ex", "echo BEGIN print ptrvar\n",
"-ex", "print ptrvar",
- "-ex", "echo END\n",
- "-ex", "echo BEGIN goroutine 2 bt\n",
- "-ex", "goroutine 2 bt",
- "-ex", "echo END\n",
- filepath.Join(dir, "a.exe")).CombinedOutput()
+ "-ex", "echo END\n"}
+
+ // without framepointer, gdb cannot backtrace our non-standard
+ // stack frames on RISC architectures.
+ canBackTrace := false
+ switch runtime.GOARCH {
+ case "amd64", "386":
+ canBackTrace = true
+ args = append(args,
+ "-ex", "echo BEGIN goroutine 2 bt\n",
+ "-ex", "goroutine 2 bt",
+ "-ex", "echo END\n")
+ }
+
+ args = append(args, filepath.Join(dir, "a.exe"))
+ got, _ := exec.Command("gdb", args...).CombinedOutput()
firstLine := bytes.SplitN(got, []byte("\n"), 2)[0]
if string(firstLine) != "Loading Go Runtime support." {
@@ -117,7 +128,9 @@ func TestGdbPython(t *testing.T) {
}
btGoroutineRe := regexp.MustCompile(`^#0\s+runtime.+at`)
- if bl := blocks["goroutine 2 bt"]; !btGoroutineRe.MatchString(bl) {
+ if bl := blocks["goroutine 2 bt"]; canBackTrace && !btGoroutineRe.MatchString(bl) {
t.Fatalf("goroutine 2 bt failed: %s", bl)
+ } else if !canBackTrace {
+ t.Logf("gdb cannot backtrace for GOARCH=%s, skipped goroutine backtrace test", runtime.GOARCH)
}
}