Skip to content

Commit

Permalink
stack: add support for Go 1.13beta1
Browse files Browse the repository at this point in the history
It now prints 'pc' in addition to 'fp' and 'sp'.

Include unit test.
  • Loading branch information
maruel committed Jul 19, 2019
1 parent c1498ae commit e9f3b5d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stack/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var (
// when a signal is not correctly handled. It is printed with m.throwing>0.
// These are discarded.
// - For cgo, the source file may be "??".
reFile = regexp.MustCompile("^(?:\t| +)(\\?\\?|\\<autogenerated\\>|.+\\.(?:c|go|s))\\:(\\d+)(?:| \\+0x[0-9a-f]+)(?:| fp=0x[0-9a-f]+ sp=0x[0-9a-f]+)$")
reFile = regexp.MustCompile("^(?:\t| +)(\\?\\?|\\<autogenerated\\>|.+\\.(?:c|go|s))\\:(\\d+)(?:| \\+0x[0-9a-f]+)(?:| fp=0x[0-9a-f]+ sp=0x[0-9a-f]+(?:| pc=0x[0-9a-f]+))$")
// Sadly, it doesn't note the goroutine number so we could cascade them per
// parenthood.
reCreated = regexp.MustCompile("^created by (.+)$")
Expand Down
36 changes: 36 additions & 0 deletions stack/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,42 @@ func TestParseDumpAsm(t *testing.T) {
compareString(t, "panic: reflect.Set: value of type\n\n", extra.String())
}

func TestParseDumpAsmGo1dot13(t *testing.T) {
data := []string{
"panic: reflect.Set: value of type",
"",
"goroutine 16 [garbage collection]:",
"runtime.switchtoM()",
"\t/goroot/src/runtime/asm_amd64.s:198 fp=0xc20cfb80d8 sp=0xc20cfb80d0 pc=0x5007be",
"",
}
extra := &bytes.Buffer{}
c, err := ParseDump(bytes.NewBufferString(strings.Join(data, "\n")), extra, false)
if err != nil {
t.Fatal(err)
}
expected := []*Goroutine{
{
Signature: Signature{
State: "garbage collection",
Stack: Stack{
Calls: []Call{
{
SrcPath: "/goroot/src/runtime/asm_amd64.s",
Line: 198,
Func: Func{Raw: "runtime.switchtoM"},
},
},
},
},
ID: 16,
First: true,
},
}
compareGoroutines(t, expected, c.Goroutines)
compareString(t, "panic: reflect.Set: value of type\n\n", extra.String())
}

func TestParseDumpLineErr(t *testing.T) {
data := []string{
"panic: reflect.Set: value of type",
Expand Down

0 comments on commit e9f3b5d

Please sign in to comment.