pkg/proc: do not check decl line for FunctionArguments (#3254)
Fixes a bug where we cannot get locals (including arguments and return values) from a given scope because the line number state machine ends up in an invalid state because of this parameter being set to false.
This commit is contained in:
parent
2be9cf1fab
commit
a01fe73845
13
_fixtures/traceprog.go
Normal file
13
_fixtures/traceprog.go
Normal file
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func callme(i int) int {
|
||||
return i * i
|
||||
}
|
||||
|
||||
func main() {
|
||||
j := 0
|
||||
j += callme(2)
|
||||
fmt.Println(j)
|
||||
}
|
@ -1036,6 +1036,31 @@ func TestTrace(t *testing.T) {
|
||||
cmd.Wait()
|
||||
}
|
||||
|
||||
func TestTrace2(t *testing.T) {
|
||||
dlvbin, tmpdir := getDlvBin(t)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
expected := []byte("> goroutine(1): main.callme(2)\n>> goroutine(1): => (4)\n")
|
||||
|
||||
fixtures := protest.FindFixturesDir()
|
||||
cmd := exec.Command(dlvbin, "trace", "--output", filepath.Join(tmpdir, "__debug"), filepath.Join(fixtures, "traceprog.go"), "callme")
|
||||
rdr, err := cmd.StderrPipe()
|
||||
assertNoError(err, t, "stderr pipe")
|
||||
defer rdr.Close()
|
||||
|
||||
cmd.Dir = filepath.Join(fixtures, "buildtest")
|
||||
|
||||
assertNoError(cmd.Start(), t, "running trace")
|
||||
|
||||
output, err := ioutil.ReadAll(rdr)
|
||||
assertNoError(err, t, "ReadAll")
|
||||
|
||||
if !bytes.Contains(output, expected) {
|
||||
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
|
||||
}
|
||||
cmd.Wait()
|
||||
}
|
||||
|
||||
func TestTraceMultipleGoroutines(t *testing.T) {
|
||||
dlvbin, tmpdir := getDlvBin(t)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
@ -474,7 +474,7 @@ func (scope *EvalScope) LocalVariables(cfg LoadConfig) ([]*Variable, error) {
|
||||
|
||||
// FunctionArguments returns the name, value, and type of all current function arguments.
|
||||
func (scope *EvalScope) FunctionArguments(cfg LoadConfig) ([]*Variable, error) {
|
||||
vars, err := scope.Locals(0)
|
||||
vars, err := scope.Locals(localsNoDeclLineCheck)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user