mirror of
https://github.com/go-delve/delve.git
synced 2025-10-30 18:27:37 +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
|
return allg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *G) Thread() *Thread {
|
||||||
|
return g.thread
|
||||||
|
}
|
||||||
|
|
||||||
// Halt stops all threads.
|
// Halt stops all threads.
|
||||||
func (dbp *Process) Halt() (err error) {
|
func (dbp *Process) Halt() (err error) {
|
||||||
if dbp.exited {
|
if dbp.exited {
|
||||||
|
|||||||
@ -186,11 +186,17 @@ func ConvertFunction(fn *gosym.Func) *Function {
|
|||||||
|
|
||||||
// ConvertGoroutine converts from proc.G to api.Goroutine.
|
// ConvertGoroutine converts from proc.G to api.Goroutine.
|
||||||
func ConvertGoroutine(g *proc.G) *Goroutine {
|
func ConvertGoroutine(g *proc.G) *Goroutine {
|
||||||
|
th := g.Thread()
|
||||||
|
tid := 0
|
||||||
|
if th != nil {
|
||||||
|
tid = th.ID
|
||||||
|
}
|
||||||
return &Goroutine{
|
return &Goroutine{
|
||||||
ID: g.ID,
|
ID: g.ID,
|
||||||
CurrentLoc: ConvertLocation(g.CurrentLoc),
|
CurrentLoc: ConvertLocation(g.CurrentLoc),
|
||||||
UserCurrentLoc: ConvertLocation(g.UserCurrent()),
|
UserCurrentLoc: ConvertLocation(g.UserCurrent()),
|
||||||
GoStatementLoc: ConvertLocation(g.Go()),
|
GoStatementLoc: ConvertLocation(g.Go()),
|
||||||
|
ThreadID: tid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -200,6 +200,8 @@ type Goroutine struct {
|
|||||||
UserCurrentLoc Location `json:"userCurrentLoc"`
|
UserCurrentLoc Location `json:"userCurrentLoc"`
|
||||||
// Location of the go instruction that started this goroutine
|
// Location of the go instruction that started this goroutine
|
||||||
GoStatementLoc Location `json:"goStatementLoc"`
|
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.
|
// 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"
|
locname = "Go"
|
||||||
loc = g.GoStatementLoc
|
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) {
|
func writeGoroutineLong(w io.Writer, g *api.Goroutine, prefix string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user