mirror of
https://github.com/go-delve/delve.git
synced 2025-11-03 05:47:34 +08:00
Add command to print every thread status
This commit is contained in:
@ -31,6 +31,7 @@ func DebugCommands() *Commands {
|
||||
"step": step,
|
||||
"clear": clear,
|
||||
"print": printVar,
|
||||
"threads": threads,
|
||||
"": nullCommand,
|
||||
}
|
||||
|
||||
@ -82,6 +83,11 @@ func help(p *proctl.DebuggedProcess, ars ...string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func threads(p *proctl.DebuggedProcess, ars ...string) error {
|
||||
return p.PrintThreadInfo()
|
||||
}
|
||||
|
||||
func cont(p *proctl.DebuggedProcess, ars ...string) error {
|
||||
err := p.Continue()
|
||||
if err != nil {
|
||||
|
||||
@ -198,6 +198,15 @@ func (dbp *DebuggedProcess) Status() *syscall.WaitStatus {
|
||||
return dbp.CurrentThread.Status
|
||||
}
|
||||
|
||||
func (dbp *DebuggedProcess) PrintThreadInfo() error {
|
||||
for _, th := range dbp.Threads {
|
||||
if err := th.PrintInfo(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Finds the executable from /proc/<pid>/exe and then
|
||||
// uses that to parse the following information:
|
||||
// * Dwarf .debug_frame section
|
||||
|
||||
@ -48,6 +48,16 @@ func (thread *ThreadContext) CurrentPC() (uint64, error) {
|
||||
return regs.PC(), nil
|
||||
}
|
||||
|
||||
func (thread *ThreadContext) PrintInfo() error {
|
||||
pc, err := thread.CurrentPC()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, l, fn := thread.Process.GoSymTable.PCToLine(pc)
|
||||
fmt.Printf("Thread %d at %#v %s:%d %s\n", thread.Id, pc, f, l, fn.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sets a software breakpoint at addr, and stores it in the process wide
|
||||
// break point table. Setting a break point must be thread specific due to
|
||||
// ptrace actions needing the thread to be in a signal-delivery-stop in order
|
||||
|
||||
Reference in New Issue
Block a user