
* proc: start variable visibility one line after their decl line In most cases variables shouldn't be visible on their declaration line because they won't be initialized there. Function arguments are treated as an exception. This fix is only applied to programs compiled with Go 1.15 or later as previous versions of Go did not report the correct declaration line for variables captured by closures. Fixes #1134 * proc: silence go vet error * Makefile: enable PIE tests on windows/Go 1.15 * core: support core files for PIEs on windows * goversion: add Go 1.15 to supported versions * proc: fix function call injection for Go 1.15 Go 1.15 changed the call injection protocol so that the runtime will execute the injected call on a different (new) goroutine. This commit changes the function call support in delve to: 1. correctly track down the call injection state after the runtime switches to a different goroutine. 2. correctly perform the escapeCheck when stack values can come from multiple goroutine stacks. * proc: miscellaneous fixed for call injection under macOS with go 1.15 - create copy of SP in debugCallAXCompleteCall case because the code used to assume that regs doesn't change - fix automatic address calculation for function arguments when an argument has a spurious DW_OP_piece at entry
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package reader
|
|
|
|
import (
|
|
"debug/dwarf"
|
|
|
|
"github.com/go-delve/delve/pkg/dwarf/godwarf"
|
|
)
|
|
|
|
type Variable struct {
|
|
*godwarf.Tree
|
|
Depth int
|
|
}
|
|
|
|
// VariablesFlags specifies some configuration flags for the Variables function.
|
|
type VariablesFlags uint8
|
|
|
|
const (
|
|
VariablesOnlyVisible VariablesFlags = 1 << iota
|
|
VariablesSkipInlinedSubroutines
|
|
VariablesTrustDeclLine
|
|
)
|
|
|
|
// Variables returns a list of variables contained inside 'root'.
|
|
// If onlyVisible is true only variables visible at pc will be returned.
|
|
// If skipInlinedSubroutines is true inlined subroutines will be skipped
|
|
func Variables(root *godwarf.Tree, pc uint64, line int, flags VariablesFlags) []Variable {
|
|
return variablesInternal(nil, root, 0, pc, line, flags)
|
|
}
|
|
|
|
func variablesInternal(v []Variable, root *godwarf.Tree, depth int, pc uint64, line int, flags VariablesFlags) []Variable {
|
|
switch root.Tag {
|
|
case dwarf.TagInlinedSubroutine:
|
|
if flags&VariablesSkipInlinedSubroutines != 0 {
|
|
return v
|
|
}
|
|
fallthrough
|
|
case dwarf.TagLexDwarfBlock, dwarf.TagSubprogram:
|
|
if (flags&VariablesOnlyVisible == 0) || root.ContainsPC(pc) {
|
|
for _, child := range root.Children {
|
|
v = variablesInternal(v, child, depth+1, pc, line, flags)
|
|
}
|
|
}
|
|
return v
|
|
default:
|
|
o := 0
|
|
if root.Tag != dwarf.TagFormalParameter && (flags&VariablesTrustDeclLine != 0) {
|
|
// visibility for variables starts the line after declaration line,
|
|
// except for formal parameters, which are visible on the same line they
|
|
// are defined.
|
|
o = 1
|
|
}
|
|
if declLine, ok := root.Val(dwarf.AttrDeclLine).(int64); !ok || line >= int(declLine)+o {
|
|
return append(v, Variable{root, depth})
|
|
}
|
|
return v
|
|
}
|
|
}
|