transition to dbg_info2

This commit is contained in:
Ryan Fleury
2025-09-30 12:52:32 -07:00
parent 4b122dec51
commit 4964a94cd3
23 changed files with 356 additions and 602 deletions
+2 -2
View File
@@ -219,7 +219,7 @@ access_pt_is_expired_(AccessPt *pt, AccessPtExpireParams *params)
U64 last_time_touched_us = ins_atomic_u64_eval(&pt->last_time_touched_us);
U64 last_update_idx_touched = ins_atomic_u64_eval(&pt->last_update_idx_touched);
B32 result = (access_refcount == 0 &&
last_time_touched_us + params->time < os_now_microseconds() &&
last_update_idx_touched + params->update_idxs < update_tick_idx());
last_time_touched_us + params->time <= os_now_microseconds() &&
last_update_idx_touched + params->update_idxs <= update_tick_idx());
return result;
}
+35 -222
View File
@@ -786,11 +786,11 @@ ctrl_module_from_process_vaddr(CTRL_Entity *process, U64 vaddr)
return result;
}
internal DI_Key
internal DI2_Key
ctrl_dbgi_key_from_module(CTRL_Entity *module)
{
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
DI_Key dbgi_key = {debug_info_path->string, debug_info_path->timestamp};
DI2_Key dbgi_key = di2_key_from_path_timestamp(debug_info_path->string, debug_info_path->timestamp);
return dbgi_key;
}
@@ -1176,15 +1176,15 @@ ctrl_entity_array_from_kind(CTRL_EntityCtx *ctx, CTRL_EntityKind kind)
}
internal CTRL_EntityList
ctrl_modules_from_dbgi_key(Arena *arena, CTRL_EntityCtx *ctx, DI_Key *dbgi_key)
ctrl_modules_from_dbgi_key(Arena *arena, CTRL_EntityCtx *ctx, DI2_Key dbgi_key)
{
CTRL_EntityList list = {0};
CTRL_EntityArray all_modules = ctrl_entity_array_from_kind(ctx, CTRL_EntityKind_Module);
for EachIndex(idx, all_modules.count)
{
CTRL_Entity *module = all_modules.v[idx];
DI_Key module_dbgi_key = ctrl_dbgi_key_from_module(module);
if(di_key_match(&module_dbgi_key, dbgi_key))
DI2_Key module_dbgi_key = ctrl_dbgi_key_from_module(module);
if(di2_key_match(module_dbgi_key, dbgi_key))
{
ctrl_entity_list_push(arena, &list, module);
}
@@ -2756,7 +2756,7 @@ internal CTRL_CallStack
ctrl_call_stack_from_unwind(Arena *arena, CTRL_Entity *process, CTRL_Unwind *base_unwind)
{
Temp scratch = scratch_begin(&arena, 1);
DI_Scope *di_scope = di_scope_open();
Access *access = access_open();
Arch arch = process->arch;
CTRL_CallStack result = {0};
{
@@ -2778,8 +2778,8 @@ ctrl_call_stack_from_unwind(Arena *arena, CTRL_Entity *process, CTRL_Unwind *bas
U64 rip_vaddr = regs_rip_from_arch_block(arch, src->regs);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
RDI_Scope *scope = rdi_scope_from_voff(rdi, rip_voff);
// rjf: build inline frames (minus parent & inline depth)
@@ -2841,7 +2841,7 @@ ctrl_call_stack_from_unwind(Arena *arena, CTRL_Entity *process, CTRL_Unwind *bas
}
}
}
di_scope_close(di_scope);
access_close(access);
scratch_end(scratch);
return result;
}
@@ -3185,16 +3185,16 @@ ctrl_thread__entry_point(void *p)
String8 path = msg->path;
CTRL_Entity *module = ctrl_entity_from_handle(entity_ctx, msg->entity);
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
DI_Key old_dbgi_key = {debug_info_path->string, debug_info_path->timestamp};
di_close(&old_dbgi_key);
DI2_Key old_dbgi_key = di2_key_from_path_timestamp(debug_info_path->string, debug_info_path->timestamp);
di2_close(old_dbgi_key);
MutexScopeW(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
{
ctrl_entity_equip_string(ctrl_state->ctrl_thread_entity_store, debug_info_path, path_normalized_from_string(scratch.arena, path));
}
U64 new_dbgi_timestamp = os_properties_from_file_path(path).modified;
debug_info_path->timestamp = new_dbgi_timestamp;
DI_Key new_dbgi_key = {debug_info_path->string, new_dbgi_timestamp};
di_open(&new_dbgi_key);
DI2_Key new_dbgi_key = di2_key_from_path_timestamp(debug_info_path->string, new_dbgi_timestamp);
di2_open(new_dbgi_key);
CTRL_EventList evts = {0};
CTRL_Event *evt = ctrl_event_list_push(scratch.arena, &evts);
evt->kind = CTRL_EventKind_ModuleDebugInfoPathChange;
@@ -3259,12 +3259,12 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_EvalScope *
if(user_bps->first == 0) { return; }
ProfBeginFunction();
Temp scratch = scratch_begin(&arena, 1);
DI_Scope *di_scope = eval_scope->di_scope;
Access *access = eval_scope->access;
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
CTRL_Entity *module_entity = ctrl_entity_from_handle(entity_ctx, module);
CTRL_Entity *debug_info_path_entity = ctrl_entity_child_from_kind(module_entity, CTRL_EntityKind_DebugInfoPath);
DI_Key dbgi_key = {debug_info_path_entity->string, debug_info_path_entity->timestamp};
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module_entity);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
U64 base_vaddr = module_entity->vaddr_range.min;
for(CTRL_UserBreakpointNode *n = user_bps->first; n != 0; n = n->next)
{
@@ -3828,7 +3828,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
if(!should_filter_event && ev->code == 0xc0000005 &&
(spoof == 0 || ev->instruction_pointer != spoof->new_ip_value))
{
DI_Scope *di_scope = di_scope_open();
Access *access = access_open();
CTRL_Entity *process = ctrl_entity_from_handle(entity_ctx, ctrl_handle_make(CTRL_MachineID_Local, ev->process));
CTRL_Entity *module = &ctrl_entity_nil;
for(CTRL_Entity *child = process->first; child != &ctrl_entity_nil; child = child->next)
@@ -3844,9 +3844,8 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
// rjf: determine base address of asan shadow space
U64 asan_shadow_base_vaddr = 0;
B32 asan_shadow_variable_exists_but_is_zero = 0;
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, max_U64);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, max_U64);
RDI_NameMap *unparsed_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
{
RDI_ParsedNameMap map = {0};
@@ -3888,7 +3887,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
}
}
di_scope_close(di_scope);
access_close(access);
}
}break;
}
@@ -4057,8 +4056,8 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
out_evt2->parent = process_handle;
out_evt2->timestamp = debug_info_timestamp;
out_evt2->string = initial_debug_info_path;
DI_Key initial_dbgi_key = {initial_debug_info_path, debug_info_timestamp};
di_open(&initial_dbgi_key);
DI2_Key initial_dbgi_key = di2_key_from_path_timestamp(initial_debug_info_path, debug_info_timestamp);
di2_open(initial_dbgi_key);
}break;
case DMN_EventKind_ExitProcess:
{
@@ -4090,12 +4089,8 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
out_evt->msg_id = msg->msg_id;
out_evt->entity = module_handle;
out_evt->string = module_path;
CTRL_Entity *debug_info_path_ent = ctrl_entity_child_from_kind(module_ent, CTRL_EntityKind_DebugInfoPath);
if(debug_info_path_ent != &ctrl_entity_nil)
{
DI_Key dbgi_key = {debug_info_path_ent->string, debug_info_path_ent->timestamp};
di_close(&dbgi_key);
}
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module_ent);
di2_close(dbgi_key);
}break;
case DMN_EventKind_DebugString:
{
@@ -4169,187 +4164,6 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
ctrl_state->dbg_dir_root = push_array(ctrl_state->dbg_dir_arena, CTRL_DbgDirNode, 1);
}
//- rjf: when a new module is loaded, pre-emptively try to open all adjacent
// debug infos. with debug events, we learn about loaded modules serially,
// and we need to completely load debug info before continuing. for massive
// projects, this is a problem, because completely loading debug info isn't a
// trivial cost, and there are often 1000s of DLLs.
//
// an imperfect but usually reasonable heuristic is to look at adjacent
// debug info files, in the same or under the directory as the initially
// loaded, and pre-emptively convert all of them (which for us is the
// heaviest part of debug info loading, if native RDI is not used).
//
// only do this on the first ever loaded module, *or* once we get beyond 256
// modules (a very bad heuristic that may or may not inform us that we are
// dealing with insane-town projects)
//
if(0 &&
event->kind == DMN_EventKind_LoadModule &&
(entity_ctx->entity_kind_counts[CTRL_EntityKind_Module] > 256 ||
entity_ctx->entity_kind_counts[CTRL_EntityKind_Module] == 1))
{
//- rjf: unpack event
CTRL_Handle process_handle = ctrl_handle_make(CTRL_MachineID_Local, event->process);
CTRL_Handle loaded_module_handle = ctrl_handle_make(CTRL_MachineID_Local, event->module);
CTRL_Entity *process = ctrl_entity_from_handle(entity_ctx, process_handle);
CTRL_Entity *loaded_module = ctrl_entity_from_handle(entity_ctx, loaded_module_handle);
//- rjf: for each module, use its full path as the start to a new limited recursive
// directory search. cache each directory once traversed in the dbg_dir tree. if any
// node is not cached, then scan it & pre-emptively convert debug info.
ProfScope("pre-emptively load adjacent debug info for %.*s", str8_varg(loaded_module->string))
{
//- rjf: calculate seed path
DI_Key loaded_di_key = ctrl_dbgi_key_from_module(loaded_module);
String8 loaded_di_name = str8_skip_last_slash(loaded_di_key.path);
String8 debug_info_ext = str8_skip_last_dot(loaded_di_key.path);
String8 seed_folder_path = str8_chop_last_slash(loaded_di_key.path);
if(seed_folder_path.size == 0)
{
String8 module_path = loaded_module->string;
seed_folder_path = str8_chop_last_slash(module_path);
}
//- rjf: split seed path
String8List seed_path_parts = str8_split_path(scratch.arena, seed_folder_path);
//- rjf: find parent dir node for this module's debug info; build tree leading to this dir
CTRL_DbgDirNode *parent_dir_node = ctrl_state->dbg_dir_root;
for(String8Node *n = seed_path_parts.first; n != 0; n = n->next)
{
String8 name = n->string;
CTRL_DbgDirNode *next_child = 0;
for(CTRL_DbgDirNode *child = parent_dir_node->first; child != 0; child = child->next)
{
if(str8_match(child->name, name, StringMatchFlag_CaseInsensitive))
{
next_child = child;
break;
}
}
if(next_child == 0)
{
next_child = push_array(ctrl_state->dbg_dir_arena, CTRL_DbgDirNode, 1);
DLLPushBack(parent_dir_node->first, parent_dir_node->last, next_child);
next_child->parent = parent_dir_node;
next_child->name = push_str8_copy(ctrl_state->dbg_dir_arena, name);
parent_dir_node->child_count += 1;
}
parent_dir_node = next_child;
}
//- rjf: count modules
{
parent_dir_node->module_direct_count += 1;
}
//- rjf: iterate from dir node up its ancestor chain - do recursive
// searches if this is an ancestor of loaded modules, it has not been
// searched yet, but it has >4 child branches, meaning it looks like
// project directory
//
DI_KeyList preemptively_loaded_keys = {0};
for(CTRL_DbgDirNode *dir_node = parent_dir_node; dir_node != 0; dir_node = dir_node->parent)
{
if(dir_node->search_count == 0 && dir_node->module_direct_count >= 1)
{
//- rjf: form full path of this directory node
String8List dir_node_path_parts = {0};
for(CTRL_DbgDirNode *n = dir_node; n != 0; n = n->parent)
{
if(n->name.size != 0)
{
str8_list_push_front(scratch.arena, &dir_node_path_parts, n->name);
}
}
String8 dir_node_path = str8_list_join(scratch.arena, &dir_node_path_parts, &(StringJoin){.sep = str8_lit("/")});
//- rjf: iterate downwards from this directory recursively, locate
// debug infos, and pre-emptively convert
typedef struct Task Task;
struct Task
{
Task *next;
CTRL_DbgDirNode *node;
String8 path;
};
Task start_task = {0, dir_node, dir_node_path};
Task *first_task = &start_task;
Task *last_task = first_task;
U64 task_count = 0;
for(Task *t = first_task; t != 0; t = t->next)
{
ProfBegin("search task %.*s", str8_varg(t->path));
// rjf: increment search counter
t->node->search_count += 1;
// rjf: iterate this directory. if debug infos are encountered,
// kick off pre-emptive conversion, and gather key. if folders
// are encountered, then add them to the tree, and kick off a
// sub-search if needed.
OS_FileIter *it = os_file_iter_begin(scratch.arena, t->path, 0);
U64 idx = 0;
for(OS_FileInfo info = {0}; idx < 16384 && os_file_iter_next(scratch.arena, it, &info); idx += 1)
{
// rjf: folder -> do sub-search if not duplicative
if(info.props.flags & FilePropertyFlag_IsFolder && task_count < 16384 && !str8_match(str8_prefix(info.name, 1), str8_lit("."), 0))
{
CTRL_DbgDirNode *existing_dir_child = 0;
for(CTRL_DbgDirNode *child = t->node->first; child != 0; child = child->next)
{
if(str8_match(child->name, info.name, StringMatchFlag_CaseInsensitive))
{
existing_dir_child = child;
break;
}
}
if(existing_dir_child == 0)
{
existing_dir_child = push_array(ctrl_state->dbg_dir_arena, CTRL_DbgDirNode, 1);
DLLPushBack(t->node->first, t->node->last, existing_dir_child);
existing_dir_child->parent = t->node;
existing_dir_child->name = push_str8_copy(ctrl_state->dbg_dir_arena, info.name);
t->node->child_count += 1;
}
if(existing_dir_child->search_count == 0)
{
Task *task = push_array(scratch.arena, Task, 1);
task->node = existing_dir_child;
task->path = push_str8f(scratch.arena, "%S/%S", t->path, info.name);
SLLQueuePush(first_task, last_task, task);
task_count += 1;
}
}
// rjf: debug info file -> kick off open
else if(preemptively_loaded_keys.count < 4096 &&
!(info.props.flags & FilePropertyFlag_IsFolder) &&
str8_match(str8_skip_last_dot(info.name), debug_info_ext, StringMatchFlag_CaseInsensitive) &&
!str8_match(loaded_di_name, info.name, StringMatchFlag_CaseInsensitive))
{
DI_Key key = {push_str8f(scratch.arena, "%S/%S", t->path, info.name), info.props.modified};
di_open(&key);
di_key_list_push(scratch.arena, &preemptively_loaded_keys, &key);
if(preemptively_loaded_keys.count >= Max(1, async_thread_count()/2))
{
for(DI_KeyNode *n = preemptively_loaded_keys.first; n != 0; n = n->next)
{
di_close(&n->v);
}
MemoryZeroStruct(&preemptively_loaded_keys);
}
}
}
os_file_iter_end(it);
ProfEnd();
}
}
}
}
}
//- rjf: out of queued up demon events -> clear event arena
if(ctrl_state->first_dmn_event_node == 0)
{
@@ -4416,7 +4230,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
{
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
CTRL_EvalScope *scope = push_array(arena, CTRL_EvalScope, 1);
scope->di_scope = di_scope_open();
scope->access = access_open();
//////////////////////////////
//- rjf: unpack thread
@@ -4452,11 +4266,10 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
mod = mod->next)
{
if(mod->kind != CTRL_EntityKind_Module) { continue; }
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(mod, CTRL_EntityKind_DebugInfoPath);
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(mod);
//- rjf: try to obtain this module's RDI
RDI_Parsed *rdi = di_rdi_from_key(scope->di_scope, &dbgi_key, 1, 0);
RDI_Parsed *rdi = di2_rdi_from_key(scope->access, dbgi_key, 0, 0);
//- rjf: if this RDI is not yet ready => determine if we need to wait for it
//
@@ -4488,7 +4301,8 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
// rjf: not cached -> compute & store
else ProfScope("cache miss")
{
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, dbgi_key.path);
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(mod, CTRL_EntityKind_DebugInfoPath);
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, debug_info_path->string);
{
//- rjf: determine if file is PDB
B32 file_is_pdb = 0;
@@ -4538,7 +4352,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
//- rjf: if this RDI is necessary, but we do not have it => wait for it forever
if(rdi == &rdi_parsed_nil && rdi_is_necessary)
{
rdi = di_rdi_from_key(scope->di_scope, &dbgi_key, 1, max_U64);
rdi = di2_rdi_from_key(scope->access, dbgi_key, 1, max_U64);
}
//- rjf: fill evaluation module info
@@ -4625,7 +4439,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
internal void
ctrl_thread__eval_scope_end(CTRL_EvalScope *scope)
{
di_scope_close(scope->di_scope);
access_close(scope->access);
}
//- rjf: log flusher
@@ -5351,15 +5165,14 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
if(msg->run_flags & CTRL_RunFlag_StopOnEntryPoint && !launch_done_first_module && event->kind == DMN_EventKind_HandshakeComplete)
{
launch_done_first_module = 1;
DI_Scope *di_scope = di_scope_open();
Access *access = access_open();
//- rjf: unpack process/module info
CTRL_Entity *process = ctrl_entity_from_handle(entity_ctx, ctrl_handle_make(CTRL_MachineID_Local, event->process));
CTRL_Entity *module = ctrl_entity_child_from_kind(process, CTRL_EntityKind_Module);
U64 module_base_vaddr = module->vaddr_range.min;
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, max_U64);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, max_U64);
RDI_NameMap *unparsed_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
RDI_ParsedNameMap map = {0};
rdi_parsed_from_name_map(rdi, unparsed_map, &map);
@@ -5572,7 +5385,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
//- rjf: found entry points -> add to joined traps
dmn_trap_chunk_list_concat_shallow_copy(scratch.arena, &joined_traps, &entry_traps);
di_scope_close(di_scope);
access_close(access);
}
//////////////////////////
+3 -3
View File
@@ -650,7 +650,7 @@ struct CTRL_DbgDirNode
typedef struct CTRL_EvalScope CTRL_EvalScope;
struct CTRL_EvalScope
{
DI_Scope *di_scope;
Access *access;
E_BaseCtx base_ctx;
E_IRCtx ir_ctx;
E_InterpretCtx interpret_ctx;
@@ -845,7 +845,7 @@ internal CTRL_Entity *ctrl_entity_child_from_kind(CTRL_Entity *parent, CTRL_Enti
internal CTRL_Entity *ctrl_entity_ancestor_from_kind(CTRL_Entity *entity, CTRL_EntityKind kind);
internal CTRL_Entity *ctrl_process_from_entity(CTRL_Entity *entity);
internal CTRL_Entity *ctrl_module_from_process_vaddr(CTRL_Entity *process, U64 vaddr);
internal DI_Key ctrl_dbgi_key_from_module(CTRL_Entity *module);
internal DI2_Key ctrl_dbgi_key_from_module(CTRL_Entity *module);
internal CTRL_Entity *ctrl_module_from_thread_candidates(CTRL_EntityCtx *ctx, CTRL_Entity *thread, CTRL_EntityList *candidates);
internal U64 ctrl_vaddr_from_voff(CTRL_Entity *module, U64 voff);
internal U64 ctrl_voff_from_vaddr(CTRL_Entity *module, U64 vaddr);
@@ -877,7 +877,7 @@ internal void ctrl_entity_equip_string(CTRL_EntityCtxRWStore *store, CTRL_Entity
//- rjf: accelerated entity context lookups
internal CTRL_EntityCtxLookupAccel *ctrl_thread_entity_ctx_lookup_accel(void);
internal CTRL_EntityArray ctrl_entity_array_from_kind(CTRL_EntityCtx *ctx, CTRL_EntityKind kind);
internal CTRL_EntityList ctrl_modules_from_dbgi_key(Arena *arena, CTRL_EntityCtx *ctx, DI_Key *dbgi_key);
internal CTRL_EntityList ctrl_modules_from_dbgi_key(Arena *arena, CTRL_EntityCtx *ctx, DI2_Key dbgi_key);
internal CTRL_Entity *ctrl_thread_from_id(CTRL_EntityCtx *ctx, U64 id);
//- rjf: applying events to entity caches
+47 -131
View File
@@ -152,7 +152,6 @@ d_line_list_copy(Arena *arena, D_LineList *list)
D_LineNode *dst_n = push_array(arena, D_LineNode, 1);
MemoryCopyStruct(dst_n, src_n);
dst_n->v.file_path = push_str8_copy(arena, dst_n->v.file_path);
dst_n->v.dbgi_key = di_key_copy(arena, &src_n->v.dbgi_key);
SLLQueuePush(dst.first, dst.last, dst_n);
dst.count += 1;
}
@@ -340,15 +339,15 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
U64 ip_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
log_infof("ip_vaddr: 0x%I64x\n", ip_vaddr);
log_infof("dbgi_key: {%S, 0x%I64x}\n", dbgi_key.path, dbgi_key.min_timestamp);
log_infof("dbgi_key: {0x%I64x, 0x%I64x}\n", dbgi_key.u64[0], dbgi_key.u64[1]);
// rjf: ip => line vaddr range
Rng1U64 line_vaddr_rng = {0};
{
U64 ip_voff = ctrl_voff_from_vaddr(module, ip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, ip_voff);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff);
Rng1U64 line_voff_rng = {0};
if(lines.first != 0)
{
@@ -366,7 +365,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
// is enabled. This is enabled by default normally.
{
U64 opl_line_voff_rng = ctrl_voff_from_vaddr(module, line_vaddr_rng.max);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, opl_line_voff_rng);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng);
if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee))
{
line_vaddr_rng.max = ctrl_vaddr_from_voff(module, lines.first->v.voff_range.max);
@@ -503,13 +502,13 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
U64 ip_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
// rjf: ip => line vaddr range
Rng1U64 line_vaddr_rng = {0};
{
U64 ip_voff = ctrl_voff_from_vaddr(module, ip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, ip_voff);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff);
Rng1U64 line_voff_rng = {0};
if(lines.first != 0)
{
@@ -524,7 +523,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
// is enabled. This is enabled by default normally.
{
U64 opl_line_voff_rng = ctrl_voff_from_vaddr(module, line_vaddr_rng.max);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, opl_line_voff_rng);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng);
if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee))
{
line_vaddr_rng.max = ctrl_vaddr_from_voff(module, lines.first->v.voff_range.max);
@@ -586,8 +585,8 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
U64 jump_dest_vaddr = point->jump_dest_vaddr;
CTRL_Entity *jump_dest_module = ctrl_module_from_process_vaddr(process, jump_dest_vaddr);
U64 jump_dest_voff = ctrl_voff_from_vaddr(jump_dest_module, jump_dest_vaddr);
DI_Key jump_dest_dbgi_key = ctrl_dbgi_key_from_module(jump_dest_module);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &jump_dest_dbgi_key, jump_dest_voff);
DI2_Key jump_dest_dbgi_key = ctrl_dbgi_key_from_module(jump_dest_module);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, jump_dest_dbgi_key, jump_dest_voff);
if(lines.count == 0)
{
add = 0;
@@ -644,97 +643,14 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
////////////////////////////////
//~ rjf: Debug Info Lookups
//- rjf: symbol -> voff lookups
internal U64
d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name)
{
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
DI_Scope *scope = di_scope_open();
U64 result = 0;
{
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 1, 0);
RDI_NameMapKind name_map_kinds[] =
{
RDI_NameMapKind_GlobalVariables,
RDI_NameMapKind_Procedures,
};
if(rdi != &rdi_parsed_nil)
{
for(U64 name_map_kind_idx = 0;
name_map_kind_idx < ArrayCount(name_map_kinds);
name_map_kind_idx += 1)
{
RDI_NameMapKind name_map_kind = name_map_kinds[name_map_kind_idx];
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, name_map_kind);
RDI_ParsedNameMap parsed_name_map = {0};
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, symbol_name.str, symbol_name.size);
// rjf: node -> num
U64 entity_num = 0;
if(node != 0)
{
switch(node->match_count)
{
case 1:
{
entity_num = node->match_idx_or_idx_run_first + 1;
}break;
default:
{
U32 num = 0;
U32 *run = rdi_matches_from_map_node(rdi, node, &num);
if(num != 0)
{
entity_num = run[0]+1;
}
}break;
}
}
// rjf: num -> voff
U64 voff = 0;
if(entity_num != 0) switch(name_map_kind)
{
default:{}break;
case RDI_NameMapKind_GlobalVariables:
{
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, entity_num-1);
voff = global_var->voff;
}break;
case RDI_NameMapKind_Procedures:
{
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, entity_num-1);
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
voff = *rdi_element_from_name_idx(rdi, ScopeVOffData, scope->voff_range_first);
}break;
}
// rjf: nonzero voff -> break
if(voff != 0)
{
result = voff;
break;
}
}
}
}
di_scope_close(scope);
scratch_end(scratch);
ProfEnd();
return result;
}
//- rjf: voff -> line info
internal D_LineList
d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
d_lines_from_dbgi_key_voff(Arena *arena, DI2_Key dbgi_key, U64 voff)
{
Temp scratch = scratch_begin(&arena, 1);
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 1, 0);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, 0);
D_LineList result = {0};
{
//- rjf: gather line tables
@@ -799,7 +715,7 @@ d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
}
n->v.pt = txt_pt(line->line_num, column ? column->col_first : 1);
n->v.voff_range = r1u64(parsed_line_table.voffs[line_info_idx], parsed_line_table.voffs[line_info_idx+1]);
n->v.dbgi_key = *dbgi_key;
n->v.dbgi_key = dbgi_key;
if(line_table_n == top_line_table)
{
shallowest_voff_range = n->v.voff_range;
@@ -813,7 +729,7 @@ d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
n->v.voff_range = intersect_1u64(n->v.voff_range, shallowest_voff_range);
}
}
di_scope_close(scope);
access_close(access);
scratch_end(scratch);
return result;
}
@@ -823,17 +739,17 @@ d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
// TODO(rjf): this depends on file path maps, needs to move
internal D_LineListArray
d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key, String8 file_path, Rng1S64 line_num_range)
d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI2_Key dbgi_key, String8 file_path, Rng1S64 line_num_range)
{
D_LineListArray array = {0};
{
array.count = dim_1s64(line_num_range)+1;
array.v = push_array(arena, D_LineList, array.count);
di_key_list_push(arena, &array.dbgi_keys, &dbgi_key);
di2_key_list_push(arena, &array.dbgi_keys, dbgi_key);
}
Temp scratch = scratch_begin(&arena, 1);
U64 *lines_num_voffs = push_array(scratch.arena, U64, array.count);
DI_Scope *scope = di_scope_open();
Access *access = access_open();
String8List overrides = rd_possible_overrides_from_file_path(scratch.arena, file_path);
for(String8Node *override_n = overrides.first;
override_n != 0;
@@ -843,7 +759,7 @@ d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key,
String8 file_path_normalized = lower_from_str8(scratch.arena, path_normalized_from_string(scratch.arena, file_path));
// rjf: binary -> rdi
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
// rjf: file_path_normalized * rdi -> src_id
B32 good_src_id = 0;
@@ -911,7 +827,7 @@ d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key,
}
}
}
di_scope_close(scope);
access_close(access);
scratch_end(scratch);
return array;
}
@@ -926,8 +842,7 @@ d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64
}
Temp scratch = scratch_begin(&arena, 1);
U64 *lines_num_voffs = push_array(scratch.arena, U64, array.count);
DI_Scope *scope = di_scope_open();
DI_KeyList dbgi_keys = d_push_active_dbgi_key_list(scratch.arena);
DI2_KeyArray dbgi_keys = di2_push_all_loaded_keys(scratch.arena);
String8List overrides = rd_possible_overrides_from_file_path(scratch.arena, file_path);
for(String8Node *override_n = overrides.first;
override_n != 0;
@@ -935,13 +850,13 @@ d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64
{
String8 file_path = override_n->string;
String8 file_path_normalized = lower_from_str8(scratch.arena, file_path);
for(DI_KeyNode *dbgi_key_n = dbgi_keys.first;
dbgi_key_n != 0;
dbgi_key_n = dbgi_key_n->next)
for EachIndex(idx, dbgi_keys.count)
{
Access *access = access_open();
// rjf: binary -> rdi
DI_Key key = dbgi_key_n->v;
RDI_Parsed *rdi = di_rdi_from_key(scope, &key, 1, 0);
DI2_Key key = dbgi_keys.v[idx];
RDI_Parsed *rdi = di2_rdi_from_key(access, key, 1, 0);
// rjf: file_path_normalized * rdi -> src_id
B32 good_src_id = 0;
@@ -1012,17 +927,18 @@ d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64
// rjf: good src id -> push to relevant dbgi keys
if(good_src_id)
{
di_key_list_push(arena, &array.dbgi_keys, &key);
di2_key_list_push(arena, &array.dbgi_keys, key);
}
access_close(access);
}
}
di_scope_close(scope);
scratch_end(scratch);
return array;
}
internal D_LineList
d_lines_from_dbgi_key_file_path_line_num(Arena *arena, DI_Key dbgi_key, String8 file_path, S64 line_num)
d_lines_from_dbgi_key_file_path_line_num(Arena *arena, DI2_Key dbgi_key, String8 file_path, S64 line_num)
{
D_LineListArray array = d_lines_array_from_dbgi_key_file_path_line_range(arena, dbgi_key, file_path, r1s64(line_num, line_num+1));
D_LineList list = {0};
@@ -1175,16 +1091,16 @@ d_ctrl_targets_running(void)
//- rjf: active entity based queries
internal DI_KeyList
internal DI2_KeyList
d_push_active_dbgi_key_list(Arena *arena)
{
DI_KeyList dbgis = {0};
DI2_KeyList dbgis = {0};
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
for EachIndex(idx, modules.count)
{
CTRL_Entity *module = modules.v[idx];
DI_Key key = ctrl_dbgi_key_from_module(module);
di_key_list_push(arena, &dbgis, &key);
DI2_Key key = ctrl_dbgi_key_from_module(module);
di2_key_list_push(arena, &dbgis, key);
}
return dbgis;
}
@@ -1271,7 +1187,7 @@ d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 ro
}
internal E_String2NumMap *
d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
d_query_cached_locals_map_from_dbgi_key_voff(DI2_Key dbgi_key, U64 voff)
{
ProfBeginFunction();
E_String2NumMap *map = &e_string2num_map_nil;
@@ -1287,13 +1203,13 @@ d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
{
break;
}
U64 hash = di_hash_from_key(dbgi_key);
U64 hash = u64_hash_from_str8(str8_struct(&dbgi_key));
U64 slot_idx = hash % cache->table_size;
D_RunLocalsCacheSlot *slot = &cache->table[slot_idx];
D_RunLocalsCacheNode *node = 0;
for(D_RunLocalsCacheNode *n = slot->first; n != 0; n = n->hash_next)
{
if(di_key_match(&n->dbgi_key, dbgi_key) && n->voff == voff)
if(di2_key_match(n->dbgi_key, dbgi_key) && n->voff == voff)
{
node = n;
break;
@@ -1301,18 +1217,18 @@ d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
}
if(node == 0)
{
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 1, 0);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, 0);
E_String2NumMap *map = e_push_locals_map_from_rdi_voff(cache->arena, rdi, voff);
if(map->slots_count != 0)
{
node = push_array(cache->arena, D_RunLocalsCacheNode, 1);
node->dbgi_key = di_key_copy(cache->arena, dbgi_key);
node->dbgi_key = dbgi_key;
node->voff = voff;
node->locals_map = map;
SLLQueuePush_N(slot->first, slot->last, node, hash_next);
}
di_scope_close(scope);
access_close(access);
}
if(node != 0 && node->locals_map->slots_count != 0)
{
@@ -1325,7 +1241,7 @@ d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
}
internal E_String2NumMap *
d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
d_query_cached_member_map_from_dbgi_key_voff(DI2_Key dbgi_key, U64 voff)
{
ProfBeginFunction();
E_String2NumMap *map = &e_string2num_map_nil;
@@ -1341,13 +1257,13 @@ d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
{
break;
}
U64 hash = di_hash_from_key(dbgi_key);
U64 hash = u64_hash_from_str8(str8_struct(&dbgi_key));
U64 slot_idx = hash % cache->table_size;
D_RunLocalsCacheSlot *slot = &cache->table[slot_idx];
D_RunLocalsCacheNode *node = 0;
for(D_RunLocalsCacheNode *n = slot->first; n != 0; n = n->hash_next)
{
if(di_key_match(&n->dbgi_key, dbgi_key) && n->voff == voff)
if(di2_key_match(n->dbgi_key, dbgi_key) && n->voff == voff)
{
node = n;
break;
@@ -1355,18 +1271,18 @@ d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
}
if(node == 0)
{
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 1, 0);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, 0);
E_String2NumMap *map = e_push_member_map_from_rdi_voff(cache->arena, rdi, voff);
if(map->slots_count != 0)
{
node = push_array(cache->arena, D_RunLocalsCacheNode, 1);
node->dbgi_key = di_key_copy(cache->arena, dbgi_key);
node->dbgi_key = dbgi_key;
node->voff = voff;
node->locals_map = map;
SLLQueuePush_N(slot->first, slot->last, node, hash_next);
}
di_scope_close(scope);
access_close(access);
}
if(node != 0 && node->locals_map->slots_count != 0)
{
+9 -12
View File
@@ -126,7 +126,7 @@ struct D_Line
String8 file_path;
TxtPt pt;
Rng1U64 voff_range;
DI_Key dbgi_key;
DI2_Key dbgi_key;
};
typedef struct D_LineNode D_LineNode;
@@ -149,7 +149,7 @@ struct D_LineListArray
{
D_LineList *v;
U64 count;
DI_KeyList dbgi_keys;
DI2_KeyList dbgi_keys;
};
////////////////////////////////
@@ -248,7 +248,7 @@ typedef struct D_RunLocalsCacheNode D_RunLocalsCacheNode;
struct D_RunLocalsCacheNode
{
D_RunLocalsCacheNode *hash_next;
DI_Key dbgi_key;
DI2_Key dbgi_key;
U64 voff;
E_String2NumMap *locals_map;
};
@@ -365,18 +365,15 @@ internal CTRL_TrapList d_trap_net_from_thread__step_into_line(Arena *arena, CTRL
////////////////////////////////
//~ rjf: Debug Info Lookups
//- rjf: symbol -> voff lookups
internal U64 d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name);
//- rjf: voff -> line info
internal D_LineList d_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff);
internal D_LineList d_lines_from_dbgi_key_voff(Arena *arena, DI2_Key dbgi_key, U64 voff);
//- rjf: file:line -> line info
// TODO(rjf): this depends on file path maps, needs to move
// TODO(rjf): need to clean this up & dedup
internal D_LineListArray d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI_Key dbgi_key, String8 file_path, Rng1S64 line_num_range);
internal D_LineListArray d_lines_array_from_dbgi_key_file_path_line_range(Arena *arena, DI2_Key dbgi_key, String8 file_path, Rng1S64 line_num_range);
internal D_LineListArray d_lines_array_from_file_path_line_range(Arena *arena, String8 file_path, Rng1S64 line_num_range);
internal D_LineList d_lines_from_dbgi_key_file_path_line_num(Arena *arena, DI_Key dbgi_key, String8 file_path, S64 line_num);
internal D_LineList d_lines_from_dbgi_key_file_path_line_num(Arena *arena, DI2_Key dbgi_key, String8 file_path, S64 line_num);
internal D_LineList d_lines_from_file_path_line_num(Arena *arena, String8 file_path, S64 line_num);
////////////////////////////////
@@ -402,14 +399,14 @@ internal U64 d_ctrl_last_run_frame_idx(void);
internal B32 d_ctrl_targets_running(void);
//- rjf: active entity based queries
internal DI_KeyList d_push_active_dbgi_key_list(Arena *arena);
internal DI2_KeyList d_push_active_dbgi_key_list(Arena *arena);
//- rjf: per-run caches
internal U64 d_query_cached_rip_from_thread(CTRL_Entity *thread);
internal U64 d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count);
internal U64 d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr);
internal E_String2NumMap *d_query_cached_locals_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff);
internal E_String2NumMap *d_query_cached_member_map_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff);
internal E_String2NumMap *d_query_cached_locals_map_from_dbgi_key_voff(DI2_Key dbgi_key, U64 voff);
internal E_String2NumMap *d_query_cached_member_map_from_dbgi_key_voff(DI2_Key dbgi_key, U64 voff);
//- rjf: top-level command dispatch
internal void d_push_cmd(D_CmdKind kind, D_CmdParams *params);
+62 -7
View File
@@ -18,6 +18,30 @@ di2_key_match(DI2_Key a, DI2_Key b)
return result;
}
internal void
di2_key_list_push(Arena *arena, DI2_KeyList *list, DI2_Key key)
{
DI2_KeyNode *n = push_array(arena, DI2_KeyNode, 1);
n->v = key;
SLLQueuePush(list->first, list->last, n);
list->count += 1;
}
internal DI2_KeyArray
di2_key_array_from_list(Arena *arena, DI2_KeyList *list)
{
DI2_KeyArray array = {0};
array.count = list->count;
array.v = push_array(arena, DI2_Key, array.count);
U64 idx = 0;
for EachNode(n, DI2_KeyNode, list->first)
{
array.v[idx] = n->v;
idx += 1;
}
return array;
}
////////////////////////////////
//~ rjf: Main Layer Initialization
@@ -269,6 +293,7 @@ di2_open(DI2_Key key)
batch->count += 1;
}
cond_var_broadcast(async_tick_start_cond_var);
ins_atomic_u32_eval_assign(&async_loop_again, 1);
}
}
@@ -327,7 +352,10 @@ di2_close(DI2_Key key)
//- rjf: release node's resources if needed
if(node_released)
{
arena_release(arena);
if(arena != 0)
{
arena_release(arena);
}
os_file_map_view_close(file_map, file_base, r1u64(0, file_props.size));
os_file_map_close(file_map);
os_file_close(file);
@@ -398,7 +426,7 @@ di2_rdi_from_key(Access *access, DI2_Key key, B32 high_priority, U64 endt_us)
B32 grabbed = 0;
for(DI2_Node *n = slot->first; n != 0; n = n->next)
{
if(di2_key_match(n->key, key))
if(di2_key_match(n->key, key) && ins_atomic_u64_eval(&n->refcount) > 0)
{
found = 1;
if(high_priority && ins_atomic_u64_eval_cond_assign(&n->batch_request_counts[0], 1, 0) == 0)
@@ -427,6 +455,7 @@ di2_rdi_from_key(Access *access, DI2_Key key, B32 high_priority, U64 endt_us)
batch->count += 1;
}
cond_var_broadcast(async_tick_start_cond_var);
ins_atomic_u32_eval_assign(&async_loop_again, 1);
}
// rjf: found current results, or out-of-time? abort
@@ -695,6 +724,14 @@ di2_async_tick(void)
t->status = DI2_LoadTaskStatus_Done;
}
//- rjf: if the RDI for this task *is* stale, but the O.G. path is actually RDI,
// then we can't actually re-convert to produce a non-stale RDI. in this case, just
// mark as done.
if(rdi_is_stale && og_is_rdi)
{
t->status = DI2_LoadTaskStatus_Done;
}
//- rjf: if task is done, retire & recycle task; gather path to load
if(t->status == DI2_LoadTaskStatus_Done)
{
@@ -853,6 +890,7 @@ di2_conversion_completion_signal_receiver_thread_entry_point(void *p)
if(semaphore_take(di2_shared->conversion_completion_signal_semaphore, max_U64))
{
cond_var_broadcast(async_tick_start_cond_var);
ins_atomic_u32_eval_assign(&async_loop_again, 1);
}
}
}
@@ -1291,7 +1329,12 @@ di2_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
DI2_KeyArray dbgi_keys = di2_push_all_loaded_keys(scratch.arena);
//- rjf: wide search across all debug infos
DI2_Match match = {0};
DI2_Match *lane_matches = 0;
if(lane_idx() == 0)
{
lane_matches = push_array(scratch.arena, DI2_Match, lane_count());
}
lane_sync_u64(&lane_matches, 0);
{
read_only local_persist RDI_NameMapKind name_map_kinds[] =
{
@@ -1326,15 +1369,27 @@ di2_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
U32 *run = rdi_matches_from_map_node(rdi, map_node, &num);
if(num != 0)
{
match.key = dbgi_key;
match.section_kind = name_map_section_kinds[name_map_kind_idx];
match.idx = run[num-1];
lane_matches[lane_idx()].key = dbgi_key;
lane_matches[lane_idx()].section_kind = name_map_section_kinds[name_map_kind_idx];
lane_matches[lane_idx()].idx = run[num-1];
}
}
}
access_close(access);
}
}
lane_sync();
//- rjf: pick match
DI2_Match match = {0};
for EachIndex(idx, lane_count())
{
if(lane_matches[idx].idx != 0)
{
match = lane_matches[idx];
break;
}
}
//- rjf: package as artifact
AC_Artifact artifact = {0};
@@ -1362,7 +1417,7 @@ di2_match_from_string(String8 string, U64 index, U64 endt_us)
str8_list_push(scratch.arena, &key_parts, str8_struct(&string.size));
str8_list_push(scratch.arena, &key_parts, string);
String8 key = str8_list_join(scratch.arena, &key_parts, 0);
AC_Artifact artifact = ac_artifact_from_key(access, key, di2_match_artifact_create, 0, endt_us, .flags = AC_Flag_Wide);
AC_Artifact artifact = ac_artifact_from_key(access, key, di2_match_artifact_create, 0, endt_us, .flags = AC_Flag_Wide, .gen = di2_load_gen());
result.key.u64[0] = artifact.u64[0];
result.key.u64[1] = artifact.u64[1];
result.section_kind = artifact.u64[2];
+2
View File
@@ -247,6 +247,8 @@ global DI2_Shared *di2_shared = 0;
internal DI2_Key di2_key_zero(void);
internal B32 di2_key_match(DI2_Key a, DI2_Key b);
internal void di2_key_list_push(Arena *arena, DI2_KeyList *list, DI2_Key key);
internal DI2_KeyArray di2_key_array_from_list(Arena *arena, DI2_KeyList *list);
////////////////////////////////
//~ rjf: Main Layer Initialization
+3 -7
View File
@@ -185,7 +185,7 @@ dasm_params_match(DASM_Params *a, DASM_Params *b)
a->style_flags == b->style_flags &&
a->syntax == b->syntax &&
a->base_vaddr == b->base_vaddr &&
di_key_match(&a->dbgi_key, &b->dbgi_key));
di2_key_match(a->dbgi_key, b->dbgi_key));
return result;
}
@@ -273,7 +273,6 @@ dasm_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
{
Temp scratch = scratch_begin(0, 0);
Access *access = access_open();
DI_Scope *di_scope = di_scope_open();
//- rjf: unpack key
U128 hash = {0};
@@ -281,15 +280,14 @@ dasm_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
U64 key_read_off = 0;
key_read_off += str8_deserial_read_struct(key, key_read_off, &hash);
key_read_off += str8_deserial_read_struct(key, key_read_off, &params);
params.dbgi_key.path.str = key.str + key_read_off;
String8 data = c_data_from_hash(access, hash);
//- rjf: get dbg info
B32 stale = 0;
RDI_Parsed *rdi = &rdi_parsed_nil;
if(params.dbgi_key.path.size != 0)
if(!di2_key_match(params.dbgi_key, di2_key_zero()))
{
rdi = di_rdi_from_key(di_scope, &params.dbgi_key, 1, 0);
rdi = di2_rdi_from_key(access, params.dbgi_key, 0, 0);
stale = (stale || (rdi == &rdi_parsed_nil));
}
@@ -483,7 +481,6 @@ dasm_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
artifact->data_hash = hash;
}
di_scope_close(di_scope);
access_close(access);
scratch_end(scratch);
}
@@ -514,7 +511,6 @@ dasm_info_from_hash_params(Access *access, U128 hash, DASM_Params *params)
String8List key_parts = {0};
str8_list_push(scratch.arena, &key_parts, str8_struct(&hash));
str8_list_push(scratch.arena, &key_parts, str8_struct(params));
str8_list_push(scratch.arena, &key_parts, params->dbgi_key.path);
String8 key = str8_list_join(scratch.arena, &key_parts, 0);
// rjf: get info
+1 -1
View File
@@ -97,7 +97,7 @@ struct DASM_Params
DASM_StyleFlags style_flags;
DASM_Syntax syntax;
U64 base_vaddr;
DI_Key dbgi_key;
DI2_Key dbgi_key;
};
////////////////////////////////
-1
View File
@@ -763,7 +763,6 @@ struct E_BaseCtx
E_Module *modules;
U64 modules_count;
E_Module *primary_module;
DI_MatchStore *dbgi_match_store;
// rjf: space hooks
void *space_rw_user_data;
+32 -12
View File
@@ -1866,9 +1866,12 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
//- rjf: debug info matches
case E_IdentifierResolutionPath_DebugInfoMatch:
{
if(!string_mapped && e_base_ctx->dbgi_match_store != 0 && (qualifier.size == 0 || str8_match(qualifier, str8_lit("symbol"), 0)))
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("symbol"), 0)))
{
DI_Match match = di_match_from_name(e_base_ctx->dbgi_match_store, string, 0);
Access *access = access_open();
// rjf: find match
DI2_Match match = di2_match_from_string(string, 0, 0);
if(match.idx == 0)
{
String8List namespaceified_strings = {0};
@@ -1897,18 +1900,34 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
}
for(String8Node *n = namespaceified_strings.first; n != 0; n = n->next)
{
match = di_match_from_name(e_base_ctx->dbgi_match_store, n->string, 0);
match = di2_match_from_string(n->string, 0, 0);
if(match.idx != 0)
{
break;
}
}
}
if(match.idx != 0 && match.dbgi_idx < e_base_ctx->modules_count)
// rjf: match -> RDI
RDI_Parsed *rdi = di2_rdi_from_key(access, match.key, 0, 0);
// rjf: find module from dbgi key
U32 dbgi_idx = 0;
E_Module *module = &e_module_nil;
for EachIndex(idx, e_base_ctx->modules_count)
{
E_Module *module = &e_base_ctx->modules[match.dbgi_idx];
RDI_Parsed *rdi = module->rdi;
switch(match.section)
if(e_base_ctx->modules[idx].rdi == rdi)
{
module = &e_base_ctx->modules[idx];
dbgi_idx = (U32)idx;
break;
}
}
// rjf: form result
if(match.idx != 0 && module != &e_module_nil)
{
switch(match.section_kind)
{
default:{}break;
case RDI_SectionKind_GlobalVariables:
@@ -1919,7 +1938,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
E_OpList oplist = {0};
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(module->vaddr_range.min + global_var->voff));
string_mapped = 1;
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, dbgi_idx);
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
mapped_bytecode_mode = E_Mode_Offset;
mapped_bytecode_space = module->space;
@@ -1932,7 +1951,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
E_OpList oplist = {0};
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, e_value_u64(thread_var->tls_off));
string_mapped = 1;
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, dbgi_idx);
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
mapped_bytecode_mode = E_Mode_Offset;
mapped_bytecode_space = module->space;
@@ -1955,7 +1974,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
E_OpList oplist = {0};
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(value));
string_mapped = 1;
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, dbgi_idx);
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
mapped_bytecode_mode = E_Mode_Value;
mapped_bytecode_space = module->space;
@@ -1973,7 +1992,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
E_OpList oplist = {0};
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(module->vaddr_range.min + voff));
string_mapped = 1;
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, dbgi_idx);
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
mapped_bytecode_mode = E_Mode_Value;
mapped_bytecode_space = module->space;
@@ -1982,11 +2001,12 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
{
U32 type_idx = match.idx;
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
mapped_type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, dbgi_idx);
string_mapped = 1;
}break;
}
}
access_close(access);
}
}break;
+16 -7
View File
@@ -585,14 +585,23 @@ e_leaf_type_key_from_name(String8 name)
E_TypeKey key = e_leaf_builtin_type_key_from_name(name);
if(!e_type_key_match(e_type_key_zero(), key))
{
DI_Match match = di_match_from_name(e_base_ctx->dbgi_match_store, name, 0);
if(match.section == RDI_SectionKind_TypeNodes)
DI2_Match match = di2_match_from_string(name, 0, 0);
if(match.section_kind == RDI_SectionKind_TypeNodes)
{
E_Module *module = &e_base_ctx->modules[match.dbgi_idx];
RDI_Parsed *rdi = module->rdi;
U32 type_idx = match.idx;
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)match.dbgi_idx);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, match.key, 0, 0);
for EachIndex(idx, e_base_ctx->modules_count)
{
E_Module *module = &e_base_ctx->modules[idx];
if(module->rdi == rdi)
{
U32 type_idx = match.idx;
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)idx);
break;
}
}
access_close(access);
}
}
return key;
+1 -1
View File
@@ -520,7 +520,7 @@ Rng1U64 rd_reg_slot_range_table[47] =
{OffsetOf(RD_Regs, text_key), OffsetOf(RD_Regs, text_key) + sizeof(C_Key)},
{OffsetOf(RD_Regs, lang_kind), OffsetOf(RD_Regs, lang_kind) + sizeof(TXT_LangKind)},
{OffsetOf(RD_Regs, lines), OffsetOf(RD_Regs, lines) + sizeof(D_LineList)},
{OffsetOf(RD_Regs, dbgi_key), OffsetOf(RD_Regs, dbgi_key) + sizeof(DI_Key)},
{OffsetOf(RD_Regs, dbgi_key), OffsetOf(RD_Regs, dbgi_key) + sizeof(DI2_Key)},
{OffsetOf(RD_Regs, vaddr), OffsetOf(RD_Regs, vaddr) + sizeof(U64)},
{OffsetOf(RD_Regs, voff), OffsetOf(RD_Regs, voff) + sizeof(U64)},
{OffsetOf(RD_Regs, vaddr_range), OffsetOf(RD_Regs, vaddr_range) + sizeof(Rng1U64)},
+1 -1
View File
@@ -466,7 +466,7 @@ TxtPt mark;
C_Key text_key;
TXT_LangKind lang_kind;
D_LineList lines;
DI_Key dbgi_key;
DI2_Key dbgi_key;
U64 vaddr;
U64 voff;
Rng1U64 vaddr_range;
+2 -2
View File
@@ -733,10 +733,10 @@ RD_RegTable:
{String8 file_path FilePath }
{TxtPt cursor Cursor }
{TxtPt mark Mark }
{C_Key text_key TextKey }
{C_Key text_key TextKey }
{TXT_LangKind lang_kind LangKind }
{D_LineList lines Lines }
{DI_Key dbgi_key DbgiKey }
{DI2_Key dbgi_key DbgiKey }
{U64 vaddr Vaddr }
{U64 voff Voff }
{Rng1U64 vaddr_range VaddrRange }
+52 -74
View File
@@ -42,7 +42,6 @@ rd_regs_copy_contents(Arena *arena, RD_Regs *dst, RD_Regs *src)
dst->cfg_list = rd_cfg_id_list_copy(arena, &src->cfg_list);
dst->file_path = push_str8_copy(arena, src->file_path);
dst->lines = d_line_list_copy(arena, &src->lines);
dst->dbgi_key = di_key_copy(arena, &src->dbgi_key);
dst->expr = push_str8_copy(arena, src->expr);
dst->string = push_str8_copy(arena, src->string);
dst->cmd_name = push_str8_copy(arena, src->cmd_name);
@@ -3274,11 +3273,11 @@ rd_view_ui(Rng2F32 rect)
U64 vaddr = eval.value.u64;
CTRL_Entity *process = rd_ctrl_entity_from_eval_space(eval.space);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
{
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
String8 name = {0};
if(name.size == 0)
{
@@ -3294,7 +3293,7 @@ rd_view_ui(Rng2F32 rect)
{
rd_cmd(RD_CmdKind_CompleteQuery, .string = name);
}
di_scope_close(scope);
access_close(access);
}
}break;
case E_SpaceKind_File:
@@ -3361,11 +3360,11 @@ rd_view_ui(Rng2F32 rect)
U64 vaddr = eval.value.u64;
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
{
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
Access *access = access_open();
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 1, 0);
if(name.size == 0)
{
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff);
@@ -3376,7 +3375,7 @@ rd_view_ui(Rng2F32 rect)
RDI_GlobalVariable *gvar = rdi_global_variable_from_voff(rdi, voff);
name.str = rdi_string_from_idx(rdi, gvar->name_string_idx, &name.size);
}
di_scope_close(scope);
access_close(access);
}
}
if(name.size != 0)
@@ -5299,9 +5298,9 @@ rd_view_ui(Rng2F32 rect)
{
U64 vaddr = cell->eval.value.u64;
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, voff);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff);
String8 file_path = {0};
TxtPt pt = {0};
if(lines.first != 0)
@@ -6443,22 +6442,23 @@ rd_window_frame(void)
// rjf: debug info status
if(ctrl_entity->kind == CTRL_EntityKind_Module) UI_TagF("weak")
{
DI_Scope *di_scope = di_scope_open();
DI_Key dbgi_key = ctrl_dbgi_key_from_module(ctrl_entity);
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, 0);
Access *access = access_open();
CTRL_Entity *dbg_info_entity = ctrl_entity_child_from_kind(ctrl_entity, CTRL_EntityKind_DebugInfoPath);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(ctrl_entity);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi->raw_data_size != 0)
{
ui_labelf("Symbols successfully loaded from %S", dbgi_key.path);
ui_labelf("Symbols successfully loaded from %S", dbg_info_entity->string);
}
else if(dbgi_key.path.size != 0)
else if(dbg_info_entity->string.size != 0)
{
ui_labelf("Symbols not found at %S", dbgi_key.path);
ui_labelf("Symbols not found at %S", dbg_info_entity->string);
}
else if(dbgi_key.path.size == 0)
else if(dbg_info_entity->string.size == 0)
{
ui_labelf("Symbol information not found in module file");
}
di_scope_close(di_scope);
access_close(access);
}
// rjf: unwind
@@ -6611,11 +6611,6 @@ rd_window_frame(void)
ui_divider(ui_em(1.f, 1.f));
//- rjf: draw match store stats
ui_labelf("name match nodes: %I64u", rd_state->match_store->active_match_name_nodes_count);
ui_divider(ui_em(1.f, 1.f));
//- rjf: draw registers
ui_labelf("hover_reg_slot: %i", rd_state->hover_regs_slot);
struct
@@ -10267,8 +10262,6 @@ rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8
RD_CodeColorSlot color = RD_CodeColorSlot_CodeDefault;
if(kind == TXT_TokenKind_Identifier || kind == TXT_TokenKind_Keyword)
{
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
B32 mapped = 0;
// rjf: try to map as local
@@ -10318,7 +10311,8 @@ rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8
// rjf: try to map using asynchronous matching system
if(!mapped && kind == TXT_TokenKind_Identifier)
{
RDI_SectionKind section_kind = di_match_from_name(rd_state->match_store, string, 0).section;
DI2_Match match = di2_match_from_string(string, 0, 0);
RDI_SectionKind section_kind = match.section_kind;
mapped = 1;
switch(section_kind)
{
@@ -10885,7 +10879,6 @@ rd_init(CmdLine *cmdln)
}
rd_state->num_frames_requested = 2;
rd_state->seconds_until_autosave = 0.5f;
rd_state->match_store = di_match_store_alloc();
rd_state->eval_cache = e_cache_alloc();
for(U64 idx = 0; idx < ArrayCount(rd_state->cmds_arenas); idx += 1)
{
@@ -11406,6 +11399,7 @@ rd_frame(void)
//////////////////////////////
//- rjf: sync with di parsers
//
#if 0 // TODO(rjf): @dbgi2
ProfScope("sync with di parsers")
{
DI_EventList events = di_p2u_pop_events(scratch.arena, 0);
@@ -11436,6 +11430,7 @@ rd_frame(void)
}
}
}
#endif
//////////////////////////////
//- rjf: animate all views
@@ -11496,9 +11491,7 @@ rd_frame(void)
//- rjf: push frame scopes
//
Access *frame_access_restore = rd_state->frame_access;
DI_Scope *frame_di_scope_restore = rd_state->frame_di_scope;
rd_state->frame_access = access_open();
rd_state->frame_di_scope = di_scope_open();
rd_state->got_frame_call_stack_tree = 0;
//////////////////////////////
@@ -11854,15 +11847,6 @@ rd_frame(void)
}
}
//////////////////////////////
//- rjf: set name matching parameters; begin matching
//
{
DI_KeyList keys_list = d_push_active_dbgi_key_list(scratch.arena);
DI_KeyArray keys = di_key_array_from_list(scratch.arena, &keys_list);
di_match_store_begin(rd_state->match_store, keys);
}
//////////////////////////////
//- rjf: loop - consume events in core, tick engine, and repeat
//
@@ -11888,15 +11872,15 @@ rd_frame(void)
E_Module *eval_modules_primary = &eval_modules[0];
eval_modules_primary->rdi = &rdi_parsed_nil;
eval_modules_primary->vaddr_range = r1u64(0, max_U64);
DI_Key primary_dbgi_key = {0};
DI2_Key primary_dbgi_key = {0};
ProfScope("produce all eval modules")
{
for EachIndex(eval_module_idx, all_modules.count)
{
CTRL_Entity *m = all_modules.v[eval_module_idx];
DI_Key dbgi_key = ctrl_dbgi_key_from_module(m);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(m);
eval_modules[eval_module_idx].arch = m->arch;
eval_modules[eval_module_idx].rdi = di_rdi_from_key(rd_state->frame_di_scope, &dbgi_key, 1, 0);
eval_modules[eval_module_idx].rdi = di2_rdi_from_key(rd_state->frame_access, dbgi_key, 0, 0);
eval_modules[eval_module_idx].vaddr_range = m->vaddr_range;
eval_modules[eval_module_idx].space = rd_eval_space_from_ctrl_entity(ctrl_entity_ancestor_from_kind(m, CTRL_EntityKind_Process), RD_EvalSpaceKind_CtrlEntity);
if(module == m)
@@ -11931,7 +11915,6 @@ rd_frame(void)
ctx->modules = eval_modules;
ctx->modules_count = eval_modules_count;
ctx->primary_module = eval_modules_primary;
ctx->dbgi_match_store = rd_state->match_store;
//- rjf: fill space hooks
ctx->space_gen = rd_eval_space_gen;
@@ -12702,8 +12685,8 @@ rd_frame(void)
E_IRCtx *ctx = ir_ctx;
ctx->regs_map = ctrl_string2reg_from_arch(eval_base_ctx->primary_module->arch);
ctx->reg_alias_map = ctrl_string2alias_from_arch(eval_base_ctx->primary_module->arch);
ctx->locals_map = d_query_cached_locals_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
ctx->locals_map = d_query_cached_locals_map_from_dbgi_key_voff(primary_dbgi_key, rip_voff);
ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(primary_dbgi_key, rip_voff);
ctx->macro_map = macro_map;
ctx->auto_hook_map = auto_hook_map;
}
@@ -14405,7 +14388,7 @@ rd_frame(void)
U64 vaddr = 0;
for(D_LineNode *n = rd_regs()->lines.first; n != 0; n = n->next)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, &n->v.dbgi_key);
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &ctrl_entity_nil)
{
@@ -14686,7 +14669,7 @@ rd_frame(void)
//- rjf: thread finding
case RD_CmdKind_FindThread:
{
DI_Scope *scope = di_scope_open();
Access *access = access_open();
//- rjf: unpack thread info
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
@@ -14695,10 +14678,10 @@ rd_frame(void)
U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_index);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff);
D_Line line = {0};
{
U64 idx = 0;
@@ -14712,7 +14695,7 @@ rd_frame(void)
}
}
B32 missing_rip = (rip_vaddr == 0);
B32 dbgi_missing = (dbgi_key.min_timestamp == 0 || dbgi_key.path.size == 0);
B32 dbgi_missing = (di2_key_match(di2_key_zero(), dbgi_key));
B32 dbgi_pending = !dbgi_missing && rdi == &rdi_parsed_nil;
B32 has_line_info = (line.voff_range.max != 0);
B32 has_module = (module != &ctrl_entity_nil);
@@ -14749,7 +14732,7 @@ rd_frame(void)
{
find_thread_retry = thread->handle;
}
di_scope_close(scope);
access_close(access);
}break;
case RD_CmdKind_FindSelectedThread:
{
@@ -14776,20 +14759,21 @@ rd_frame(void)
// rjf: try to resolve name as a symbol
U64 voff = 0;
DI_Key voff_dbgi_key = {0};
DI2_Key voff_dbgi_key = {0};
if(!name_resolved)
{
DI_KeyList keys = d_push_active_dbgi_key_list(scratch.arena);
for(DI_KeyNode *n = keys.first; n != 0; n = n->next)
DI2_Match match = di2_match_from_string(name, 0, 0);
if(match.section_kind == RDI_SectionKind_Procedures)
{
U64 binary_voff = d_voff_from_dbgi_key_symbol_name(&n->v, name);
if(binary_voff != 0)
Access *access = access_open();
{
voff = binary_voff;
voff_dbgi_key = n->v;
name_resolved = 1;
break;
RDI_Parsed *rdi = di2_rdi_from_key(access, match.key, 0, 0);
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, match.idx);
voff = rdi_first_voff_from_procedure(rdi, procedure);
voff_dbgi_key = match.key;
}
access_close(access);
}
}
@@ -14848,20 +14832,17 @@ rd_frame(void)
// rjf: name resolved to voff * dbg info
if(name_resolved && voff != 0)
{
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &voff_dbgi_key, voff);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, voff_dbgi_key, voff);
if(lines.first != 0)
{
CTRL_Entity *process = &ctrl_entity_nil;
U64 vaddr = 0;
if(voff_dbgi_key.path.size != 0)
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, voff_dbgi_key);
CTRL_Entity *module = ctrl_entity_list_first(&modules);
process = ctrl_entity_ancestor_from_kind(module, CTRL_EntityKind_Process);
if(process != &ctrl_entity_nil)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, &voff_dbgi_key);
CTRL_Entity *module = ctrl_entity_list_first(&modules);
process = ctrl_entity_ancestor_from_kind(module, CTRL_EntityKind_Process);
if(process != &ctrl_entity_nil)
{
vaddr = module->vaddr_range.min + lines.first->v.voff_range.min;
}
vaddr = module->vaddr_range.min + lines.first->v.voff_range.min;
}
rd_cmd(RD_CmdKind_FindCodeLocation,
.file_path = lines.first->v.file_path,
@@ -14951,7 +14932,7 @@ rd_frame(void)
D_LineList lines = d_lines_from_file_path_line_num(scratch.arena, file_path, point.line);
for(D_LineNode *n = lines.first; n != 0; n = n->next)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, &n->v.dbgi_key);
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
break;
@@ -16126,7 +16107,7 @@ rd_frame(void)
D_LineList *lines = &rd_regs()->lines;
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, &n->v.dbgi_key);
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &ctrl_entity_nil)
{
@@ -17015,7 +16996,6 @@ rd_frame(void)
U64 vaddr = evt->vaddr;
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
U64 test_cached_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
@@ -17325,9 +17305,7 @@ rd_frame(void)
// since eviction threads may be waiting to get rid of stuff.
//
access_close(rd_state->frame_access);
di_scope_close(rd_state->frame_di_scope);
rd_state->frame_access = frame_access_restore;
rd_state->frame_di_scope = frame_di_scope_restore;
//////////////////////////////
//- rjf: submit rendering to all windows
-4
View File
@@ -600,13 +600,9 @@ struct RD_State
// rjf: frame parameters
F32 frame_dt;
Access *frame_access;
DI_Scope *frame_di_scope;
CTRL_CallStackTree frame_call_stack_tree;
B32 got_frame_call_stack_tree;
// rjf: dbgi match store
DI_MatchStore *match_store;
// rjf: evaluation cache
E_Cache *eval_cache;
+37 -55
View File
@@ -1634,9 +1634,7 @@ typedef struct RD_DebugInfoTableLookupAccel RD_DebugInfoTableLookupAccel;
struct RD_DebugInfoTableLookupAccel
{
RDI_SectionKind section;
U64 rdis_count;
RDI_Parsed **rdis;
DI_SearchItemArray items;
DI2_SearchItemArray items;
};
E_TYPE_EXPAND_INFO_FUNCTION_DEF(debug_info_table)
@@ -1663,28 +1661,10 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(debug_info_table)
{
U64 endt_us = rd_state->frame_eval_memread_endt_us;
//- rjf: unpack context
DI_KeyList dbgi_keys_list = d_push_active_dbgi_key_list(scratch.arena);
DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list);
U64 rdis_count = dbgi_keys.count;
RDI_Parsed **rdis = push_array(arena, RDI_Parsed *, rdis_count);
for(U64 idx = 0; idx < rdis_count; idx += 1)
{
rdis[idx] = di_rdi_from_key(rd_state->frame_di_scope, &dbgi_keys.v[idx], 1, endt_us);
}
//- rjf: query all filtered items from dbgi searching system
U128 fuzzy_search_key = {d_hash_from_string(str8_struct(&rd_regs()->view)), (U64)section};
B32 items_stale = 0;
DI_SearchParams params = {section, dbgi_keys};
accel->section = section;
accel->rdis_count = rdis_count;
accel->rdis = rdis;
accel->items = di_search_items_from_key_params_query(rd_state->frame_di_scope, fuzzy_search_key, &params, filter, endt_us, &items_stale);
if(items_stale)
{
rd_request_frame();
}
accel->items = di2_search_item_array_from_target_query(rd_state->frame_access, section, filter, endt_us);
}
E_TypeExpandInfo info = {accel, accel->items.count};
scratch_end(scratch);
@@ -1698,18 +1678,11 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(debug_info_table)
U64 needed_row_count = dim_1u64(idx_range);
for EachIndex(idx, needed_row_count)
{
Access *access = access_open();
// rjf: unpack row
DI_SearchItem *item = &accel->items.v[idx_range.min + idx];
// rjf: skip bad elements
if(item->dbgi_idx >= accel->rdis_count)
{
continue;
}
// rjf: unpack row info
RDI_Parsed *rdi = accel->rdis[item->dbgi_idx];
E_Module *module = &e_base_ctx->modules[item->dbgi_idx];
DI2_SearchItem *item = &accel->items.v[idx_range.min + idx];
RDI_Parsed *rdi = di2_rdi_from_key(access, item->key, 0, 0);
// rjf: get item's string
String8 item_string = {0};
@@ -1721,51 +1694,43 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(debug_info_table)
default:{}break;
case RDI_SectionKind_Procedures:
{
RDI_Procedure *procedure = rdi_element_from_name_idx(module->rdi, Procedures, element_idx);
RDI_Scope *scope = rdi_element_from_name_idx(module->rdi, Scopes, procedure->root_scope_idx);
U64 voff = *rdi_element_from_name_idx(module->rdi, ScopeVOffData, scope->voff_range_first);
E_OpList oplist = {0};
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU64, e_value_u64(module->vaddr_range.min + voff));
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
U32 type_idx = procedure->type_idx;
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
E_TypeKey type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)(module - e_base_ctx->modules));
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, element_idx);
String8 symbol_name = {0};
symbol_name.str = rdi_string_from_idx(module->rdi, procedure->name_string_idx, &symbol_name.size);
symbol_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &symbol_name.size);
item_string = symbol_name;
}break;
case RDI_SectionKind_GlobalVariables:
{
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(module->rdi, GlobalVariables, element_idx);
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(rdi, GlobalVariables, element_idx);
String8 symbol_name = {0};
symbol_name.str = rdi_string_from_idx(module->rdi, gvar->name_string_idx, &symbol_name.size);
symbol_name.str = rdi_string_from_idx(rdi, gvar->name_string_idx, &symbol_name.size);
item_string = symbol_name;
}break;
case RDI_SectionKind_ThreadVariables:
{
RDI_ThreadVariable *tvar = rdi_element_from_name_idx(module->rdi, ThreadVariables, element_idx);
RDI_ThreadVariable *tvar = rdi_element_from_name_idx(rdi, ThreadVariables, element_idx);
String8 symbol_name = {0};
symbol_name.str = rdi_string_from_idx(module->rdi, tvar->name_string_idx, &symbol_name.size);
symbol_name.str = rdi_string_from_idx(rdi, tvar->name_string_idx, &symbol_name.size);
item_string = symbol_name;
}break;
case RDI_SectionKind_Constants:
{
RDI_Constant *cnst = rdi_element_from_name_idx(module->rdi, Constants, element_idx);
RDI_Constant *cnst = rdi_element_from_name_idx(rdi, Constants, element_idx);
String8 symbol_name = {0};
symbol_name.str = rdi_string_from_idx(module->rdi, cnst->name_string_idx, &symbol_name.size);
symbol_name.str = rdi_string_from_idx(rdi, cnst->name_string_idx, &symbol_name.size);
item_string = symbol_name;
}break;
case RDI_SectionKind_UDTs:
{
RDI_UDT *udt = rdi_element_from_name_idx(module->rdi, UDTs, element_idx);
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, udt->self_type_idx);
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, element_idx);
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, udt->self_type_idx);
String8 name = {0};
name.str = rdi_string_from_idx(module->rdi, type_node->user_defined.name_string_idx, &name.size);
name.str = rdi_string_from_idx(rdi, type_node->user_defined.name_string_idx, &name.size);
item_string = name;
}break;
case RDI_SectionKind_SourceFiles:
{
RDI_SourceFile *sf = rdi_element_from_name_idx(module->rdi, SourceFiles, element_idx);
RDI_SourceFile *sf = rdi_element_from_name_idx(rdi, SourceFiles, element_idx);
String8List path_parts = {0};
for(RDI_FilePathNode *fpn = rdi_element_from_name_idx(rdi, FilePathNodes, sf->file_path_node_idx);
fpn != rdi_element_from_name_idx(rdi, FilePathNodes, 0);
@@ -1815,6 +1780,8 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(debug_info_table)
// rjf: fill
evals_out[idx] = item_eval;
temp_end(scratch);
access_close(access);
}
scratch_end(scratch);
}
@@ -1825,7 +1792,10 @@ E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(debug_info_table)
U64 id = 0;
if(0 < num && num <= accel->items.count)
{
id = accel->items.v[num-1].idx+1;
U64 hash = 5381;
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[num-1].key.u64[0]));
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[num-1].key.u64[1]));
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[num-1].idx));
}
return id;
}
@@ -1833,6 +1803,18 @@ E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(debug_info_table)
E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(debug_info_table)
{
RD_DebugInfoTableLookupAccel *accel = (RD_DebugInfoTableLookupAccel *)user_data;
U64 num = di_search_item_num_from_array_element_idx__linear_search(&accel->items, id-1);
U64 num = 0;
for EachIndex(idx, accel->items.count)
{
U64 hash = 5381;
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[idx].key.u64[0]));
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[idx].key.u64[1]));
hash = u64_hash_from_seed_str8(hash, str8_struct(&accel->items.v[idx].idx));
if(hash == id)
{
num = idx+1;
break;
}
}
return num;
}
+2 -2
View File
@@ -248,7 +248,7 @@
#include "radbin/radbin.h"
#include "regs/regs.h"
#include "regs/rdi/regs_rdi.h"
#include "dbg_info/dbg_info.h"
// #include "dbg_info/dbg_info.h"
#include "dbg_info/dbg_info2.h"
#include "disasm/disasm.h"
#include "demon/demon_inc.h"
@@ -296,7 +296,7 @@
#include "radbin/radbin.c"
#include "regs/regs.c"
#include "regs/rdi/regs_rdi.c"
#include "dbg_info/dbg_info.c"
// #include "dbg_info/dbg_info.c"
#include "dbg_info/dbg_info2.c"
#include "disasm/disasm.c"
#include "demon/demon_inc.c"
+31 -31
View File
@@ -20,7 +20,7 @@ rd_code_view_init(RD_CodeViewState *cv)
}
internal RD_CodeViewBuildResult
rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key)
rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI2_Key dasm_dbgi_key)
{
ProfBeginFunction();
Temp scratch = scratch_begin(&arena, 1);
@@ -289,8 +289,8 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count;
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, last_inst_on_unwound_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff);
for(D_LineNode *n = lines.first; n != 0; n = n->next)
{
if(visible_line_num_range.min <= n->v.pt.line && n->v.pt.line <= visible_line_num_range.max)
@@ -341,7 +341,7 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
{
String8 file_path = rd_regs()->file_path;
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
D_LineListArray lines_array = d_lines_array_from_dbgi_key_file_path_line_range(scratch.arena, dbgi_key, file_path, visible_line_num_range);
if(lines_array.count != 0)
{
@@ -423,21 +423,21 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
if(dasm_lines)
{
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, dasm_vaddr_range.min);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
for(S64 line_num = visible_line_num_range.min; line_num < visible_line_num_range.max; line_num += 1)
{
U64 vaddr = dasm_vaddr_range.min + dasm_line_array_code_off_from_idx(dasm_lines, line_num-1);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
U64 slice_idx = line_num-visible_line_num_range.min;
code_slice_params.line_vaddrs[slice_idx] = vaddr;
code_slice_params.line_infos[slice_idx] = d_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, voff);
code_slice_params.line_infos[slice_idx] = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff);
}
}
// rjf: add dasm dbgi key to relevant dbgis
if(dasm_lines != 0)
{
di_key_list_push(scratch.arena, &code_slice_params.relevant_dbgi_keys, &dasm_dbgi_key);
di2_key_list_push(scratch.arena, &code_slice_params.relevant_dbgi_keys, dasm_dbgi_key);
}
}
@@ -813,10 +813,9 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
//
RD_CodeViewBuildResult result = {0};
{
for(DI_KeyNode *n = code_slice_params.relevant_dbgi_keys.first; n != 0; n = n->next)
for(DI2_KeyNode *n = code_slice_params.relevant_dbgi_keys.first; n != 0; n = n->next)
{
DI_Key copy = di_key_copy(arena, &n->v);
di_key_list_push(arena, &result.dbgi_keys, &copy);
di2_key_list_push(arena, &result.dbgi_keys, n->v);
}
}
@@ -2148,7 +2147,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
//////////////////////////////
//- rjf: build code contents
//
DI_KeyList dbgi_keys = {0};
DI2_KeyList dbgi_keys = {0};
if(!file_is_missing)
{
RD_CodeViewBuildFlags flags = RD_CodeViewBuildFlag_All;
@@ -2156,7 +2155,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
{
flags &= ~RD_CodeViewBuildFlag_Margins;
}
RD_CodeViewBuildResult result = rd_code_view_build(scratch.arena, cv, flags, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero());
RD_CodeViewBuildResult result = rd_code_view_build(scratch.arena, cv, flags, code_area_rect, data, &info, 0, r1u64(0, 0), di2_key_zero());
dbgi_keys = result.dbgi_keys;
}
@@ -2166,7 +2165,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
if(rd_regs()->file_path.size != 0)
{
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
rd_regs()->lines = d_lines_from_dbgi_key_file_path_line_num(rd_frame_arena(), dbgi_key, rd_regs()->file_path, rd_regs()->cursor.line);
}
@@ -2179,15 +2178,18 @@ RD_VIEW_UI_FUNCTION_DEF(text)
U64 file_timestamp = os_properties_from_file_path(rd_regs()->file_path).modified;
if(file_timestamp != 0)
{
for(DI_KeyNode *n = dbgi_keys.first; n != 0; n = n->next)
for(DI2_KeyNode *n = dbgi_keys.first; n != 0; n = n->next)
{
DI_Key key = n->v;
DI2_Key key = n->v;
// TODO(rjf): @dbgi2
#if 0
if(key.min_timestamp < file_timestamp && key.min_timestamp != 0 && key.path.size != 0)
{
file_is_out_of_date = 1;
out_of_date_dbgi_name = str8_skip_last_slash(key.path);
break;
}
#endif
}
}
}
@@ -2356,7 +2358,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
Arch arch = rd_arch_from_eval(eval);
CTRL_Entity *space_entity = rd_ctrl_entity_from_eval_space(space);
CTRL_Entity *dasm_module = &ctrl_entity_nil;
DI_Key dbgi_key = {0};
DI2_Key dbgi_key = {0};
U64 base_vaddr = 0;
switch(space_entity->kind)
{
@@ -2455,7 +2457,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
rd_regs()->vaddr = range.min+off;
rd_regs()->vaddr_range = r1u64(range.min+off, range.min+off);
rd_regs()->voff_range = ctrl_voff_range_from_vaddr_range(dasm_module, rd_regs()->vaddr_range);
rd_regs()->lines = d_lines_from_dbgi_key_voff(rd_frame_arena(), &dbgi_key, rd_regs()->voff_range.min);
rd_regs()->lines = d_lines_from_dbgi_key_voff(rd_frame_arena(), dbgi_key, rd_regs()->voff_range.min);
}
//////////////////////////////
@@ -2952,16 +2954,16 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
last_stack_top = f_stack_top;
if(dim_1u64(frame_vaddr_range_in_viz) != 0)
{
DI_Scope *scope = di_scope_open();
Access *access = access_open();
U64 f_rip_vaddr = regs_rip_from_arch_block(selected_thread->arch, f->regs);
CTRL_Entity *module = ctrl_module_from_process_vaddr(selected_process, f_rip_vaddr);
U64 f_rip_voff = ctrl_voff_from_vaddr(module, f_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, f_rip_voff);
String8 procedure_name = {0};
procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size);
di_scope_close(scope);
access_close(access);
if(procedure_name.size != 0)
{
Annotation *annotation = push_array(scratch.arena, Annotation, 1);
@@ -3008,7 +3010,6 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
//- rjf: fill local variable annotations
if(e_space_match(rd_eval_space_from_ctrl_entity(selected_process, RD_EvalSpaceKind_CtrlEntity), eval.space))
{
DI_Scope *scope = di_scope_open();
Vec4F32 local_color = ui_color_from_name(str8_lit("code_local"));
Vec4F32 color_gen_table[] =
{
@@ -3047,7 +3048,6 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
}
}
}
di_scope_close(scope);
}
//- rjf: fill procedures annotations
@@ -3066,13 +3066,13 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
vaddr = next_vaddr)
{
next_vaddr = vaddr+1;
DI_Scope *scope = di_scope_open();
Access *access = access_open();
CTRL_Entity *module = ctrl_module_from_process_vaddr(eval_process, vaddr);
if(module != &ctrl_entity_nil)
{
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff);
RDI_Scope *root_scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
if(procedure->root_scope_idx != 0)
@@ -3103,7 +3103,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
}
}
}
di_scope_close(scope);
access_close(access);
}
}
@@ -3123,13 +3123,13 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
vaddr = next_vaddr)
{
next_vaddr = vaddr+1;
DI_Scope *scope = di_scope_open();
Access *access = access_open();
CTRL_Entity *module = ctrl_module_from_process_vaddr(eval_process, vaddr);
if(module != &ctrl_entity_nil)
{
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
RDI_GlobalVariable *gvar = rdi_global_variable_from_voff(rdi, voff);
if(gvar->voff != 0)
{
@@ -3159,7 +3159,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
}
}
}
di_scope_close(scope);
access_close(access);
}
}
+2 -2
View File
@@ -67,7 +67,7 @@ struct RD_CodeViewState
typedef struct RD_CodeViewBuildResult RD_CodeViewBuildResult;
struct RD_CodeViewBuildResult
{
DI_KeyList dbgi_keys;
DI2_KeyList dbgi_keys;
};
////////////////////////////////
@@ -199,7 +199,7 @@ struct RD_WatchViewState
//~ rjf: Code View Functions
internal void rd_code_view_init(RD_CodeViewState *cv);
internal RD_CodeViewBuildResult rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key);
internal RD_CodeViewBuildResult rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags flags, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_LineArray *dasm_lines, Rng1U64 dasm_vaddr_range, DI2_Key dasm_dbgi_key);
////////////////////////////////
//~ rjf: Watch View Functions
+15 -24
View File
@@ -548,7 +548,6 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e
Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol"));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
Access *access = access_open();
DI_Scope *di_scope = di_scope_open();
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process);
Arch arch = entity->arch;
B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread);
@@ -564,8 +563,8 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
String8 name = {0};
{
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, 0);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi != &rdi_parsed_nil)
{
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, rip_voff);
@@ -591,22 +590,21 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e
}
}
}
di_scope_close(di_scope);
access_close(access);
}
//- rjf: modules get debug info status extras
if(entity->kind == CTRL_EntityKind_Module && include_extras)
{
DI_Scope *di_scope = di_scope_open();
DI_Key dbgi_key = ctrl_dbgi_key_from_module(entity);
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 1, 0);
Access *access = access_open();
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(entity);
RDI_Parsed *rdi = di2_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi->raw_data_size == 0)
{
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_push_new(arena, &result, &params, str8_lit("(Symbols not found)"), .font = rd_font_from_slot(RD_FontSlot_Main), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Main), .size = extras_size, .color = secondary_color);
}
di_scope_close(di_scope);
access_close(access);
}
return result;
@@ -1419,7 +1417,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, thread_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color
@@ -1490,7 +1488,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
D_Line *line = 0;
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
if(di_key_match(&n->v.dbgi_key, &dbgi_key))
if(di2_key_match(n->v.dbgi_key, dbgi_key))
{
line = &n->v;
break;
@@ -1575,7 +1573,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, thread_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
DI2_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color
@@ -1644,7 +1642,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
D_Line *line = 0;
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
if(di_key_match(&n->v.dbgi_key, &dbgi_key))
if(di2_key_match(n->v.dbgi_key, dbgi_key))
{
line = &n->v;
break;
@@ -1867,19 +1865,14 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
// rjf: line info on this line -> adjust bg color to visualize
B32 has_line_info = 0;
{
U64 best_stamp = 0;
S64 line_info_line_num = 0;
F32 line_info_t = 0;
D_LineList *lines = &params->line_infos[line_idx];
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
if(n->v.dbgi_key.min_timestamp >= best_stamp)
{
has_line_info = (n->v.pt.line == line_num || params->line_vaddrs[line_idx] != 0);
line_info_line_num = n->v.pt.line;
best_stamp = n->v.dbgi_key.min_timestamp;
line_info_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "dbgi_alive_t_%S", n->v.dbgi_key.path), 1.f);
}
has_line_info = (has_line_info || n->v.pt.line == line_num || params->line_vaddrs[line_idx] != 0);
line_info_line_num = n->v.pt.line;
line_info_t = ui_anim(ui_key_from_stringf(ui_key_zero(), "dbgi_alive_t_%I64x_%I64x", n->v.dbgi_key.u64[0], n->v.dbgi_key.u64[1]), 1.f);
}
if(has_line_info)
{
@@ -2019,7 +2012,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
//
UI_Focus(UI_FocusKind_Off)
{
DI_Scope *scope = di_scope_open();
U64 line_idx = 0;
for(S64 line_num = params->line_num_range.min;
line_num < params->line_num_range.max;
@@ -2152,7 +2144,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
}
}
}
di_scope_close(scope);
}
//////////////////////////////
@@ -2275,7 +2266,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
D_LineList *lines = &params->line_infos[line_idx];
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, &n->v.dbgi_key);
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &ctrl_entity_nil)
{
@@ -2805,7 +2796,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
for(D_LineNode *n = lines->first; n != 0; n = n->next)
{
if((n->v.pt.line == line_num || params->line_vaddrs[line_idx] != 0) &&
((di_key_match(&n->v.dbgi_key, &hover_regs->dbgi_key) &&
((di2_key_match(n->v.dbgi_key, hover_regs->dbgi_key) &&
n->v.voff_range.min <= hover_voff_range.min && hover_voff_range.min < n->v.voff_range.max) ||
(params->line_vaddrs[line_idx] == hover_regs->vaddr_range.min && hover_regs->vaddr_range.min != 0)))
{
+1 -1
View File
@@ -104,7 +104,7 @@ struct RD_CodeSliceParams
RD_CfgList *line_pins;
U64 *line_vaddrs;
D_LineList *line_infos;
DI_KeyList relevant_dbgi_keys;
DI2_KeyList relevant_dbgi_keys;
TXT_TextInfo *text_info;
String8 text_data;