Use allm info to attach to existing threads
This remove reliance on the procfs for figuring out what threads are already active when we attach to a running process. The allm linked list will be present to matter what OS we're on, whereas procfs will not be present everywhere. This is the first in a series of steps to support more platforms.
This commit is contained in:
parent
c4f79a36e5
commit
5ece8d3b69
@ -80,7 +80,25 @@ func (bpe BreakPointExistsError) Error() string {
|
||||
}
|
||||
|
||||
func Attach(pid int) (*DebuggedProcess, error) {
|
||||
return newDebugProcess(pid, true)
|
||||
dbp, err := newDebugProcess(pid, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Attach to all currently active threads.
|
||||
allm, err := dbp.CurrentThread.AllM()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, m := range allm {
|
||||
if m.procid == 0 {
|
||||
continue
|
||||
}
|
||||
_, err := dbp.AttachThread(m.procid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return dbp, nil
|
||||
}
|
||||
|
||||
func Launch(cmd []string) (*DebuggedProcess, error) {
|
||||
@ -135,14 +153,6 @@ func newDebugProcess(pid int, attach bool) (*DebuggedProcess, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Attach to all currently active threads.
|
||||
for _, tid := range threadIds(pid) {
|
||||
_, err := dbp.AttachThread(tid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &dbp, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user