mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
re-plug raddbg markup data section into module image info cache; fix detachment signifying
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ commands =
|
|||||||
{
|
{
|
||||||
//- rjf: [raddbg]
|
//- rjf: [raddbg]
|
||||||
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg meta telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg meta telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||||
.f1 = { .win = "raddbg_stable --ipc kill_all && build radbin debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
.f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||||
|
|
||||||
//- rjf: [raddbg wsl]
|
//- rjf: [raddbg wsl]
|
||||||
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
|
||||||
|
|||||||
+44
-42
@@ -3095,7 +3095,7 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityCtx *ctx, CTRL_Handle thread, U
|
|||||||
// stop unwinding on errors or stale data
|
// stop unwinding on errors or stale data
|
||||||
unwind.flags |= step_result.flags;
|
unwind.flags |= step_result.flags;
|
||||||
if(unwind.flags & (CTRL_UnwindFlag_Stale|CTRL_UnwindFlag_Error) ||
|
if(unwind.flags & (CTRL_UnwindFlag_Stale|CTRL_UnwindFlag_Error) ||
|
||||||
(regs_rsp_from_arch_block(arch, regs_block) == rsp && regs_rip_from_arch_block(arch, regs_block) == rip))
|
(regs_rsp_from_arch_block(arch, regs_block) == rsp && regs_rip_from_arch_block(arch, regs_block) == rip))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3772,29 +3772,28 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
|||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0,0);
|
Temp scratch = scratch_begin(0,0);
|
||||||
|
|
||||||
Arena *arena = arena_alloc();
|
//- rjf: set up per-module info
|
||||||
U64 entry_point_voff = 0;
|
Arena *arena = arena_alloc();
|
||||||
U32 rdi_dbg_time = 0;
|
U64 entry_point_voff = 0;
|
||||||
Guid rdi_dbg_guid = {0};
|
U32 rdi_dbg_time = 0;
|
||||||
String8 exe_dbg_path = {0};
|
Guid rdi_dbg_guid = {0};
|
||||||
String8 rdi_dbg_path = {0};
|
String8 exe_dbg_path = {0};
|
||||||
String8 raddbg_data = {0};
|
String8 rdi_dbg_path = {0};
|
||||||
Rng1U64 raddbg_section_voff_range = r1u64(0, 0);
|
String8 raddbg_data = {0};
|
||||||
Rng1U64 raddbg_is_attached_section_voff_range = r1u64(0, 0);
|
Rng1U64 raddbg_section_voff_range = {0};
|
||||||
|
Rng1U64 raddbg_is_attached_section_voff_range = {0};
|
||||||
PE_IntelPdata *pdatas = 0;
|
PE_IntelPdata *pdatas = 0;
|
||||||
U64 pdatas_count = 0;
|
U64 pdatas_count = 0;
|
||||||
U32 pdb_dbg_time = 0;
|
U32 pdb_dbg_time = 0;
|
||||||
U32 pdb_dbg_age = 0;
|
U32 pdb_dbg_age = 0;
|
||||||
Guid pdb_dbg_guid = {0};
|
Guid pdb_dbg_guid = {0};
|
||||||
String8 pdb_dbg_path = {0};
|
String8 pdb_dbg_path = {0};
|
||||||
|
U64 cfi_rebase = 0;
|
||||||
U64 cfi_rebase = 0;
|
B32 is_unwind_eh = 0;
|
||||||
B32 is_unwind_eh = 0;
|
|
||||||
EH_FrameHdr eh_frame_hdr = {0};
|
EH_FrameHdr eh_frame_hdr = {0};
|
||||||
EH_PtrCtx eh_ptr_ctx = { .pc_vaddr = max_U64, .text_vaddr = max_U64, .data_vaddr = max_U64, .func_vaddr = max_U64, .ptr_align = 0 };
|
EH_PtrCtx eh_ptr_ctx = { .pc_vaddr = max_U64, .text_vaddr = max_U64, .data_vaddr = max_U64, .func_vaddr = max_U64, .ptr_align = 0 };
|
||||||
|
|
||||||
// read module's signature bytes
|
//- read module's signature bytes
|
||||||
U64 module_sig_size = Max(elf_magic_string.size, sizeof(PE_DosMagic));
|
U64 module_sig_size = Max(elf_magic_string.size, sizeof(PE_DosMagic));
|
||||||
U8 *module_sig_bytes = push_array(scratch.arena, U8, module_sig_size);
|
U8 *module_sig_bytes = push_array(scratch.arena, U8, module_sig_size);
|
||||||
dmn_process_read(process.dmn_handle, rng_1u64(vaddr_range.min, vaddr_range.min + module_sig_size), module_sig_bytes);
|
dmn_process_read(process.dmn_handle, rng_1u64(vaddr_range.min, vaddr_range.min + module_sig_size), module_sig_bytes);
|
||||||
@@ -4004,6 +4003,7 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- parse ELF module
|
//- parse ELF module
|
||||||
//
|
//
|
||||||
@@ -4137,11 +4137,11 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
|||||||
//- rjf: insert info into cache
|
//- rjf: insert info into cache
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module);
|
U64 hash = ctrl_hash_from_handle(module);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeW(stripe->rw_mutex)
|
MutexScopeW(stripe->rw_mutex)
|
||||||
{
|
{
|
||||||
CTRL_ModuleImageInfoCacheNode *node = 0;
|
CTRL_ModuleImageInfoCacheNode *node = 0;
|
||||||
@@ -4157,16 +4157,18 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
|||||||
{
|
{
|
||||||
node = push_array(arena, CTRL_ModuleImageInfoCacheNode, 1);
|
node = push_array(arena, CTRL_ModuleImageInfoCacheNode, 1);
|
||||||
DLLPushBack(slot->first, slot->last, node);
|
DLLPushBack(slot->first, slot->last, node);
|
||||||
node->module = module;
|
node->module = module;
|
||||||
node->arena = arena;
|
node->arena = arena;
|
||||||
node->pdatas = pdatas;
|
node->pdatas = pdatas;
|
||||||
node->pdatas_count = pdatas_count;
|
node->pdatas_count = pdatas_count;
|
||||||
node->cfi_rebase = cfi_rebase;
|
node->cfi_rebase = cfi_rebase;
|
||||||
node->is_unwind_eh = is_unwind_eh;
|
node->is_unwind_eh = is_unwind_eh;
|
||||||
node->eh_frame_hdr = eh_frame_hdr;
|
node->eh_frame_hdr = eh_frame_hdr;
|
||||||
node->eh_ptr_ctx = eh_ptr_ctx;
|
node->eh_ptr_ctx = eh_ptr_ctx;
|
||||||
node->entry_point_voff = entry_point_voff;
|
node->entry_point_voff = entry_point_voff;
|
||||||
node->initial_debug_info_path = initial_debug_info_path;
|
node->initial_debug_info_path = initial_debug_info_path;
|
||||||
|
node->raddbg_attached_marker_voff = raddbg_is_attached_section_voff_range.min;
|
||||||
|
node->raddbg_data = str8_copy(arena, raddbg_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4180,7 +4182,7 @@ ctrl_thread__module_close(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: evict module image info from cache
|
//- rjf: evict module image info from cache
|
||||||
//
|
//
|
||||||
Rng1U64 raddbg_section_voff_range = {0};
|
U64 raddbg_attached_marker_voff = 0;
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module);
|
U64 hash = ctrl_hash_from_handle(module);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
||||||
@@ -4200,7 +4202,7 @@ ctrl_thread__module_close(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr
|
|||||||
}
|
}
|
||||||
if(node)
|
if(node)
|
||||||
{
|
{
|
||||||
raddbg_section_voff_range = node->raddbg_section_voff_range;
|
raddbg_attached_marker_voff = node->raddbg_attached_marker_voff;
|
||||||
DLLRemove(slot->first, slot->last, node);
|
DLLRemove(slot->first, slot->last, node);
|
||||||
arena_release(node->arena);
|
arena_release(node->arena);
|
||||||
}
|
}
|
||||||
@@ -4208,12 +4210,12 @@ ctrl_thread__module_close(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: write 0 into first byte of raddbg data section, to signify detachment
|
//- rjf: write 0 at attachment market, to signify detachment
|
||||||
//
|
//
|
||||||
if(raddbg_section_voff_range.max != raddbg_section_voff_range.min)
|
if(raddbg_attached_marker_voff != 0)
|
||||||
{
|
{
|
||||||
U8 new_value = 0;
|
U8 new_value = 0;
|
||||||
dmn_process_write_struct(process.dmn_handle, vaddr_range.min + raddbg_section_voff_range.min, &new_value);
|
dmn_process_write_struct(process.dmn_handle, vaddr_range.min + raddbg_attached_marker_voff, &new_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ struct CTRL_ModuleImageInfoCacheNode
|
|||||||
EH_PtrCtx eh_ptr_ctx;
|
EH_PtrCtx eh_ptr_ctx;
|
||||||
U64 entry_point_voff;
|
U64 entry_point_voff;
|
||||||
String8 initial_debug_info_path;
|
String8 initial_debug_info_path;
|
||||||
Rng1U64 raddbg_section_voff_range;
|
U64 raddbg_attached_marker_voff;
|
||||||
String8 raddbg_data;
|
String8 raddbg_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user