feat: print a message when the debuggee process exits (#3870)
Co-authored-by: Jake Ng <jakejx.ng@gmail.com>
This commit is contained in:
parent
5d82dc10dc
commit
9af09688ea
@ -1319,6 +1319,7 @@ func (d *Debugger) Command(command *api.DebuggerCommand, resumeNotify chan struc
|
|||||||
state.Exited = true
|
state.Exited = true
|
||||||
state.ExitStatus = errProcessExited.Status
|
state.ExitStatus = errProcessExited.Status
|
||||||
state.Err = errProcessExited
|
state.Err = errProcessExited
|
||||||
|
d.maybePrintUnattendedStopWarning(proc.StopExited, state.CurrentThread, clientStatusCh)
|
||||||
return state, nil
|
return state, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1341,7 +1342,7 @@ func (d *Debugger) Command(command *api.DebuggerCommand, resumeNotify chan struc
|
|||||||
d.amendBreakpoint(bp)
|
d.amendBreakpoint(bp)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.maybePrintUnattendedBreakpointWarning(d.target.Selected.StopReason, state.CurrentThread, clientStatusCh)
|
d.maybePrintUnattendedStopWarning(d.target.Selected.StopReason, state.CurrentThread, clientStatusCh)
|
||||||
return state, err
|
return state, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2498,7 +2499,7 @@ func attachErrorMessageDefault(pid int, err error) error {
|
|||||||
return fmt.Errorf("could not attach to pid %d: %s", pid, err)
|
return fmt.Errorf("could not attach to pid %d: %s", pid, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Debugger) maybePrintUnattendedBreakpointWarning(stopReason proc.StopReason, currentThread *api.Thread, clientStatusCh <-chan struct{}) {
|
func (d *Debugger) maybePrintUnattendedStopWarning(stopReason proc.StopReason, currentThread *api.Thread, clientStatusCh <-chan struct{}) {
|
||||||
select {
|
select {
|
||||||
case <-clientStatusCh:
|
case <-clientStatusCh:
|
||||||
// the channel will be closed if the client that sends the command has left
|
// the channel will be closed if the client that sends the command has left
|
||||||
@ -2507,6 +2508,17 @@ func (d *Debugger) maybePrintUnattendedBreakpointWarning(stopReason proc.StopRea
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if currentThread == nil || currentThread.Breakpoint == nil {
|
||||||
|
switch stopReason {
|
||||||
|
case proc.StopManual:
|
||||||
|
// print nothing
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
fmt.Fprintln(os.Stderr, "Stop reason: "+stopReason.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const defaultStackTraceDepth = 50
|
const defaultStackTraceDepth = 50
|
||||||
frames, err := d.stacktrace(currentThread.GoroutineID, defaultStackTraceDepth, 0)
|
frames, err := d.stacktrace(currentThread.GoroutineID, defaultStackTraceDepth, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2521,17 +2533,6 @@ func (d *Debugger) maybePrintUnattendedBreakpointWarning(stopReason proc.StopRea
|
|||||||
}
|
}
|
||||||
|
|
||||||
bp := currentThread.Breakpoint
|
bp := currentThread.Breakpoint
|
||||||
if bp == nil {
|
|
||||||
switch stopReason {
|
|
||||||
case proc.StopManual:
|
|
||||||
// print nothing
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
fmt.Fprintln(os.Stderr, "Stop reason: "+stopReason.String())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch bp.Name {
|
switch bp.Name {
|
||||||
case proc.FatalThrow, proc.UnrecoveredPanic:
|
case proc.FatalThrow, proc.UnrecoveredPanic:
|
||||||
fmt.Fprintln(os.Stderr, "\n** execution is paused because your program is panicking **")
|
fmt.Fprintln(os.Stderr, "\n** execution is paused because your program is panicking **")
|
||||||
|
Loading…
Reference in New Issue
Block a user