Update thread printing, now denotes current thread
Also refactored code a bit, removed printing functions from proctl package and inlined them into command.
This commit is contained in:
parent
8a911d7fd2
commit
9f70f43f5c
@ -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 {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user