Debugger¶
- final class ntoseye.Debugger¶
A live debugging session. As a context manager, leaving the
withblock closes it (close()): every breakpoint is removed, the target resumes, and the session ends.Usable from any Python thread: calls are serialized on the session’s own thread, and a call that waits (
run(),wait()) releases the GIL. Ctrl+C (KeyboardInterrupt) during a call ends a wait, step, or trace early and raises; during a resumingcommand()it breaks in, as in the REPL. Between calls the session keeps servicing the guest, resuming wrong-process and false-condition breakpoint hits so the guest never sits frozen. A debugger handed to a REPL custom command is valid only on the REPL’s thread, for that command.- property breakpoints: Breakpoints¶
Code breakpoints and data watchpoints:
.add(...),.watch(...), iteration,[id].
- property capabilities: list[Record]¶
The backend’s capability matrix as
{capability, label, supported}records: which operations the transport supports.
- close() None¶
Remove every breakpoint, leave the target running, and end the session: the connection and the target’s single-instance lock are released, so the target can be attached again, and this debugger and its handles raise from then on. Closing again does nothing. On failure the target is left halted, the session stays open, and the error is raised. A borrowed (REPL command) debugger does not own the session and leaves it alone.
- property coherent: bool¶
False after a reboot until the kernel’s module list exists: kernel symbols and breakpoints work, process/module enumeration does not yet.
- command(line: str, timeout: float | None = None) str¶
Run a REPL command line and return its text output (styling stripped). Commands that resume the target wait for the next stop, up to
timeoutseconds; the stop is thendbg.stop.
- cont(disposition: Literal['handled', 'not_handled'] = ...) None¶
Resume without waiting, acknowledging the current exception as
handledornot_handled(KD only).
- debug_log(since: int = 0) Record¶
Captured guest debug output (DbgPrint) since sequence
since:{lines: [{seq, timestamp_ms, text}], next_seq, dropped}. Pass the previousnext_seqto poll only new lines.
- property drivers: Drivers¶
Driver objects from the object manager’s
Driverdirectory:drivers["Disk"],.at(addr).
- eval(expr: str) int¶
Evaluate a debugger (MASM) expression in kernel scope to an integer; registers are the stopped vCPU’s.
- property exceptions: Exceptions¶
Exception stop policies (
sx*):.set(code, mode), iteration,.reset().
- property generation: int¶
How many times the guest has been rebuilt (reboots). Handles from an older generation raise
StaleHandleError; cache this beside raw addresses to know when they went stale.
- property memory: Memory¶
Kernel virtual memory: the kernel’s own page tables. User addresses are not mapped here; read them through
process.memory.
- notices() list[str]¶
Drain the diagnostics the debugger raised since the last call (a breakpoint that failed to re-arm, a reclaimed breakpoint slot, host memory that stopped matching after a reload).
- reload() None¶
Rebuild guest state now (rediscover the kernel). Stops already do this when the backend reports a reload; this forces it.
- run(timeout: float | None = None, *, disposition: Literal['handled', 'not_handled'] = ...) Stop | None¶
Resume and wait for the next stop, auto-resuming past wrong-process and false-conditional hits. Returns the
Stop, orNoneif the target is still running aftertimeoutseconds.
- run_to(target: int | str, timeout: float | None = None, *, step: Literal['over', 'into'] | None = None) Stop | None¶
Run until
target(an address, or a symbolicmodule!name[+off]) is reached (g <addr>), or withstep="over"/"into"single-step there (pa/ta). Other stops en route are returned as they are; withtimeout, an unreached target is interrupted where it is.
- property secure_kernel: SecureKernel¶
The VBS secure kernel (VTL1): read-only
memory,symbols,types,modules, andtrustlets. Discovered on first use from host memory; raisesNtoseyeErrorwhen VBS is not running or the backend cannot read host memory. Experimental.
- step(until: Literal['call', 'ret', 'branch'] | None = None) Stop¶
Single-step one instruction, or with
until(“call”, “ret”, “branch”) step into until the next such instruction (tc/tt/th).
- step_over(until: Literal['call', 'ret', 'branch'] | None = None) Stop¶
Step over the current instruction, or with
untilstep over until the next call/ret/branch (pc/pt/ph).
- property symbols: Symbols¶
Kernel-scope symbols:
symbols["nt!KeBugCheckEx"],nearest(addr),search(query), the symbol and source paths.
- trace_calls(limit: int = 10000) Record¶
Trace calls until the current function returns (
wt), single-stepping at mostlimitinstructions:{end, error, instructions, root}, whererootis the call tree andendsays why tracing stopped.