debugdetect

package
v1.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 7 Imported by: 0

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

func IsDebuggerAttached() (bool, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL