proc: handle gid == 0 in FindGoroutine
Goroutine id == 0 is special (there can be many goroutines with id 0). If the caller of FindGoroutine asks for gid==0 and current thread is running a goroutine 0 (i.e. either no goroutine or a special goroutine) return whatever goroutine is running on the current thread. Updates #1428
This commit is contained in:
parent
6611fbe919
commit
2210debf6c
@ -590,6 +590,20 @@ func FindGoroutine(dbp Process, gid int) (*G, error) {
|
|||||||
return dbp.SelectedGoroutine(), nil
|
return dbp.SelectedGoroutine(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gid == 0 {
|
||||||
|
// goroutine 0 is special, it either means we have no current goroutine
|
||||||
|
// (for example, running C code), or that we are running on a special
|
||||||
|
// stack (system stack, signal handling stack) and we didn't properly
|
||||||
|
// detect.
|
||||||
|
// If the user requested goroutine 0 and we the current thread is running
|
||||||
|
// on a goroutine 0 (or no goroutine at all) return the goroutine running
|
||||||
|
// on the current thread.
|
||||||
|
g, _ := GetG(dbp.CurrentThread())
|
||||||
|
if g == nil || g.ID == 0 {
|
||||||
|
return g, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gs, _, err := GoroutinesInfo(dbp, 0, 0)
|
gs, _, err := GoroutinesInfo(dbp, 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user