mirror of
https://github.com/go-delve/delve.git
synced 2025-11-01 20:20:40 +08:00
proc: Breakpoint to catch unrecovered panics
Automatically sets a breakpoint on runtime.startpanic, the function that gets called by runtime.dopanic when a panic is not recovered. Implements #317
This commit is contained in:
10
proc/proc.go
10
proc/proc.go
@ -741,6 +741,16 @@ func initializeDebugProcess(dbp *Process, path string, attach bool) (*Process, e
|
||||
// the offset of g struct inside TLS
|
||||
dbp.SelectedGoroutine, _ = dbp.CurrentThread.GetG()
|
||||
|
||||
panicpc, err := dbp.FindFunctionLocation("runtime.startpanic", true, 0)
|
||||
if err == nil {
|
||||
bp, err := dbp.SetBreakpoint(panicpc)
|
||||
if err == nil {
|
||||
bp.Name = "unrecovered-panic"
|
||||
bp.ID = -1
|
||||
dbp.breakpointIDCounter--
|
||||
}
|
||||
}
|
||||
|
||||
return dbp, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user