A process debugger written in Rust.
- Map out memory so we can create bounds for breakpoints
- Iterator trait for memory map, to make it nice to work with
- I can't implement a trait for it?
- Shared/Dynamic Libraries
- How to track changes in the map or allocations?
- Iterator trait for memory map, to make it nice to work with
- Breakpoints
- Set
- Remove
- List
- Conditional
- Future breakpoints on functions not yet imported (Windbg feature)
-
ready_vm_write/readvreplacement forptraceread/write - Unicorn Instruction Emulation
- TUI Rust Pane for dashboard
- inferior (inferior data type)
- process start (could be linked to inferior)
- breakpoints
- debug
- breakpoints
- stepping
- expression evaluation
- backtrace (stack unwinding)
- register
- memory writes
- starting a process
- breakpoints
- conditions
- Inferior Process structure for knowledge about the process
- general cmd line debug functions
- Breakpoint
- Software
- Hardware
- Symbols
- Source Code
- Directive for registers
- Set breakpoint with register
break $eip
- Set breakpoint with register
- Display Layout
- Memory View
- Disassembly
- Registers
- Stack
- Source Code
- Carry error code in
InferiorState(fat enum) - Manage debugee threads
- check for new threads on signal and add to DB
- Parse args correctly
- Parse settings into linefeed directive so UI knows about it.
- Good practice to flush stdio prior to fork.
- Ctrl+c to break out of
wait
- Retain a copy of env varaibles since the child will replace the value of environ. If we arevforked, we have to restore it.
- Allow user to select
cwdbefore fork.
- Fork process.
- User
- Symbols
- Target
- Plugin architecture.
- Bulk split between io/reg/bp/debug
- Hardware Breakpoints
- DR0-DR3: registers for writing addr
- DR4/DR6: debug status register
- DR5/DR7: debug control register
- Break on reading, writing, or executing
- Software breakpoint
- Rewrite next instruction with Interrupt
- Replace first byte with
0xCCand store real one55 push %rbp 48 89 e5 mov %rsp, %rsp 48 83 ec 10 sub $0x10,%rsp 55 push %rbp cc 89 e5 mov %rsp, %rsp 48 83 ec 10 sub $0x10,%rsp
- Traps (SIGTRAP)
- Operating system registers interrupt handlers
- Trigger then handler invoked
waitpid(m_pid, 0, 0)
- Single Step:
ptrace(PTRACE_SINGLESTEP, debuggee_pid, nullptr, nullptr) - Step out. Set BP at return addr
- Step Over.
- BP at return addr
- AND a BP at next instruction
ptrace(PTRACE_GETREGS, pid, nullptr, ®s)
- Read/Write. One
WORDat a timeauto date = ptrace(PTRACE_PEEKDATA, m_pid, address, nullptr); data |= 1 ptrace(PTRACE_POKEDATA, m_pid, address, data) - process_vm_readv. Multi
WORDread/writes. Probably better
- Trap Clone:
ptrace(PTRACE_SETOPTIONS, m_pid, nullptr, PTRACE_O_TRACECLONE)case (SIGTRAP | (PTRACE_EVENT_CLONE << 8)) // get the new thread ID unsigned long event_message = 0; ptrace(PTRACE_GETEVENTMSG, pid, nullptr, message); // handle creation //...
- BP on library not loaded
typdef struct {
Elf64_Sxword d_tag; /* entry tag value */
union {
Elf64_Xword d_val;
Elf64_addr d_ptr;
} d_un
} Elf64_Dyn
- struct
r_debuglink_mapnavigate loaded SOsElfW(Addr) r_brk: Address of function with SO is loaded/unloaded- Set SW breakpoint, to populate
link_map
- Set SW breakpoint, to populate
PTRACE_TRACEME
PTRACE_PEEKDATA
PTRACE_POKEDATA
PTRACE_GETREGS
PTRACE_SETREGS