diff --git a/_fixtures/traceprog.go b/_fixtures/traceprog.go new file mode 100644 index 00000000..f8ec72cb --- /dev/null +++ b/_fixtures/traceprog.go @@ -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) +} diff --git a/cmd/dlv/dlv_test.go b/cmd/dlv/dlv_test.go index b2f35d85..7e134ee2 100644 --- a/cmd/dlv/dlv_test.go +++ b/cmd/dlv/dlv_test.go @@ -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) diff --git a/pkg/proc/eval.go b/pkg/proc/eval.go index 1afa2294..d8348fe6 100644 --- a/pkg/proc/eval.go +++ b/pkg/proc/eval.go @@ -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 }