class Cradare2::DSL::Debugger

Overview

High-level debugger DSL for controlling execution, breakpoints, registers, memory maps, and crash reports.

Defined in:

cradare2/dsl/debugger.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

[View source]

Instance Method Detail

def allocate_memory(size : Int32, address : Address | Nil = nil) : self #

Allocates a memory region of the given size in the debugged process (dm ).


[View source]
def analyze_registers(regs : Model::Registers | Nil = nil) : Cradare2::Analysis::RegisterAnalysis #

Performs deep structural analysis on current CPU registers and memory boundaries.


[View source]
def attach(pid : Int32) : self #

Attaches to a running process by PID.


[View source]
def attachable_processes : Array(Model::ProcessInfo) #

Returns a list of attachable / running system processes (dplj).


[View source]
def backtrace : Array(Model::StackFrame) #

Returns the call stack / backtrace frames (dbtj).


[View source]
def backtrace_symbols : Array(String) #

Returns list of demangled backtrace function symbols.


[View source]
def base_address_of(module_name : String) : UInt64 | Nil #

Returns the base load address of a specific loaded module by name (e.g. "game.dll" or "godot.exe").


[View source]
def breakpoint(target : Address) : self #

Sets a software breakpoint at the given address or symbol (db).


[View source]
def breakpoint_at?(target : Address) : Bool #

Checks whether a breakpoint is active at the specified address.


[View source]
def breakpoint_at_source(file : String, line : Int32) : self #

Sets a breakpoint at a source code file and line number. If mapped in Crystal/DWARF line metadata, resolves the target address; otherwise falls back to dbl file:line.


[View source]
def breakpoints : Array(Model::Breakpoint) #

Returns list of active breakpoints as typed models.


[View source]
def classify_memory(address : UInt64) : Cradare2::Analysis::ClassifiedAddress #

Classifies an arbitrary pointer against the debugged process memory maps.


[View source]
def clear_breakpoints : self #

Removes all breakpoints and watchpoints (db-*).


[View source]
def conditional_breakpoint(target : Address, condition : String) : self #

Sets a software breakpoint with an associated condition expression.


[View source]
def continue : self #

Continues execution of the debugged process (dc).


[View source]
def continue_back : self #

Continues execution back / reverse continue until hitting a breakpoint (dcb).


[View source]
def continue_until(address : Address) : self #

Continues execution until reaching the specified target address (dcu).


[View source]
def continue_until_call : self #

Continues execution until the next call instruction (dcc).


[View source]
def continue_until_ret : self #

Continues execution until returning from the current function (dcr).


[View source]
def continue_until_syscall : self #

Continues execution until the next system call (dcs).


[View source]
def crash_report(regs : Model::Registers | Nil = nil, bt : Array(Model::StackFrame) | Nil = nil) : String #

Generates a detailed, demangled native crash diagnostic report. Includes crash instruction pointer, active function, faulting memory region, registers dump, and demangled call stack.


[View source]
def current_thread : Model::Thread | Nil #

Returns the currently selected thread in the debugger.


[View source]
def current_thread_id : Int32 | Nil #

Returns the currently active thread ID (dpt.).


[View source]
def deallocate_memory(target : Address) : self #

Deallocates a memory region at the given address in the debugged process (dm- ).


[View source]
def detach : self #

Detaches from current process.


[View source]
def diagnose_crash(regs : Model::Registers | Nil = nil, bt : Array(Model::StackFrame) | Nil = nil) : Model::CrashDiagnosis #

Generates a structured crash diagnosis with root-cause pattern analysis and remediation steps.


[View source]
def diff_registers(baseline : Model::Registers) : Hash(String, Tuple(UInt64, UInt64)) #

Compares current CPU registers against a baseline Registers snapshot.


[View source]
def disable_all_breakpoints : self #

Disables all breakpoints in the session (dbd*).


[View source]
def disable_breakpoint(target : Address) : self #

Disables a breakpoint at the specified target without deleting it (dbd).


[View source]
def dump_memory_region(path : String) : self #

Dumps a debug memory region to a file on disk (dmd).


[View source]
def enable_all_breakpoints : self #

Enables all breakpoints in the session (dbe*).


[View source]
def enable_breakpoint(target : Address) : self #

Enables a breakpoint at the specified target (dbe).


[View source]
def executable_path : String #

Returns the path to the executable of the debugged process (dpe).


[View source]
def find_breakpoint(target : Address) : Model::Breakpoint | Nil #

Finds an active breakpoint located at the specified address.


[View source]
def find_stale_vtables(registers_to_scan : Array(String) = ["rcx", "rdi", "rsi", "rbx"], vtable_offset : Int32 = 0) : Array(NamedTuple(register: String, object_address: UInt64, vtable: UInt64, reason: String)) #

