func (d *Debugger) Threads() []*api.Thread { threads := []*api.Thread{} for _, th := range d.process.Threads { threads = append(threads, api.ConvertThread(th)) } return threads }
// State returns the current state of the debugger. func (d *Debugger) State() (*api.DebuggerState, error) { if d.process.Exited() { return nil, proc.ProcessExitedError{Pid: d.ProcessPid()} } var ( state *api.DebuggerState goroutine *api.Goroutine ) if d.process.SelectedGoroutine != nil { goroutine = api.ConvertGoroutine(d.process.SelectedGoroutine) } state = &api.DebuggerState{ SelectedGoroutine: goroutine, Exited: d.process.Exited(), } for i := range d.process.Threads { th := api.ConvertThread(d.process.Threads[i]) state.Threads = append(state.Threads, th) if i == d.process.CurrentThread.ID { state.CurrentThread = th } } return state, nil }
func (d *Debugger) State() (*api.DebuggerState, error) { if d.process.Exited() { return nil, proc.ProcessExitedError{Pid: d.ProcessPid()} } var ( state *api.DebuggerState thread *api.Thread goroutine *api.Goroutine ) if d.process.CurrentThread != nil { thread = api.ConvertThread(d.process.CurrentThread) } if d.process.SelectedGoroutine != nil { goroutine = api.ConvertGoroutine(d.process.SelectedGoroutine) } var breakpoint *api.Breakpoint bp := d.process.CurrentBreakpoint() if bp != nil { breakpoint = api.ConvertBreakpoint(bp) } state = &api.DebuggerState{ Breakpoint: breakpoint, CurrentThread: thread, SelectedGoroutine: goroutine, Exited: d.process.Exited(), } return state, nil }
// Threads returns the threads of the target process. func (d *Debugger) Threads() ([]*api.Thread, error) { if d.process.Exited() { return nil, &proc.ProcessExitedError{} } threads := []*api.Thread{} for _, th := range d.process.Threads { threads = append(threads, api.ConvertThread(th)) } return threads, nil }
// FindThread returns the thread for the given 'id'. func (d *Debugger) FindThread(id int) (*api.Thread, error) { d.processMutex.Lock() defer d.processMutex.Unlock() if d.process.Exited() { return nil, &proc.ProcessExitedError{} } for _, th := range d.process.Threads { if th.ID == id { return api.ConvertThread(th), nil } } return nil, nil }
func (d *Debugger) State() (*api.DebuggerState, error) { var ( state *api.DebuggerState thread *api.Thread ) th := d.process.CurrentThread if th != nil { thread = api.ConvertThread(th) } var breakpoint *api.Breakpoint bp := d.process.CurrentBreakpoint() if bp != nil { breakpoint = api.ConvertBreakpoint(bp) } state = &api.DebuggerState{ Breakpoint: breakpoint, CurrentThread: thread, Exited: d.process.Exited(), } return state, nil }