mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
get raddbg building on new demon layer
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ commands =
|
|||||||
{
|
{
|
||||||
.rjf_f1 =
|
.rjf_f1 =
|
||||||
{
|
{
|
||||||
.win = "build ryan_scratch",
|
.win = "build raddbg",
|
||||||
.linux = "",
|
.linux = "",
|
||||||
.out = "*compilation*",
|
.out = "*compilation*",
|
||||||
.footer_panel = true,
|
.footer_panel = true,
|
||||||
|
|||||||
+1
-1
@@ -74,4 +74,4 @@
|
|||||||
|
|
||||||
#include "ctrl_core.h"
|
#include "ctrl_core.h"
|
||||||
|
|
||||||
#endif //CTRL_INC_H
|
#endif // CTRL_INC_H
|
||||||
|
|||||||
+6
-4
@@ -179,7 +179,7 @@ dasm_inst_chunk_list_from_arch_addr_data(Arena *arena, U64 *bytes_processed_coun
|
|||||||
//- rjf: opening handles & correllation with module
|
//- rjf: opening handles & correllation with module
|
||||||
|
|
||||||
internal DASM_Handle
|
internal DASM_Handle
|
||||||
dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, DMN_Handle process, Rng1U64 vaddr_range)
|
dasm_handle_from_ctrl_process_range_arch(CTRL_MachineID machine, DMN_Handle process, Rng1U64 vaddr_range, Architecture arch)
|
||||||
{
|
{
|
||||||
DASM_Handle result = {0};
|
DASM_Handle result = {0};
|
||||||
if(machine != 0 && process.u64[0] != 0)
|
if(machine != 0 && process.u64[0] != 0)
|
||||||
@@ -196,7 +196,8 @@ dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, DMN_Handle process,
|
|||||||
{
|
{
|
||||||
if(e->machine_id == machine &&
|
if(e->machine_id == machine &&
|
||||||
ctrl_handle_match(e->process, process) &&
|
ctrl_handle_match(e->process, process) &&
|
||||||
MemoryMatchStruct(&e->vaddr_range, &vaddr_range))
|
MemoryMatchStruct(&e->vaddr_range, &vaddr_range) &&
|
||||||
|
e->arch == arch)
|
||||||
{
|
{
|
||||||
entity = e;
|
entity = e;
|
||||||
break;
|
break;
|
||||||
@@ -209,6 +210,7 @@ dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, DMN_Handle process,
|
|||||||
entity->machine_id = machine;
|
entity->machine_id = machine;
|
||||||
entity->process = process;
|
entity->process = process;
|
||||||
entity->vaddr_range= vaddr_range;
|
entity->vaddr_range= vaddr_range;
|
||||||
|
entity->arch = arch;
|
||||||
entity->id = ins_atomic_u64_inc_eval(&dasm_shared->entity_id_gen);
|
entity->id = ins_atomic_u64_inc_eval(&dasm_shared->entity_id_gen);
|
||||||
entity->decode_inst_arena = arena_alloc__sized(MB(256), KB(64));
|
entity->decode_inst_arena = arena_alloc__sized(MB(256), KB(64));
|
||||||
entity->decode_string_arena = arena_alloc__sized(GB(1), KB(64));
|
entity->decode_string_arena = arena_alloc__sized(GB(1), KB(64));
|
||||||
@@ -413,7 +415,7 @@ dasm_decode_thread_entry_point(void *p)
|
|||||||
ctrl_machine_id = entity->machine_id;
|
ctrl_machine_id = entity->machine_id;
|
||||||
ctrl_process = entity->process;
|
ctrl_process = entity->process;
|
||||||
vaddr_range = entity->vaddr_range;
|
vaddr_range = entity->vaddr_range;
|
||||||
arch = ctrl_arch_from_handle(ctrl_machine_id, ctrl_process);
|
arch = entity->arch;
|
||||||
bytes_processed_counter = &entity->bytes_processed;
|
bytes_processed_counter = &entity->bytes_processed;
|
||||||
U64 bytes_to_process = dim_1u64(vaddr_range);
|
U64 bytes_to_process = dim_1u64(vaddr_range);
|
||||||
ins_atomic_u64_eval_assign(&entity->bytes_processed, 0);
|
ins_atomic_u64_eval_assign(&entity->bytes_processed, 0);
|
||||||
@@ -465,7 +467,7 @@ dasm_decode_thread_entry_point(void *p)
|
|||||||
if(good_task)
|
if(good_task)
|
||||||
{
|
{
|
||||||
data.str = push_array_no_zero(scratch.arena, U8, dim_1u64(chunk_vaddr_range));
|
data.str = push_array_no_zero(scratch.arena, U8, dim_1u64(chunk_vaddr_range));
|
||||||
data.size = ctrl_process_read(ctrl_machine_id, ctrl_process, chunk_vaddr_range, data.str);
|
data.size = dmn_process_read(ctrl_process, chunk_vaddr_range, data.str);
|
||||||
if(data.size != 0)
|
if(data.size != 0)
|
||||||
{
|
{
|
||||||
inst_list = dasm_inst_chunk_list_from_arch_addr_data(scratch.arena, bytes_processed_counter, arch, chunk_vaddr_range.min, data);
|
inst_list = dasm_inst_chunk_list_from_arch_addr_data(scratch.arena, bytes_processed_counter, arch, chunk_vaddr_range.min, data);
|
||||||
|
|||||||
+2
-1
@@ -79,6 +79,7 @@ struct DASM_Entity
|
|||||||
CTRL_MachineID machine_id;
|
CTRL_MachineID machine_id;
|
||||||
DMN_Handle process;
|
DMN_Handle process;
|
||||||
Rng1U64 vaddr_range;
|
Rng1U64 vaddr_range;
|
||||||
|
Architecture arch;
|
||||||
U64 id;
|
U64 id;
|
||||||
|
|
||||||
// rjf: top-level info
|
// rjf: top-level info
|
||||||
@@ -187,7 +188,7 @@ internal DASM_InstChunkList dasm_inst_chunk_list_from_arch_addr_data(Arena *aren
|
|||||||
//~ rjf: Cache Lookups
|
//~ rjf: Cache Lookups
|
||||||
|
|
||||||
//- rjf: opening handles & correllation with module
|
//- rjf: opening handles & correllation with module
|
||||||
internal DASM_Handle dasm_handle_from_ctrl_process_range(CTRL_MachineID machine, DMN_Handle process, Rng1U64 vaddr_range);
|
internal DASM_Handle dasm_handle_from_ctrl_process_range_arch(CTRL_MachineID machine, DMN_Handle process, Rng1U64 vaddr_range, Architecture arch);
|
||||||
|
|
||||||
//- rjf: asking for top-level info of a handle
|
//- rjf: asking for top-level info of a handle
|
||||||
internal DASM_BinaryInfo dasm_binary_info_from_handle(Arena *arena, DASM_Handle handle);
|
internal DASM_BinaryInfo dasm_binary_info_from_handle(Arena *arena, DASM_Handle handle);
|
||||||
|
|||||||
+19
-17
@@ -1404,7 +1404,7 @@ internal DASM_Handle
|
|||||||
df_dasm_handle_from_process_vaddr(DF_Entity *process, U64 vaddr)
|
df_dasm_handle_from_process_vaddr(DF_Entity *process, U64 vaddr)
|
||||||
{
|
{
|
||||||
Rng1U64 disasm_vaddr_rng = r1u64(AlignDownPow2(vaddr, KB(4)), AlignDownPow2(vaddr, KB(4)) + KB(16));
|
Rng1U64 disasm_vaddr_rng = r1u64(AlignDownPow2(vaddr, KB(4)), AlignDownPow2(vaddr, KB(4)) + KB(16));
|
||||||
DASM_Handle dasm_handle = dasm_handle_from_ctrl_process_range(process->ctrl_machine_id, process->ctrl_handle, disasm_vaddr_rng);
|
DASM_Handle dasm_handle = dasm_handle_from_ctrl_process_range_arch(process->ctrl_machine_id, process->ctrl_handle, disasm_vaddr_rng, process->arch);
|
||||||
return dasm_handle;
|
return dasm_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2710,11 +2710,9 @@ df_debug_info_path_from_module(Arena *arena, DF_Entity *module)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
|
||||||
String8 exe_path = module->name;
|
String8 exe_path = module->name;
|
||||||
String8 dbg_path = ctrl_og_dbg_path_from_exe_path(arena, exe_path);
|
String8 dbg_path = push_str8f(arena, "%S.pdb", str8_chop_last_dot(exe_path));
|
||||||
result = dbg_path;
|
result = dbg_path;
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
}
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
return result;
|
return result;
|
||||||
@@ -2830,8 +2828,8 @@ df_trap_net_from_thread__step_over_inst(Arena *arena, DF_Entity *thread)
|
|||||||
String8 machine_code = {0};
|
String8 machine_code = {0};
|
||||||
{
|
{
|
||||||
Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch));
|
Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch));
|
||||||
machine_code.str = push_array_no_zero(scratch.arena, U8, max_instruction_size_from_arch(arch));
|
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, rng, max_U64);
|
||||||
machine_code.size = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, rng, machine_code.str);
|
machine_code = machine_code_slice.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: build traps if machine code was read successfully
|
// rjf: build traps if machine code was read successfully
|
||||||
@@ -2897,8 +2895,8 @@ df_trap_net_from_thread__step_over_line(Arena *arena, DF_Entity *thread)
|
|||||||
String8 machine_code = {0};
|
String8 machine_code = {0};
|
||||||
if(good_line_info)
|
if(good_line_info)
|
||||||
{
|
{
|
||||||
machine_code.str = push_array_no_zero(scratch.arena, U8, dim_1u64(line_vaddr_rng));
|
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, line_vaddr_rng, max_U64);
|
||||||
machine_code.size = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, line_vaddr_rng, machine_code.str);
|
machine_code = machine_code_slice.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: machine code => ctrl flow analysis
|
// rjf: machine code => ctrl flow analysis
|
||||||
@@ -3022,8 +3020,8 @@ df_trap_net_from_thread__step_into_line(Arena *arena, DF_Entity *thread)
|
|||||||
String8 machine_code = {0};
|
String8 machine_code = {0};
|
||||||
if(good_line_info)
|
if(good_line_info)
|
||||||
{
|
{
|
||||||
machine_code.str = push_array_no_zero(scratch.arena, U8, dim_1u64(line_vaddr_rng));
|
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, line_vaddr_rng, max_U64);
|
||||||
machine_code.size = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, line_vaddr_rng, machine_code.str);
|
machine_code = machine_code_slice.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: machine code => ctrl flow analysis
|
// rjf: machine code => ctrl flow analysis
|
||||||
@@ -3581,10 +3579,10 @@ df_tls_base_vaddr_from_process_root_rip(DF_Entity *process, U64 root_vaddr, U64
|
|||||||
//- rjf: read module's TLS index
|
//- rjf: read module's TLS index
|
||||||
U64 tls_index = 0;
|
U64 tls_index = 0;
|
||||||
{
|
{
|
||||||
U64 bytes_read = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, tls_vaddr_range, &tls_index);
|
CTRL_ProcessMemorySlice tls_index_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, tls_vaddr_range, max_U64);
|
||||||
if(bytes_read < sizeof(U64))
|
if(tls_index_slice.data.size >= addr_size)
|
||||||
{
|
{
|
||||||
tls_index = 0;
|
tls_index = *(U64 *)tls_index_slice.data.str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3658,14 +3656,14 @@ internal CTRL_Unwind
|
|||||||
df_push_unwind_from_thread(Arena *arena, DF_Entity *thread)
|
df_push_unwind_from_thread(Arena *arena, DF_Entity *thread)
|
||||||
{
|
{
|
||||||
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
|
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
|
||||||
CTRL_Unwind unwind = ctrl_unwind_from_process_thread(arena, thread->ctrl_machine_id, process->ctrl_handle, thread->ctrl_handle);
|
CTRL_Unwind unwind = ctrl_unwind_from_thread(arena, thread->ctrl_machine_id, thread->ctrl_handle, 0);
|
||||||
return unwind;
|
return unwind;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
df_rip_from_thread(DF_Entity *thread)
|
df_rip_from_thread(DF_Entity *thread)
|
||||||
{
|
{
|
||||||
U64 result = ctrl_rip_from_thread(thread->ctrl_machine_id, thread->ctrl_handle);
|
U64 result = ctrl_query_cached_rip_from_thread(thread->ctrl_machine_id, thread->ctrl_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3718,7 +3716,10 @@ df_push_member_map_from_binary_voff(Arena *arena, DBGI_Scope *scope, DF_Entity *
|
|||||||
internal B32
|
internal B32
|
||||||
df_set_thread_rip(DF_Entity *thread, U64 vaddr)
|
df_set_thread_rip(DF_Entity *thread, U64 vaddr)
|
||||||
{
|
{
|
||||||
B32 result = ctrl_thread_write_rip(thread->ctrl_machine_id, thread->ctrl_handle, vaddr);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
void *block = ctrl_query_cached_reg_block_from_thread(scratch.arena, thread->ctrl_machine_id, thread->ctrl_handle, max_U64);
|
||||||
|
regs_arch_block_write_rip(thread->arch, block, vaddr);
|
||||||
|
B32 result = ctrl_thread_write_reg_block(thread->ctrl_machine_id, thread->ctrl_handle, block);
|
||||||
|
|
||||||
// rjf: early mutation of unwind cache for immediate frontend effect
|
// rjf: early mutation of unwind cache for immediate frontend effect
|
||||||
if(result)
|
if(result)
|
||||||
@@ -3738,6 +3739,7 @@ df_set_thread_rip(DF_Entity *thread, U64 vaddr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scratch_end(scratch);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4134,7 +4136,7 @@ df_eval_from_string(Arena *arena, DBGI_Scope *scope, DF_CtrlCtx *ctrl_ctx, EVAL_
|
|||||||
|
|
||||||
//- rjf: unpack arguments
|
//- rjf: unpack arguments
|
||||||
DF_Entity *thread = df_entity_from_handle(ctrl_ctx->thread);
|
DF_Entity *thread = df_entity_from_handle(ctrl_ctx->thread);
|
||||||
U64 tls_root_vaddr = ctrl_tls_root_vaddr_from_thread(thread->ctrl_machine_id, thread->ctrl_handle);
|
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(thread->ctrl_machine_id, thread->ctrl_handle);
|
||||||
DF_Entity *process = thread->parent;
|
DF_Entity *process = thread->parent;
|
||||||
U64 unwind_count = ctrl_ctx->unwind_count;
|
U64 unwind_count = ctrl_ctx->unwind_count;
|
||||||
CTRL_Unwind unwind = df_query_cached_unwind_from_thread(thread);
|
CTRL_Unwind unwind = df_query_cached_unwind_from_thread(thread);
|
||||||
|
|||||||
@@ -240,9 +240,9 @@ df_process_info_list_from_query(Arena *arena, String8 query)
|
|||||||
//- rjf: build list
|
//- rjf: build list
|
||||||
DF_ProcessInfoList list = {0};
|
DF_ProcessInfoList list = {0};
|
||||||
{
|
{
|
||||||
DEMON_ProcessIter iter = {0};
|
DMN_ProcessIter iter = {0};
|
||||||
demon_proc_iter_begin(&iter);
|
dmn_process_iter_begin(&iter);
|
||||||
for(DEMON_ProcessInfo info = {0}; demon_proc_iter_next(scratch.arena, &iter, &info);)
|
for(DMN_ProcessInfo info = {0}; dmn_process_iter_next(scratch.arena, &iter, &info);)
|
||||||
{
|
{
|
||||||
// rjf: skip root-level or otherwise 0-pid processes
|
// rjf: skip root-level or otherwise 0-pid processes
|
||||||
if(info.pid == 0)
|
if(info.pid == 0)
|
||||||
@@ -290,7 +290,7 @@ df_process_info_list_from_query(Arena *arena, String8 query)
|
|||||||
list.count += 1;
|
list.count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
demon_proc_iter_end(&iter);
|
dmn_process_iter_end(&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
@@ -7552,8 +7552,9 @@ DF_VIEW_CMD_FUNCTION_DEF(Memory)
|
|||||||
|
|
||||||
DF_VIEW_UI_FUNCTION_DEF(Memory)
|
DF_VIEW_UI_FUNCTION_DEF(Memory)
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0, 0);
|
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
HS_Scope *hs_scope = hs_scope_open();
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: unpack state
|
//- rjf: unpack state
|
||||||
@@ -7766,8 +7767,8 @@ DF_VIEW_UI_FUNCTION_DEF(Memory)
|
|||||||
// rjf: try to read new memory for this range
|
// rjf: try to read new memory for this range
|
||||||
U64 bytes_to_read = dim_1u64(chunk_aligned_range_bytes);
|
U64 bytes_to_read = dim_1u64(chunk_aligned_range_bytes);
|
||||||
U8 *buffer = push_array_no_zero(scratch.arena, U8, bytes_to_read);
|
U8 *buffer = push_array_no_zero(scratch.arena, U8, bytes_to_read);
|
||||||
U64 half1_bytes_read = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, r1u64(chunk_aligned_range_bytes.min, chunk_aligned_range_bytes.min+bytes_to_read/2), buffer+0);
|
U64 half1_bytes_read = dmn_process_read(process->ctrl_handle, r1u64(chunk_aligned_range_bytes.min, chunk_aligned_range_bytes.min+bytes_to_read/2), buffer+0);
|
||||||
U64 half2_bytes_read = ctrl_process_read(process->ctrl_machine_id, process->ctrl_handle, r1u64(chunk_aligned_range_bytes.min+bytes_to_read/2, chunk_aligned_range_bytes.max), buffer+bytes_to_read/2);
|
U64 half2_bytes_read = dmn_process_read(process->ctrl_handle, r1u64(chunk_aligned_range_bytes.min+bytes_to_read/2, chunk_aligned_range_bytes.max), buffer+bytes_to_read/2);
|
||||||
|
|
||||||
// rjf: worked? -> clear cache & store
|
// rjf: worked? -> clear cache & store
|
||||||
if(half1_bytes_read+half2_bytes_read >= bytes_to_read)
|
if(half1_bytes_read+half2_bytes_read >= bytes_to_read)
|
||||||
@@ -8340,6 +8341,7 @@ DF_VIEW_UI_FUNCTION_DEF(Memory)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hs_scope_close(hs_scope);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ struct DF_EntityListerItemArray
|
|||||||
typedef struct DF_ProcessInfo DF_ProcessInfo;
|
typedef struct DF_ProcessInfo DF_ProcessInfo;
|
||||||
struct DF_ProcessInfo
|
struct DF_ProcessInfo
|
||||||
{
|
{
|
||||||
DEMON_ProcessInfo info;
|
DMN_ProcessInfo info;
|
||||||
B32 is_attached;
|
B32 is_attached;
|
||||||
FuzzyMatchRangeList attached_match_ranges;
|
FuzzyMatchRangeList attached_match_ranges;
|
||||||
FuzzyMatchRangeList name_match_ranges;
|
FuzzyMatchRangeList name_match_ranges;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include "regs/raddbgi/regs_raddbgi.h"
|
#include "regs/raddbgi/regs_raddbgi.h"
|
||||||
#include "type_graph/type_graph.h"
|
#include "type_graph/type_graph.h"
|
||||||
#include "dbgi/dbgi.h"
|
#include "dbgi/dbgi.h"
|
||||||
#include "demon/demon_inc.h"
|
#include "demon2/demon2_inc.h"
|
||||||
#include "eval/eval_inc.h"
|
#include "eval/eval_inc.h"
|
||||||
#include "unwind/unwind.h"
|
#include "unwind/unwind.h"
|
||||||
#include "ctrl/ctrl_inc.h"
|
#include "ctrl/ctrl_inc.h"
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
#include "regs/raddbgi/regs_raddbgi.c"
|
#include "regs/raddbgi/regs_raddbgi.c"
|
||||||
#include "type_graph/type_graph.c"
|
#include "type_graph/type_graph.c"
|
||||||
#include "dbgi/dbgi.c"
|
#include "dbgi/dbgi.c"
|
||||||
#include "demon/demon_inc.c"
|
#include "demon2/demon2_inc.c"
|
||||||
#include "eval/eval_inc.c"
|
#include "eval/eval_inc.c"
|
||||||
#include "unwind/unwind.c"
|
#include "unwind/unwind.c"
|
||||||
#include "ctrl/ctrl_inc.c"
|
#include "ctrl/ctrl_inc.c"
|
||||||
|
|||||||
Reference in New Issue
Block a user