delve/pkg/proc/variable_test.go
Derek Parker 94a20d57da
pkg/proc: Introduce Target and remove CommonProcess (#1834)
* pkg/proc: Introduce Target

* pkg/proc: Remove Common.fncallEnabled

Realistically we only block it on recorded backends.

* pkg/proc: Move fncallForG to Target

* pkg/proc: Remove CommonProcess

Remove final bit of functionality stored in CommonProcess and move it to
*Target.

* pkg/proc: Add SupportsFunctionCall to Target
2020-01-21 12:41:24 -08:00

45 lines
1.3 KiB
Go

package proc_test
import (
"path/filepath"
"testing"
"github.com/go-delve/delve/pkg/proc"
protest "github.com/go-delve/delve/pkg/proc/test"
)
func TestGoroutineCreationLocation(t *testing.T) {
protest.AllowRecording(t)
withTestProcess("goroutinestackprog", t, func(p *proc.Target, fixture protest.Fixture) {
bp := setFunctionBreakpoint(p, t, "main.agoroutine")
assertNoError(proc.Continue(p), t, "Continue()")
gs, _, err := proc.GoroutinesInfo(p, 0, 0)
assertNoError(err, t, "GoroutinesInfo")
for _, g := range gs {
currentLocation := g.UserCurrent()
currentFn := currentLocation.Fn
if currentFn != nil && currentFn.BaseName() == "agoroutine" {
createdLocation := g.Go()
if createdLocation.Fn == nil {
t.Fatalf("goroutine creation function is nil")
}
if createdLocation.Fn.BaseName() != "main" {
t.Fatalf("goroutine creation function has wrong name: %s", createdLocation.Fn.BaseName())
}
if filepath.Base(createdLocation.File) != "goroutinestackprog.go" {
t.Fatalf("goroutine creation file incorrect: %s", filepath.Base(createdLocation.File))
}
if createdLocation.Line != 23 {
t.Fatalf("goroutine creation line incorrect: %v", createdLocation.Line)
}
}
}
p.ClearBreakpoint(bp.Addr)
proc.Continue(p)
})
}