Documentation
¶
Overview ¶
Package debugdetect provides utilities for detecting if a program is running under a debugger.
This is useful for applications that need to modify their behavior when being debugged, such as TUI applications that need to wait for debugger attachment before continuing startup.
Example usage:
attached, err := debugdetect.IsDebuggerAttached()
if err != nil {
log.Fatalf("Failed to detect debugger: %v", err)
}
if !attached {
fmt.Println("Waiting for debugger...")
for {
if attached, _ := debugdetect.IsDebuggerAttached(); attached {
break
}
time.Sleep(100 * time.Millisecond)
}
}
Supported platforms: linux, darwin, windows, freebsd Detects: ptrace-based debuggers (Delve, gdb, lldb, etc.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDebuggerAttached ¶
IsDebuggerAttached returns true if the current process is being debugged by a ptrace-based debugger (Delve, gdb, lldb, etc.).
Returns an error if the debugger state cannot be determined. Supported platforms: linux, darwin, windows, freebsd
func WaitForDebugger ¶
func WaitForDebugger() error
Types ¶
This section is empty.