proc: handle DW_TAG_subprogram with a nochildren abbrev

On macOS, externally linked programs will have an abbrev for
DW_TAG_subprogram without the haschildren flag set. We should handle
this case instead of expecting all DW_TAG_subprogram entries to have
list of children.

Fixes #1034
This commit is contained in:
aarzilli 2017-12-04 11:05:05 +01:00 committed by Derek Parker
parent 17bd4b52e8
commit 77c955365f
2 changed files with 19 additions and 1 deletions

@ -55,7 +55,7 @@ func (vrdr *VariableReader) Next() bool {
}
}
if recur {
if recur && vrdr.entry.Children {
vrdr.depth++
} else {
if vrdr.depth == 0 {

@ -3337,3 +3337,21 @@ func TestSystemstackStacktrace(t *testing.T) {
}
})
}
func TestIssue1034(t *testing.T) {
// The external linker on macOS produces an abbrev for DW_TAG_subprogram
// without the "has children" flag, we should support this.
withTestProcess("cgostacktest/", t, func(p proc.Process, fixture protest.Fixture) {
_, err := setFunctionBreakpoint(p, "main.main")
assertNoError(err, t, "setFunctionBreakpoint()")
assertNoError(proc.Continue(p), t, "Continue()")
frames, err := p.SelectedGoroutine().Stacktrace(10)
assertNoError(err, t, "Stacktrace")
scope := proc.FrameToScope(p, frames[2])
args, _ := scope.FunctionArguments(normalLoadConfig)
assertNoError(err, t, "FunctionArguments()")
if len(args) > 0 {
t.Fatalf("wrong number of arguments for frame %v (%d)", frames[2], len(args))
}
})
}