diff --git a/command/command.go b/command/command.go index 4fefcf77312302f44fd00a66bde89ae9680d1aa6..5246fe32a77b1170b6e2c128b9f41a445fc736b8 100644 --- a/command/command.go +++ b/command/command.go @@ -117,7 +117,23 @@ func (c *Commands) help(p *proctl.DebuggedProcess, ars ...string) error { } func threads(p *proctl.DebuggedProcess, ars ...string) error { - return p.PrintThreadInfo() + for _, th := range p.Threads { + prefix := " " + if th == p.CurrentThread { + prefix = "* " + } + pc, err := th.CurrentPC() + if err != nil { + return err + } + f, l, fn := th.Process.GoSymTable.PCToLine(pc) + if fn != nil { + fmt.Printf("%sThread %d at %#v %s:%d %s\n", prefix, th.Id, pc, f, l, fn.Name) + } else { + fmt.Printf("%sThread %d at %#v\n", prefix, th.Id, pc) + } + } + return nil } func goroutines(p *proctl.DebuggedProcess, ars ...string) error { diff --git a/proctl/proctl.go b/proctl/proctl.go index 0c2372c046eb59c42181a904b45c6c1bdf1000e6..d8a2e8d118aa87e8da19a96db52a3c71f38c4af2 100644 --- a/proctl/proctl.go +++ b/proctl/proctl.go @@ -198,17 +198,6 @@ func (dbp *DebuggedProcess) Status() *sys.WaitStatus { return dbp.CurrentThread.Status } -// Loop through all threads, printing their information -// to the console. -func (dbp *DebuggedProcess) PrintThreadInfo() error { - for _, th := range dbp.Threads { - if err := th.PrintInfo(); err != nil { - return err - } - } - return nil -} - // Step over function calls. func (dbp *DebuggedProcess) Next() error { var runnable []*ThreadContext diff --git a/proctl/threads.go b/proctl/threads.go index 88c8f23efb6948905d5848fe1852a0fccd463ba7..f3593b7c7b77ebde474d2b169cbdd3c0e7413dfe 100644 --- a/proctl/threads.go +++ b/proctl/threads.go @@ -49,22 +49,6 @@ func (thread *ThreadContext) CurrentPC() (uint64, error) { return regs.PC(), nil } -// PrintInfo prints out the thread status -// including: PC, tid, file, line, and function. -func (thread *ThreadContext) PrintInfo() error { - pc, err := thread.CurrentPC() - if err != nil { - return err - } - f, l, fn := thread.Process.GoSymTable.PCToLine(pc) - if fn != nil { - fmt.Printf("Thread %d at %#v %s:%d %s\n", thread.Id, pc, f, l, fn.Name) - } else { - fmt.Printf("Thread %d at %#v\n", thread.Id, pc) - } - return nil -} - // Continue the execution of this thread. This method takes // software breakpoints into consideration and ensures that // we step over any breakpoints. It will restore the instruction,