mirror of
https://github.com/go-delve/delve.git
synced 2025-10-27 20:23:41 +08:00
Refactor: Use thread-locked goroutine for ptrace ops
Previously either the terminal client or the debugger service would either lock main goroutine to a thread or provide a locked goroutine to run _all_ DebuggedProcess functions in. This is unnecessary because only ptrace functions need to be run from the same thread that originated the PT_ATTACH request. Here we use a specific thread-locked goroutine to service any ptrace request. That goroutine is also responsible for the initial spawning / attaching of the process, since it must be responsible for the PT_ATTACH request.
This commit is contained in:
@ -10,20 +10,22 @@ import (
|
||||
protest "github.com/derekparker/delve/proc/test"
|
||||
)
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(2)
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
protest.RunTestsWithFixtures(m)
|
||||
}
|
||||
|
||||
func withTestProcess(name string, t *testing.T, fn func(p *DebuggedProcess, fixture protest.Fixture)) {
|
||||
runtime.LockOSThread()
|
||||
|
||||
fixture := protest.BuildFixture(name)
|
||||
p, err := Launch([]string{fixture.Path})
|
||||
if err != nil {
|
||||
t.Fatal("Launch():", err)
|
||||
}
|
||||
|
||||
defer p.Detach()
|
||||
defer p.Detach(true)
|
||||
|
||||
fn(p, fixture)
|
||||
}
|
||||
@ -88,6 +90,7 @@ func TestExit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHalt(t *testing.T) {
|
||||
runtime.GOMAXPROCS(2)
|
||||
withTestProcess("testprog", t, func(p *DebuggedProcess, fixture protest.Fixture) {
|
||||
go func() {
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user