aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime-gdb_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-02-16 21:56:10 -0500
committerAustin Clements <austin@google.com>2015-02-17 18:41:01 +0000
commit545686857bc4c2e7a5306d97e5ef48f631d277bc (patch)
tree9cc1ab35bb691be125a5b026b0f2249c3ac500be /src/runtime/runtime-gdb_test.go
parent277eddb8f236b76c1028110ca89c9fc596f3074f (diff)
downloadgo-545686857bc4c2e7a5306d97e5ef48f631d277bc.tar.xz
runtime: fix GDB "info goroutines" for Go 1.5
"info goroutines" is failing because it hasn't kept up with changes in the 1.5 runtime. This fixes three issues preventing "info goroutines" from working. allg is no longer a linked list, so switch to using the allgs slice. The g struct's 'status' field is now called 'atomicstatus', so rename uses of 'status'. Finally, this was trying to parse str(pc) as an int, but str(pc) can return symbolic information after the raw hex value; fix this by stripping everything after the first space. This also adds a test for "info goroutines" to runtime-gdb_test, which was previously quite skeletal. Change-Id: I8ad83ee8640891cdd88ecd28dad31ed9b5833b7a Reviewed-on: https://go-review.googlesource.com/4935 Reviewed-by: Minux Ma <minux@golang.org>
Diffstat (limited to 'src/runtime/runtime-gdb_test.go')
-rw-r--r--src/runtime/runtime-gdb_test.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
index 4911dc000d..a946749f47 100644
--- a/src/runtime/runtime-gdb_test.go
+++ b/src/runtime/runtime-gdb_test.go
@@ -1,11 +1,13 @@
package runtime_test
import (
+ "bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
+ "regexp"
"runtime"
"testing"
)
@@ -30,7 +32,7 @@ func main() {
}
`
-func TestGdbLoadRuntimeSupport(t *testing.T) {
+func TestGdbPython(t *testing.T) {
checkGdbPython(t)
dir, err := ioutil.TempDir("", "go-build")
@@ -54,8 +56,27 @@ func TestGdbLoadRuntimeSupport(t *testing.T) {
got, _ := exec.Command("gdb", "-nx", "-q", "--batch", "-iex",
fmt.Sprintf("add-auto-load-safe-path %s/src/runtime", runtime.GOROOT()),
+ "-ex", "br 'main.main'",
+ "-ex", "run",
+ "-ex", "echo BEGIN info goroutines\n",
+ "-ex", "info goroutines",
+ "-ex", "echo END\n",
filepath.Join(dir, "a.exe")).CombinedOutput()
- if string(got) != "Loading Go Runtime support.\n" {
- t.Fatalf("%s", got)
+
+ firstLine := bytes.SplitN(got, []byte("\n"), 2)[0]
+ if string(firstLine) != "Loading Go Runtime support." {
+ t.Fatalf("failed to load Go runtime support: %s", firstLine)
+ }
+
+ // Extract named BEGIN...END blocks from output
+ partRe := regexp.MustCompile(`(?ms)^BEGIN ([^\n]*)\n(.*?)\nEND`)
+ blocks := map[string]string{}
+ for _, subs := range partRe.FindAllSubmatch(got, -1) {
+ blocks[string(subs[1])] = string(subs[2])
+ }
+
+ infoGoroutinesRe := regexp.MustCompile(`\d+\s+running\s+runtime`)
+ if bl := blocks["info goroutines"]; !infoGoroutinesRe.MatchString(bl) {
+ t.Fatalf("info goroutines failed: %s", bl)
}
}