mirror of
https://github.com/go-delve/delve.git
synced 2025-10-30 02:07:58 +08:00
terminal: show current thread of goroutines (#564)
This commit is contained in:
committed by
Derek Parker
parent
ede880134c
commit
7761faad5b
@ -620,6 +620,10 @@ func (dbp *Process) GoroutinesInfo() ([]*G, error) {
|
||||
return allg, nil
|
||||
}
|
||||
|
||||
func (g *G) Thread() *Thread {
|
||||
return g.thread
|
||||
}
|
||||
|
||||
// Halt stops all threads.
|
||||
func (dbp *Process) Halt() (err error) {
|
||||
if dbp.exited {
|
||||
|
||||
@ -186,11 +186,17 @@ func ConvertFunction(fn *gosym.Func) *Function {
|
||||
|
||||
// ConvertGoroutine converts from proc.G to api.Goroutine.
|
||||
func ConvertGoroutine(g *proc.G) *Goroutine {
|
||||
th := g.Thread()
|
||||
tid := 0
|
||||
if th != nil {
|
||||
tid = th.ID
|
||||
}
|
||||
return &Goroutine{
|
||||
ID: g.ID,
|
||||
CurrentLoc: ConvertLocation(g.CurrentLoc),
|
||||
UserCurrentLoc: ConvertLocation(g.UserCurrent()),
|
||||
GoStatementLoc: ConvertLocation(g.Go()),
|
||||
ThreadID: tid,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -200,6 +200,8 @@ type Goroutine struct {
|
||||
UserCurrentLoc Location `json:"userCurrentLoc"`
|
||||
// Location of the go instruction that started this goroutine
|
||||
GoStatementLoc Location `json:"goStatementLoc"`
|
||||
// ID of the associated thread for running goroutines
|
||||
ThreadID int `json:"threadID"`
|
||||
}
|
||||
|
||||
// DebuggerCommand is a command which changes the debugger's execution state.
|
||||
|
||||
@ -547,7 +547,11 @@ func formatGoroutine(g *api.Goroutine, fgl formatGoroutineLoc) string {
|
||||
locname = "Go"
|
||||
loc = g.GoStatementLoc
|
||||
}
|
||||
return fmt.Sprintf("%d - %s: %s", g.ID, locname, formatLocation(loc))
|
||||
thread := ""
|
||||
if g.ThreadID != 0 {
|
||||
thread = fmt.Sprintf(" (thread %d)", g.ThreadID)
|
||||
}
|
||||
return fmt.Sprintf("%d - %s: %s%s", g.ID, locname, formatLocation(loc), thread)
|
||||
}
|
||||
|
||||
func writeGoroutineLong(w io.Writer, g *api.Goroutine, prefix string) {
|
||||
|
||||
Reference in New Issue
Block a user