mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 00:22:23 -07:00
bundle disassembly parameterizations into single dasm params type; extend with exe path & base address, to begin using debug info in the disassembly pass itself
This commit is contained in:
+86
-88
@@ -13,6 +13,21 @@
|
||||
#include "third_party/udis86/libudis86/syn.c"
|
||||
#include "third_party/udis86/libudis86/udis86.c"
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parameter Type Functions
|
||||
|
||||
internal B32
|
||||
dasm_params_match(DASM_Params *a, DASM_Params *b)
|
||||
{
|
||||
B32 result = (a->vaddr == b->vaddr &&
|
||||
a->arch == b->arch &&
|
||||
a->style_flags == b->style_flags &&
|
||||
a->syntax == b->syntax &&
|
||||
a->base_vaddr == b->base_vaddr &&
|
||||
str8_match(a->exe_path, b->exe_path, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Instruction Type Functions
|
||||
|
||||
@@ -134,16 +149,9 @@ dasm_scope_open(void)
|
||||
dasm_tctx = push_array(arena, DASM_TCTX, 1);
|
||||
dasm_tctx->arena = arena;
|
||||
}
|
||||
DASM_Scope *scope = dasm_tctx->free_scope;
|
||||
if(scope != 0)
|
||||
{
|
||||
SLLStackPop(dasm_tctx->free_scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
scope = push_array_no_zero(dasm_tctx->arena, DASM_Scope, 1);
|
||||
}
|
||||
MemoryZeroStruct(scope);
|
||||
U64 base_pos = arena_pos(dasm_tctx->arena);
|
||||
DASM_Scope *scope = push_array(dasm_tctx->arena, DASM_Scope, 1);
|
||||
scope->base_pos = base_pos;
|
||||
return scope;
|
||||
}
|
||||
|
||||
@@ -161,43 +169,27 @@ dasm_scope_close(DASM_Scope *scope)
|
||||
{
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(t->hash, n->hash) &&
|
||||
t->addr == n->addr &&
|
||||
t->arch == n->arch &&
|
||||
t->style_flags == n->style_flags &&
|
||||
t->syntax == n->syntax)
|
||||
if(u128_match(t->hash, n->hash) && dasm_params_match(&t->params, &n->params))
|
||||
{
|
||||
ins_atomic_u64_dec_eval(&n->scope_ref_count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SLLStackPush(dasm_tctx->free_touch, t);
|
||||
}
|
||||
SLLStackPush(dasm_tctx->free_scope, scope);
|
||||
arena_pop_to(dasm_tctx->arena, scope->base_pos);
|
||||
}
|
||||
|
||||
internal void
|
||||
dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node)
|
||||
{
|
||||
DASM_Touch *touch = dasm_tctx->free_touch;
|
||||
DASM_Touch *touch = push_array(dasm_tctx->arena, DASM_Touch, 1);
|
||||
ins_atomic_u64_inc_eval(&node->scope_ref_count);
|
||||
ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds());
|
||||
ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, dasm_user_clock_idx());
|
||||
if(touch != 0)
|
||||
{
|
||||
SLLStackPop(dasm_tctx->free_touch);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch = push_array_no_zero(dasm_tctx->arena, DASM_Touch, 1);
|
||||
}
|
||||
MemoryZeroStruct(touch);
|
||||
touch->hash = node->hash;
|
||||
touch->addr = node->addr;
|
||||
touch->arch = node->arch;
|
||||
touch->style_flags = node->style_flags;
|
||||
touch->syntax = node->syntax;
|
||||
MemoryCopyStruct(&touch->params, &node->params);
|
||||
touch->params.exe_path = push_str8_copy(dasm_tctx->arena, touch->params.exe_path);
|
||||
SLLStackPush(scope->top_touch, touch);
|
||||
}
|
||||
|
||||
@@ -205,7 +197,7 @@ dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node)
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal DASM_Info
|
||||
dasm_info_from_hash_addr_arch_style(DASM_Scope *scope, U128 hash, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax)
|
||||
dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params)
|
||||
{
|
||||
DASM_Info info = {0};
|
||||
if(!u128_match(hash, u128_zero()))
|
||||
@@ -219,11 +211,7 @@ dasm_info_from_hash_addr_arch_style(DASM_Scope *scope, U128 hash, U64 addr, Arch
|
||||
{
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(hash, n->hash) &&
|
||||
addr == n->addr &&
|
||||
arch == n->arch &&
|
||||
style_flags == n->style_flags &&
|
||||
syntax == n->syntax)
|
||||
if(u128_match(hash, n->hash) && dasm_params_match(params, &n->params))
|
||||
{
|
||||
MemoryCopyStruct(&info, &n->info);
|
||||
found = 1;
|
||||
@@ -240,11 +228,7 @@ dasm_info_from_hash_addr_arch_style(DASM_Scope *scope, U128 hash, U64 addr, Arch
|
||||
DASM_Node *node = 0;
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(hash, n->hash) &&
|
||||
addr == n->addr &&
|
||||
arch == n->arch &&
|
||||
style_flags == n->style_flags &&
|
||||
syntax == n->syntax)
|
||||
if(u128_match(hash, n->hash) && dasm_params_match(params, &n->params))
|
||||
{
|
||||
node = n;
|
||||
break;
|
||||
@@ -264,30 +248,28 @@ dasm_info_from_hash_addr_arch_style(DASM_Scope *scope, U128 hash, U64 addr, Arch
|
||||
MemoryZeroStruct(node);
|
||||
DLLPushBack(slot->first, slot->last, node);
|
||||
node->hash = hash;
|
||||
node->addr = addr;
|
||||
node->arch = arch;
|
||||
node->style_flags = style_flags;
|
||||
node->syntax = syntax;
|
||||
MemoryCopyStruct(&node->params, params);
|
||||
node->params.exe_path = push_str8_copy(stripe->arena, node->params.exe_path);
|
||||
node_is_new = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(node_is_new)
|
||||
{
|
||||
dasm_u2p_enqueue_req(hash, addr, arch, style_flags, syntax, max_U64);
|
||||
dasm_u2p_enqueue_req(hash, params, max_U64);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
internal DASM_Info
|
||||
dasm_info_from_key_addr_arch_style(DASM_Scope *scope, U128 key, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax, U128 *hash_out)
|
||||
dasm_info_from_key_params(DASM_Scope *scope, U128 key, DASM_Params *params, U128 *hash_out)
|
||||
{
|
||||
DASM_Info result = {0};
|
||||
for(U64 rewind_idx = 0; rewind_idx < 2; rewind_idx += 1)
|
||||
{
|
||||
U128 hash = hs_hash_from_key(key, rewind_idx);
|
||||
result = dasm_info_from_hash_addr_arch_style(scope, hash, addr, arch, style_flags, syntax);
|
||||
result = dasm_info_from_hash_params(scope, hash, params);
|
||||
if(result.insts.count != 0)
|
||||
{
|
||||
if(hash_out)
|
||||
@@ -304,21 +286,26 @@ dasm_info_from_key_addr_arch_style(DASM_Scope *scope, U128 key, U64 addr, Archit
|
||||
//~ rjf: Parse Threads
|
||||
|
||||
internal B32
|
||||
dasm_u2p_enqueue_req(U128 hash, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax, U64 endt_us)
|
||||
dasm_u2p_enqueue_req(U128 hash, DASM_Params *params, U64 endt_us)
|
||||
{
|
||||
B32 good = 0;
|
||||
OS_MutexScope(dasm_shared->u2p_ring_mutex) for(;;)
|
||||
{
|
||||
U64 unconsumed_size = dasm_shared->u2p_ring_write_pos - dasm_shared->u2p_ring_read_pos;
|
||||
U64 available_size = dasm_shared->u2p_ring_size - unconsumed_size;
|
||||
if(available_size >= sizeof(hash)+sizeof(addr)+sizeof(arch))
|
||||
if(available_size >= sizeof(hash)+sizeof(U64)+sizeof(Architecture)+sizeof(DASM_StyleFlags)+sizeof(DASM_Syntax)+sizeof(U64)+sizeof(U64)+params->exe_path.size)
|
||||
{
|
||||
good = 1;
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &hash);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &addr);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &arch);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &style_flags);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, &syntax);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->vaddr);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->arch);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->style_flags);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->syntax);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->base_vaddr);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, ¶ms->exe_path.size);
|
||||
dasm_shared->u2p_ring_write_pos += ring_write(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_write_pos, params->exe_path.str, params->exe_path.size);
|
||||
dasm_shared->u2p_ring_write_pos += 7;
|
||||
dasm_shared->u2p_ring_write_pos -= dasm_shared->u2p_ring_write_pos%8;
|
||||
break;
|
||||
}
|
||||
if(os_now_microseconds() >= endt_us)
|
||||
@@ -335,18 +322,24 @@ dasm_u2p_enqueue_req(U128 hash, U64 addr, Architecture arch, DASM_StyleFlags sty
|
||||
}
|
||||
|
||||
internal void
|
||||
dasm_u2p_dequeue_req(U128 *hash_out, U64 *addr_out, Architecture *arch_out, DASM_StyleFlags *style_flags_out, DASM_Syntax *syntax_out)
|
||||
dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out)
|
||||
{
|
||||
OS_MutexScope(dasm_shared->u2p_ring_mutex) for(;;)
|
||||
{
|
||||
U64 unconsumed_size = dasm_shared->u2p_ring_write_pos - dasm_shared->u2p_ring_read_pos;
|
||||
if(unconsumed_size >= sizeof(*hash_out)+sizeof(*addr_out)+sizeof(*arch_out))
|
||||
if(unconsumed_size >= sizeof(*hash_out)+sizeof(U64)+sizeof(Architecture)+sizeof(DASM_StyleFlags)+sizeof(DASM_Syntax)+sizeof(U64)+sizeof(U64))
|
||||
{
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, hash_out);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, addr_out);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, arch_out);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, style_flags_out);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, syntax_out);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->vaddr);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->arch);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->style_flags);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->syntax);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->base_vaddr);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read_struct(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, ¶ms_out->exe_path.size);
|
||||
params_out->exe_path.str = push_array(arena, U8, params_out->exe_path.size);
|
||||
dasm_shared->u2p_ring_read_pos += ring_read(dasm_shared->u2p_ring_base, dasm_shared->u2p_ring_size, dasm_shared->u2p_ring_read_pos, params_out->exe_path.str, params_out->exe_path.size);
|
||||
dasm_shared->u2p_ring_read_pos += 7;
|
||||
dasm_shared->u2p_ring_read_pos -= dasm_shared->u2p_ring_read_pos%8;
|
||||
break;
|
||||
}
|
||||
os_condition_variable_wait(dasm_shared->u2p_ring_cv, dasm_shared->u2p_ring_mutex, max_U64);
|
||||
@@ -364,12 +357,10 @@ dasm_parse_thread__entry_point(void *p)
|
||||
|
||||
//- rjf: get next request
|
||||
U128 hash = {0};
|
||||
U64 addr = 0;
|
||||
Architecture arch = Architecture_Null;
|
||||
DASM_StyleFlags style_flags = 0;
|
||||
DASM_Syntax syntax = DASM_Syntax_Intel;
|
||||
dasm_u2p_dequeue_req(&hash, &addr, &arch, &style_flags, &syntax);
|
||||
DASM_Params params = {0};
|
||||
dasm_u2p_dequeue_req(scratch.arena, &hash, ¶ms);
|
||||
HS_Scope *hs_scope = hs_scope_open();
|
||||
DBGI_Scope *dbgi_scope = dbgi_scope_open();
|
||||
|
||||
//- rjf: unpack hash
|
||||
U64 slot_idx = hash.u64[1]%dasm_shared->slots_count;
|
||||
@@ -383,11 +374,7 @@ dasm_parse_thread__entry_point(void *p)
|
||||
{
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(n->hash, hash) &&
|
||||
n->addr == addr &&
|
||||
n->arch == arch &&
|
||||
n->style_flags == style_flags &&
|
||||
n->syntax == syntax)
|
||||
if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms))
|
||||
{
|
||||
got_task = !ins_atomic_u32_eval_cond_assign(&n->is_working, 1, 0);
|
||||
break;
|
||||
@@ -395,6 +382,13 @@ dasm_parse_thread__entry_point(void *p)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: get dbg info
|
||||
DBGI_Parse *dbgi = &dbgi_parse_nil;
|
||||
if(got_task && params.exe_path.size != 0)
|
||||
{
|
||||
dbgi = dbgi_parse_from_exe_path(dbgi_scope, params.exe_path, max_U64);
|
||||
}
|
||||
|
||||
//- rjf: hash -> data
|
||||
String8 data = {0};
|
||||
if(got_task)
|
||||
@@ -402,12 +396,18 @@ dasm_parse_thread__entry_point(void *p)
|
||||
data = hs_data_from_hash(hs_scope, hash);
|
||||
}
|
||||
|
||||
//- rjf: data * arch * addr -> decode artifacts
|
||||
//- rjf: get first line info
|
||||
if(got_task)
|
||||
{
|
||||
// U32 voff_unit_idx = rdi_vmap_idx_from_voff();
|
||||
}
|
||||
|
||||
//- rjf: data * arch * addr * dbg -> decode artifacts
|
||||
DASM_InstChunkList inst_list = {0};
|
||||
String8List inst_strings = {0};
|
||||
if(got_task)
|
||||
{
|
||||
switch(arch)
|
||||
switch(params.arch)
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
@@ -418,11 +418,11 @@ dasm_parse_thread__entry_point(void *p)
|
||||
// rjf: grab context
|
||||
struct ud udc;
|
||||
ud_init(&udc);
|
||||
ud_set_mode(&udc, bit_size_from_arch(arch));
|
||||
ud_set_pc(&udc, addr);
|
||||
ud_set_mode(&udc, bit_size_from_arch(params.arch));
|
||||
ud_set_pc(&udc, params.vaddr);
|
||||
ud_set_input_buffer(&udc, data.str, data.size);
|
||||
ud_set_vendor(&udc, UD_VENDOR_ANY);
|
||||
ud_set_syntax(&udc, syntax == DASM_Syntax_Intel ? UD_SYN_INTEL : UD_SYN_ATT);
|
||||
ud_set_syntax(&udc, params.syntax == DASM_Syntax_Intel ? UD_SYN_INTEL : UD_SYN_ATT);
|
||||
|
||||
// rjf: disassemble
|
||||
U64 byte_process_start_off = 0;
|
||||
@@ -441,12 +441,12 @@ dasm_parse_thread__entry_point(void *p)
|
||||
|
||||
// rjf: push
|
||||
String8 addr_part = {0};
|
||||
if(style_flags & DASM_StyleFlag_Addresses)
|
||||
if(params.style_flags & DASM_StyleFlag_Addresses)
|
||||
{
|
||||
addr_part = push_str8f(scratch.arena, "%016I64X ", addr+off);
|
||||
addr_part = push_str8f(scratch.arena, "%016I64X ", params.vaddr+off);
|
||||
}
|
||||
String8 code_bytes_part = {0};
|
||||
if(style_flags & DASM_StyleFlag_CodeBytes)
|
||||
if(params.style_flags & DASM_StyleFlag_CodeBytes)
|
||||
{
|
||||
String8List code_bytes_strings = {0};
|
||||
str8_list_push(scratch.arena, &code_bytes_strings, str8_lit("{"));
|
||||
@@ -495,10 +495,11 @@ dasm_parse_thread__entry_point(void *p)
|
||||
{
|
||||
hash.u64[0],
|
||||
hash.u64[1],
|
||||
addr,
|
||||
(U64)arch,
|
||||
(U64)style_flags,
|
||||
(U64)syntax,
|
||||
params.vaddr,
|
||||
(U64)params.arch,
|
||||
(U64)params.style_flags,
|
||||
(U64)params.syntax,
|
||||
(U64)dbgi,
|
||||
0x4d534144,
|
||||
};
|
||||
text_key = hs_hash_from_data(str8((U8 *)hash_data, sizeof(hash_data)));
|
||||
@@ -518,11 +519,7 @@ dasm_parse_thread__entry_point(void *p)
|
||||
{
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(n->hash, hash) &&
|
||||
addr == n->addr &&
|
||||
arch == n->arch &&
|
||||
style_flags == n->style_flags &&
|
||||
syntax == n->syntax)
|
||||
if(u128_match(n->hash, hash) && dasm_params_match(&n->params, ¶ms))
|
||||
{
|
||||
n->info_arena = info_arena;
|
||||
MemoryCopyStruct(&n->info, &info);
|
||||
@@ -533,6 +530,7 @@ dasm_parse_thread__entry_point(void *p)
|
||||
}
|
||||
}
|
||||
|
||||
dbgi_scope_close(dbgi_scope);
|
||||
hs_scope_close(hs_scope);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
+26
-14
@@ -22,6 +22,20 @@ typedef enum DASM_Syntax
|
||||
}
|
||||
DASM_Syntax;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Disassembling Parameters Bundle
|
||||
|
||||
typedef struct DASM_Params DASM_Params;
|
||||
struct DASM_Params
|
||||
{
|
||||
U64 vaddr;
|
||||
Architecture arch;
|
||||
DASM_StyleFlags style_flags;
|
||||
DASM_Syntax syntax;
|
||||
U64 base_vaddr;
|
||||
String8 exe_path;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Instruction Types
|
||||
|
||||
@@ -80,10 +94,7 @@ struct DASM_Node
|
||||
|
||||
// rjf: key
|
||||
U128 hash;
|
||||
U64 addr;
|
||||
Architecture arch;
|
||||
DASM_StyleFlags style_flags;
|
||||
DASM_Syntax syntax;
|
||||
DASM_Params params;
|
||||
|
||||
// rjf: value
|
||||
Arena *info_arena;
|
||||
@@ -121,10 +132,7 @@ struct DASM_Touch
|
||||
{
|
||||
DASM_Touch *next;
|
||||
U128 hash;
|
||||
U64 addr;
|
||||
Architecture arch;
|
||||
DASM_StyleFlags style_flags;
|
||||
DASM_Syntax syntax;
|
||||
DASM_Params params;
|
||||
};
|
||||
|
||||
typedef struct DASM_Scope DASM_Scope;
|
||||
@@ -132,6 +140,7 @@ struct DASM_Scope
|
||||
{
|
||||
DASM_Scope *next;
|
||||
DASM_Touch *top_touch;
|
||||
U64 base_pos;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -141,8 +150,6 @@ typedef struct DASM_TCTX DASM_TCTX;
|
||||
struct DASM_TCTX
|
||||
{
|
||||
Arena *arena;
|
||||
DASM_Scope *free_scope;
|
||||
DASM_Touch *free_touch;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -184,6 +191,11 @@ struct DASM_Shared
|
||||
thread_static DASM_TCTX *dasm_tctx = 0;
|
||||
global DASM_Shared *dasm_shared = 0;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parameter Type Functions
|
||||
|
||||
internal B32 dasm_params_match(DASM_Params *a, DASM_Params *b);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Instruction Type Functions
|
||||
|
||||
@@ -213,14 +225,14 @@ internal void dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_No
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal DASM_Info dasm_info_from_hash_addr_arch_style(DASM_Scope *scope, U128 hash, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax);
|
||||
internal DASM_Info dasm_info_from_key_addr_arch_style(DASM_Scope *scope, U128 key, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax, U128 *hash_out);
|
||||
internal DASM_Info dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params);
|
||||
internal DASM_Info dasm_info_from_key_params(DASM_Scope *scope, U128 key, DASM_Params *params, U128 *hash_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Parse Threads
|
||||
|
||||
internal B32 dasm_u2p_enqueue_req(U128 hash, U64 addr, Architecture arch, DASM_StyleFlags style_flags, DASM_Syntax syntax, U64 endt_us);
|
||||
internal void dasm_u2p_dequeue_req(U128 *hash_out, U64 *addr_out, Architecture *arch_out, DASM_StyleFlags *style_flags_out, DASM_Syntax *syntax_out);
|
||||
internal B32 dasm_u2p_enqueue_req(U128 hash, DASM_Params *params, U64 endt_us);
|
||||
internal void dasm_u2p_dequeue_req(Arena *arena, U128 *hash_out, DASM_Params *params_out);
|
||||
internal void dasm_parse_thread__entry_point(void *p);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -684,7 +684,16 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(disasm)
|
||||
|
||||
//- rjf: key -> parsed text info
|
||||
U128 data_hash = {0};
|
||||
DASM_Info dasm_info = dasm_info_from_key_addr_arch_style(dasm_scope, dasm_key, vaddr_range.min, top.arch, 0, DASM_Syntax_Intel, &data_hash);
|
||||
DASM_Params dasm_params = {0};
|
||||
{
|
||||
dasm_params.vaddr = vaddr_range.min;
|
||||
dasm_params.arch = top.arch;
|
||||
dasm_params.style_flags = DASM_StyleFlag_Addresses;
|
||||
dasm_params.syntax = DASM_Syntax_Intel;
|
||||
dasm_params.base_vaddr = 0;
|
||||
dasm_params.exe_path = str8_zero();
|
||||
}
|
||||
DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &data_hash);
|
||||
String8 dasm_text_data = {0};
|
||||
TXT_TextInfo dasm_text_info = {0};
|
||||
for(U64 rewind_idx = 0; rewind_idx < 2; rewind_idx += 1)
|
||||
|
||||
+20
-2
@@ -6064,7 +6064,16 @@ DF_VIEW_CMD_FUNCTION_DEF(Disassembly)
|
||||
Rng1U64 dasm_vaddr_range = r1u64(dasm_base_vaddr, dasm_base_vaddr+KB(64));
|
||||
U128 dasm_key = ctrl_hash_store_key_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, dasm_vaddr_range, 0);
|
||||
U128 dasm_data_hash = {0};
|
||||
DASM_Info dasm_info = dasm_info_from_key_addr_arch_style(dasm_scope, dasm_key, dasm_vaddr_range.min, arch, dv->style_flags, DASM_Syntax_Intel, &dasm_data_hash);
|
||||
DASM_Params dasm_params = {0};
|
||||
{
|
||||
dasm_params.vaddr = dasm_vaddr_range.min;
|
||||
dasm_params.arch = arch;
|
||||
dasm_params.style_flags = dv->style_flags;
|
||||
dasm_params.syntax = DASM_Syntax_Intel;
|
||||
dasm_params.base_vaddr = 0;
|
||||
dasm_params.exe_path = str8_zero();
|
||||
}
|
||||
DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash);
|
||||
U128 dasm_text_hash = {0};
|
||||
TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, dasm_info.text_key, txt_lang_kind_from_architecture(arch), &dasm_text_hash);
|
||||
String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash);
|
||||
@@ -6307,7 +6316,16 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly)
|
||||
Rng1U64 dasm_vaddr_range = r1u64(dasm_base_vaddr, dasm_base_vaddr+KB(64));
|
||||
U128 dasm_key = ctrl_hash_store_key_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, dasm_vaddr_range, 0);
|
||||
U128 dasm_data_hash = {0};
|
||||
DASM_Info dasm_info = dasm_info_from_key_addr_arch_style(dasm_scope, dasm_key, dasm_vaddr_range.min, arch, dv->style_flags, DASM_Syntax_Intel, &dasm_data_hash);
|
||||
DASM_Params dasm_params = {0};
|
||||
{
|
||||
dasm_params.vaddr = dasm_vaddr_range.min;
|
||||
dasm_params.arch = arch;
|
||||
dasm_params.style_flags = dv->style_flags;
|
||||
dasm_params.syntax = DASM_Syntax_Intel;
|
||||
dasm_params.base_vaddr = 0;
|
||||
dasm_params.exe_path = str8_zero();
|
||||
}
|
||||
DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash);
|
||||
U128 dasm_text_hash = {0};
|
||||
TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, dasm_info.text_key, txt_lang_kind_from_architecture(arch), &dasm_text_hash);
|
||||
String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash);
|
||||
|
||||
Reference in New Issue
Block a user