mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: Fix GDB integration with Python 2
A similar fix was applied in 545686857b
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>
This commit is contained in:
parent
49a5a97eea
commit
53840ad6f1
2 changed files with 9 additions and 1 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue