major clean-up pass over unwinding/module-info abstraction, + usage in the debug engine. simplified / cleaned up DWARF helpers for unwind info & expressions. decoupling unwinding / DWARF evaluation from memory read callbacks. light module info now prepared by demon layer - debug engine no longer duplicates per-backend parsing. unwind abstraction layer now does thin abstraction over unwinding backends, debug engine only calls abstraction. clean up demon to have fewer ad-hoc 'queries' on handles, and prefer sending info over debug events when possible / when it fits the usage pattern. move DWARF enum specifications to metacode, generate enums/xlists/tables/etc. decouple raddbg/radbin completely from old parsing helpers. replace portion of DWARF dumping; pull out some new parsing helpers from converter / dumper.

This commit is contained in:
Ryan Fleury committed 2026-06-02 12:11:13 -07:00
1 parent 541d3afefa
commit d73ce364b9
88 files changed
+9899 -4723

No files matched your search

+2 -2
View File
@@ -316,7 +316,7 @@ commit_memory_large(void *ptr, U64 size)
}
////////////////////////////////
//~ rjf: @os_hooks Shared Memory
//~ rjf: @per_os_impl Shared Memory
internal SharedMemory
shared_memory_alloc(U64 size, String8 name)
@@ -476,7 +476,7 @@ thread_detach(Thread thread)
}
////////////////////////////////
//~ rjf: @os_hooks Safe Calls
//~ rjf: @per_os_impl Safe Calls
internal void
safe_call(ThreadEntryPointFunctionType *func, ThreadEntryPointFunctionType *fail_handler, void *ptr)
+91 -82
View File
@@ -1217,6 +1217,50 @@ w32_dmn_thread_write_reg_block(Arch arch, HANDLE thread, void *reg_block)
return result;
}
internal U64
w32_dmn_thread_stack_base_vaddr_from_tlb_vaddr(HANDLE process, Arch arch, U64 tlb_vaddr)
{
U64 stack_base_vaddr = 0;
{
switch(arch)
{
case Arch_Null:
case Arch_COUNT:
case Arch_arm64:
case Arch_arm32:
case Arch_x86:
{}break;
case Arch_x64:
{
U64 stack_base_vaddr = tlb_vaddr + 0x8;
w32_dmn_process_read(process, r1u64(stack_base_vaddr, stack_base_vaddr+8), &stack_base_vaddr);
}break;
}
}
return stack_base_vaddr;
}
internal U64
w32_dmn_thread_tls_root_vaddr_from_tlb_vaddr(Arch arch, U64 tlb_vaddr)
{
U64 result = 0;
switch(arch)
{
case Arch_Null:
case Arch_COUNT:
{}break;
case Arch_arm64:
case Arch_arm32:
case Arch_x86:
{}break;
case Arch_x64:
{
result = tlb_vaddr + 88;
}break;
}
return result;
}
//- rjf: remote thread injection
internal DWORD
@@ -2066,6 +2110,10 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
thread->thread.thread_local_base = tls_base;
}
// rjf: unpack thread addresses
U64 stack_base_vaddr = w32_dmn_thread_stack_base_vaddr_from_tlb_vaddr(process_handle, module_info->arch, tls_base);
U64 tls_root_vaddr = w32_dmn_thread_tls_root_vaddr_from_tlb_vaddr(module_info->arch, tls_base);
// rjf: put thread into suspended state, so it matches expected initial state
SuspendThread(thread_handle);
@@ -2096,11 +2144,13 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
// rjf: create thread
{
DMN_Event *e = dmn_event_list_push(arena, &events);
e->kind = DMN_EventKind_CreateThread;
e->process = w32_dmn_handle_from_entity(process);
e->thread = w32_dmn_handle_from_entity(thread);
e->arch = module_info->arch;
e->code = evt.dwThreadId;
e->kind = DMN_EventKind_CreateThread;
e->process = w32_dmn_handle_from_entity(process);
e->thread = w32_dmn_handle_from_entity(thread);
e->arch = module_info->arch;
e->code = evt.dwThreadId;
e->stack_pointer = stack_base_vaddr;
e->tls_root_vaddr= tls_root_vaddr;
}
// rjf: load module
@@ -2192,6 +2242,10 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
DWORD sus_result = SuspendThread(thread->handle);
(void)sus_result;
// rjf: unpack thread addresses
U64 stack_base_vaddr = w32_dmn_thread_stack_base_vaddr_from_tlb_vaddr(process->handle, thread->arch, (U64)evt.u.CreateThread.lpThreadLocalBase);
U64 tls_root_vaddr = w32_dmn_thread_tls_root_vaddr_from_tlb_vaddr(thread->arch, (U64)evt.u.CreateThread.lpThreadLocalBase);
// rjf: unpack thread name
String8 thread_name = {0};
if(w32_dmn_GetThreadDescription != 0)
@@ -2213,11 +2267,13 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
{
DMN_Event *e = dmn_event_list_push(arena, &events);
e->kind = DMN_EventKind_CreateThread;
e->process = w32_dmn_handle_from_entity(process);
e->thread = w32_dmn_handle_from_entity(thread);
e->arch = thread->arch;
e->code = evt.dwThreadId;
e->string = thread_name;
e->process = w32_dmn_handle_from_entity(process);
e->thread = w32_dmn_handle_from_entity(thread);
e->arch = thread->arch;
e->code = evt.dwThreadId;
e->string = thread_name;
e->stack_pointer = stack_base_vaddr;
e->tls_root_vaddr = tls_root_vaddr;
}
}break;
@@ -3207,78 +3263,6 @@ dmn_process_write(DMN_Handle process, Rng1U64 range, void *src)
//- rjf: threads
internal Arch
dmn_arch_from_thread(DMN_Handle handle)
{
Arch arch = Arch_Null;
DMN_AccessScope
{
W32_DMN_Entity *entity = w32_dmn_entity_from_handle(handle);
arch = entity->arch;
}
return arch;
}
internal U64
dmn_stack_base_vaddr_from_thread(DMN_Handle handle)
{
U64 result = 0;
DMN_AccessScope
{
W32_DMN_Entity *thread = w32_dmn_entity_from_handle(handle);
if(thread->kind == W32_DMN_EntityKind_Thread)
{
W32_DMN_Entity *process = thread->parent;
U64 tlb = thread->thread.thread_local_base;
switch(thread->arch)
{
case Arch_Null:
case Arch_COUNT:
{}break;
case Arch_arm64:
case Arch_arm32:
case Arch_x86:
{NotImplemented;}break;
case Arch_x64:
{
U64 stack_base_addr = tlb + 0x8;
w32_dmn_process_read(process->handle, r1u64(stack_base_addr, stack_base_addr+8), &result);
}break;
}
}
}
return result;
}
internal U64
dmn_tls_root_vaddr_from_thread(DMN_Handle handle)
{
U64 result = 0;
DMN_AccessScope
{
W32_DMN_Entity *entity = w32_dmn_entity_from_handle(handle);
if(entity->kind == W32_DMN_EntityKind_Thread)
{
result = entity->thread.thread_local_base;
switch(entity->arch)
{
case Arch_Null:
case Arch_COUNT:
{}break;
case Arch_arm64:
case Arch_arm32:
case Arch_x86:
{NotImplemented;}break;
case Arch_x64:
{
result += 88;
}break;
}
}
}
return result;
}
internal B32
dmn_thread_read_reg_block(DMN_Handle handle, void *reg_block)
{
@@ -3303,6 +3287,31 @@ dmn_thread_write_reg_block(DMN_Handle handle, void *reg_block)
return result;
}
internal B32
dmn_thread_get_module_tls_vaddr(DMN_Handle thread_handle, DMN_Handle module_handle, U64 *vaddr_out)
{
B32 result = 0;
DMN_AccessScope
{
W32_DMN_Entity *thread = w32_dmn_entity_from_handle(thread_handle);
W32_DMN_Entity *process = thread->parent;
W32_DMN_Entity *module = w32_dmn_entity_from_handle(module_handle);
Arch arch = thread->arch;
U64 addr_size = byte_size_from_arch(arch);
U64 tls_vaddr = w32_dmn_thread_tls_root_vaddr_from_tlb_vaddr(arch, thread->thread.thread_local_base);
U64 tls_addr_array_vaddr = 0;
if(w32_dmn_process_read_struct(process->handle, tls_vaddr, &tls_addr_array_vaddr) == addr_size)
{
U64 tls_ptr_vaddr = tls_addr_array_vaddr + module->module.tls_index*addr_size;
if(w32_dmn_process_read_struct(process->handle, tls_ptr_vaddr, vaddr_out) == addr_size)
{
result = 1;
}
}
}
return result;
}
//- rjf: system process listing
internal void
+3
View File
@@ -205,6 +205,7 @@ struct W32_DMN_Entity
{
Rng1U64 vaddr_range;
U64 address_of_name_pointer;
U64 tls_index;
B32 is_main;
B32 name_is_unicode;
}
@@ -349,6 +350,8 @@ internal DMN_ModuleInfo *w32_dmn_module_info_from_process_module(Arena *arena, H
//- rjf: threads
internal B32 w32_dmn_thread_read_reg_block(Arch arch, HANDLE thread, void *reg_block);
internal B32 w32_dmn_thread_write_reg_block(Arch arch, HANDLE thread, void *reg_block);
internal U64 w32_dmn_thread_stack_base_vaddr_from_tlb_vaddr(HANDLE process, Arch arch, U64 tlb_vaddr);
internal U64 w32_dmn_thread_tls_root_vaddr_from_tlb_vaddr(Arch arch, U64 tlb_vaddr);
//- rjf: remote thread injection
internal DWORD w32_dmn_inject_thread(HANDLE process, U64 start_address);
+10 -10
View File
@@ -815,7 +815,7 @@ w32_wm_monitor_gather_enum_proc(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM b
}
////////////////////////////////
//~ rjf: @os_hooks Main Initialization API (Implemented Per-OS)
//~ rjf: @per_os_impl Main Initialization API (Implemented Per-OS)
internal void
wm_init(void)
@@ -995,7 +995,7 @@ wm_init(void)
}
////////////////////////////////
//~ rjf: @os_hooks Graphics System Info (Implemented Per-OS)
//~ rjf: @per_os_impl Graphics System Info (Implemented Per-OS)
internal WM_SystemInfo *
wm_get_system_info(void)
@@ -1004,7 +1004,7 @@ wm_get_system_info(void)
}
////////////////////////////////
//~ rjf: @os_hooks Clipboards (Implemented Per-OS)
//~ rjf: @per_os_impl Clipboards (Implemented Per-OS)
internal void
wm_set_clipboard_text(String8 string)
@@ -1053,7 +1053,7 @@ wm_get_clipboard_text(Arena *arena)
}
////////////////////////////////
//~ rjf: @os_hooks Windows (Implemented Per-OS)
//~ rjf: @per_os_impl Windows (Implemented Per-OS)
internal WM_Window
wm_window_open(Rng2F32 rect, WM_WindowFlags flags, String8 title)
@@ -1385,7 +1385,7 @@ wm_dpi_from_window(WM_Window handle)
}
////////////////////////////////
//~ rjf: @os_hooks External Windows (Implemented Per-OS)
//~ rjf: @per_os_impl External Windows (Implemented Per-OS)
internal WM_ExtWindow
wm_focused_external_window(void)
@@ -1407,7 +1407,7 @@ wm_focus_external_window(WM_ExtWindow handle)
}
////////////////////////////////
//~ rjf: @os_hooks Monitors (Implemented Per-OS)
//~ rjf: @per_os_impl Monitors (Implemented Per-OS)
internal WM_MonitorArray
wm_push_monitors_array(Arena *arena)
@@ -1494,7 +1494,7 @@ wm_dpi_from_monitor(WM_Monitor monitor)
}
////////////////////////////////
//~ rjf: @os_hooks Events (Implemented Per-OS)
//~ rjf: @per_os_impl Events (Implemented Per-OS)
internal void
wm_send_wakeup_event(void)
@@ -1573,7 +1573,7 @@ wm_mouse_from_window(WM_Window handle)
}
////////////////////////////////
//~ rjf: @os_hooks Cursors (Implemented Per-OS)
//~ rjf: @per_os_impl Cursors (Implemented Per-OS)
internal void
wm_set_cursor(WM_Cursor cursor)
@@ -1615,7 +1615,7 @@ hcursor = curs; }break;
}
////////////////////////////////
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
//~ rjf: @per_os_impl Native User-Facing Graphical Messages (Implemented Per-OS)
internal void
wm_graphical_message(B32 error, String8 title, String8 message)
@@ -1651,7 +1651,7 @@ wm_graphical_pick_file(Arena *arena, String8 initial_path)
}
////////////////////////////////
//~ rjf: @os_hooks Shell Operations
//~ rjf: @per_os_impl Shell Operations
internal void
wm_show_in_filesystem_ui(String8 path)