Scans standard object registers (e.g. RCX, RDI, RSI, RBX) to detect objects holding stale vtable pointers pointing outside currently mapped module boundaries (frequent during dynamic plugin / GDExtension hot reloading).


[View source]
def finish : self #

Alias for step_out.


[View source]
def hardware_breakpoint(target : Address) : self #

Sets a hardware execution breakpoint at the given address or symbol (dbH).


[View source]
def hardware_breakpoints : Array(Model::Breakpoint) #

Returns only hardware breakpoints.


[View source]
def hw_breakpoint(target : Address) : self #

Alias for hardware_breakpoint.


[View source]
def kill : self #

Sends SIGKILL or terminates the debugged process.


[View source]
def logpoint(target : Address, command : String) : self #

Alias for tracepoint.


[View source]
def maps : Array(Model::MemoryMap) #

Returns the loaded memory maps / regions (dmj).


[View source]
def memory_classifier : Cradare2::Analysis::MemoryClassifier #

Returns a memory classifier configured with the currently loaded memory maps.


[View source]
def module_at(address : Address) : Model::ModuleInfo | Nil #

Returns the loaded binary module containing the specified address, or nil if unmapped.


[View source]
def modules : Array(Model::ModuleInfo) #

Returns loaded PE/ELF/Mach-O binary modules in the debugged process (dmmj, with fallback to grouped dmj).


[View source]
def name_breakpoint(target : Address, name : String) : self #

Assigns a descriptive name or label to a breakpoint (dbn @ ).


[View source]
def pid : Int32 | Nil #

Returns current process ID if debugging.


[View source]
def protect_memory(target : Address, size : Int32, perms : String) : self #

Changes memory page protection permissions at target address (dmp ).


[View source]
def register(name : String) : UInt64 #

Reads a single register value by name.


[View source]
def registers : Model::Registers #

Returns current CPU registers as a strongly typed Registers model.


[View source]
def remove_breakpoint(target : Address) : self #

Removes a breakpoint or watchpoint at the given address or symbol (db-).


[View source]
def remove_watchpoint(target : Address) : self #

Alias for remove_breakpoint to explicitly remove a watchpoint.


[View source]
def restore_registers : self #

Pops / restores register states from the previous snapshot (drs-).


[View source]
def running? : Bool #

Checks if the debugged process is currently active/attached.


[View source]
def select_thread(tid : Int32) : self #

Attaches or switches focus to a specific thread ID (dpt=).


[View source]
def set_breakpoint_command(target : Address, command : String) : self #

Sets a command to execute when hitting a breakpoint (dbc).


[View source]
def set_breakpoint_condition(target : Address, condition : String) : self #

Sets an expression condition on a breakpoint (dbx @ ).


[View source]
def set_register(name : String, value : UInt64) : self #

Sets a register to a specific value (e.g. set_register("rax", 0x1234)).


[View source]
def snapshot_registers : self #

Pushes / takes a snapshot of current register states (drs+).


[View source]
def software_breakpoints : Array(Model::Breakpoint) #

Returns only software execution breakpoints.


[View source]
def stack_words(count : Int32 = 8) : Array(UInt64) #

Reads count 64-bit words directly from the current Stack Pointer (SP).


[View source]
def stale_vtable?(address : UInt64) : Bool #

Checks if an address represents a stale vtable pointer (pointing outside all currently mapped modules).


[View source]
def status : String #

Returns debugger execution status text.


[View source]
def step(count : Int32 = 1) : self #

Steps one or more machine instructions (ds).


[View source]
def step_back : self #

Steps back one machine instruction in reversible debugging (dsb).


[View source]
def step_out : self #

Steps until exiting current stack frame / function finish (dsf).


[View source]
def step_over(count : Int32 = 1) : self #

Steps over calls or compound instructions (dso).


[View source]
def step_source(lines : Int32 = 1) : self #

Steps one or more high-level source lines (dsl).


[View source]
def step_until(address : Address) : self #

Continues execution until reaching the specified target address (dsu).


[View source]
def telescope : Array(Model::TelescopeEntry) #

Inspects telescoping pointer references for all registers (drrj).


[View source]
def threads : Array(Model::Thread) #

Returns active threads in the process (dptj).


[View source]
def toggle_breakpoint(target : Address) : self #

Toggles a breakpoint at the target address (dbs).


[View source]
def tracepoint(target : Address, command : String) : self #

Sets a tracepoint / logpoint that executes a command upon hit and immediately continues execution without stopping (dbC).


[View source]
def watchpoint(target : Address, access : Symbol = :rw) : self #

Sets a memory watchpoint on read ('r'), write ('w'), or read/write ('rw') access (dbw).


[View source]
def watchpoints : Array(Model::Breakpoint) #

Returns only memory watchpoints.


[View source]