]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Fix GDB integration with Python 2
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>
Fri, 10 Apr 2015 19:13:04 +0000 (15:13 -0400)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Apr 2015 22:17:59 +0000 (22:17 +0000)
A similar fix was applied in 545686857bc4c2e7a5306d97e5ef48f631d277bc
but another instance of 'pc' was missed.

Also adds a test for the goroutine gdb command.

It currently uses goroutine 2 for the test, since goroutine 1 has
its stack pointer set to 0 for some reason.

Change-Id: I53ca22be6952f03a862edbdebd9b5c292e0853ae
Reviewed-on: https://go-review.googlesource.com/8729
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/runtime/runtime-gdb.py
src/runtime/runtime-gdb_test.go

index c70aea71bb75f1cc4b64c326339e8a09e3592a42..e57fa00e1a4dd3f6cc62534ad5a1efcfce964d67 100644 (file)
@@ -446,7 +446,7 @@ class GoroutineCmd(gdb.Command):
                        #python3 / newer versions of gdb
                        pc = int(pc)
                except gdb.error:
-                       pc = int(str(pc), 16)
+                       pc = int(str(pc).split(None, 1)[0], 16)
                save_frame = gdb.selected_frame()
                gdb.parse_and_eval('$save_pc = $pc')
                gdb.parse_and_eval('$save_sp = $sp')
index 7569d074665c426a8de333eea04901521846ada3..d6d00035720155c60e798d23938320137e2acaeb 100644 (file)
@@ -80,6 +80,9 @@ func TestGdbPython(t *testing.T) {
                "-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()
 
        firstLine := bytes.SplitN(got, []byte("\n"), 2)[0]
@@ -112,4 +115,9 @@ func TestGdbPython(t *testing.T) {
        if bl := blocks["print ptrvar"]; !strVarRe.MatchString(bl) {
                t.Fatalf("print ptrvar failed: %s", bl)
        }
+
+       btGoroutineRe := regexp.MustCompile(`^#0\s+runtime.+at`)
+       if bl := blocks["goroutine 2 bt"]; !btGoroutineRe.MatchString(bl) {
+               t.Fatalf("goroutine 2 bt failed: %s", bl)
+       }
 }