提交 2210debf 编写于 作者: A aarzilli 提交者: Derek Parker

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
上级 6611fbe9
......@@ -590,6 +590,20 @@ func FindGoroutine(dbp Process, gid int) (*G, error) {
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)
if err != nil {
return nil, err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册