Skip to content

Commit

Permalink
proc: support stepping through range-over-func statements with inlini…
Browse files Browse the repository at this point in the history
…ng (#3755)

Extends support for stepping through range-over-func statement to
programs compiled with inlining enabled.

Updates #3733
  • Loading branch information
aarzilli authored Jul 1, 2024
1 parent faac701 commit 608eaa3
Show file tree
Hide file tree
Showing 5 changed files with 612 additions and 35 deletions.
8 changes: 4 additions & 4 deletions pkg/dwarf/reader/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ const (
// returned. If the VariablesSkipInlinedSubroutines is set, variables from
// 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)
return variablesInternal(nil, root, 0, pc, line, flags, true)
}

// variablesInternal appends to 'v' variables from 'root'. The function calls
// itself with an incremented scope for all sub-blocks in 'root'.
func variablesInternal(v []Variable, root *godwarf.Tree, depth int, pc uint64, line int, flags VariablesFlags) []Variable {
func variablesInternal(v []Variable, root *godwarf.Tree, depth int, pc uint64, line int, flags VariablesFlags, first bool) []Variable {
switch root.Tag {
case dwarf.TagInlinedSubroutine:
if flags&VariablesSkipInlinedSubroutines != 0 {
if !first && flags&VariablesSkipInlinedSubroutines != 0 {
return v
}
fallthrough
Expand All @@ -50,7 +50,7 @@ func variablesInternal(v []Variable, root *godwarf.Tree, depth int, pc uint64, l
// pc (or if we don't care about visibility).
if (flags&VariablesOnlyVisible == 0) || root.ContainsPC(pc) {
for _, child := range root.Children {
v = variablesInternal(v, child, depth+1, pc, line, flags)
v = variablesInternal(v, child, depth+1, pc, line, flags, false)
}
}
return v
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (scope *EvalScope) simpleLocals(flags localsFlags, wantedName string) ([]*V
return nil, err
}

variablesFlags := reader.VariablesOnlyVisible
variablesFlags := reader.VariablesOnlyVisible | reader.VariablesSkipInlinedSubroutines
if flags&localsNoDeclLineCheck != 0 {
variablesFlags = reader.VariablesNoDeclLineCheck
}
Expand Down
Loading

0 comments on commit 608eaa3

Please sign in to comment.