fix incorrectly referring to root entity for debug info if missing; fix thread register cache issues; fix new dbgi layer issues

This commit is contained in:
Ryan Fleury
2024-05-22 11:13:08 -07:00
parent b33559b081
commit 7a4e939886
5 changed files with 35 additions and 20 deletions
+17 -3
View File
@@ -1459,9 +1459,23 @@ ctrl_query_cached_reg_block_from_thread(Arena *arena, CTRL_EntityStore *store, C
B32 need_stale = 1;
if(node->reg_gen != current_reg_gen && dmn_thread_read_reg_block(thread, result))
{
need_stale = 0;
node->reg_gen = current_reg_gen;
MemoryCopy(node->block, result, reg_block_size);
OS_MutexScopeRWPromote(stripe->rw_mutex)
{
for(CTRL_ThreadRegCacheNode *n = slot->first; n != 0; n = n->next)
{
if(n->machine_id == machine_id && dmn_handle_match(n->thread, thread))
{
node = n;
break;
}
}
if(node != 0)
{
need_stale = 0;
node->reg_gen = current_reg_gen;
MemoryCopy(node->block, result, reg_block_size);
}
}
}
if(need_stale)
{
+6 -6
View File
@@ -5,12 +5,12 @@
//~ rjf: Basic Helpers
internal U64
di_hash_from_string(String8 string)
di_hash_from_string(String8 string, StringMatchFlags match_flags)
{
U64 result = 5381;
for(U64 i = 0; i < string.size; i += 1)
{
result = ((result << 5) + result) + string.str[i];
result = ((result << 5) + result) + ((match_flags & StringMatchFlag_CaseInsensitive) ? char_to_lower(string.str[i]) : string.str[i]);
}
return result;
}
@@ -237,7 +237,7 @@ di_open(String8 path, U64 min_timestamp)
if(path.size != 0)
{
String8 path_normalized = path_normalized_from_string(scratch.arena, path);
U64 hash = di_hash_from_string(path_normalized);
U64 hash = di_hash_from_string(path_normalized, StringMatchFlag_CaseInsensitive);
U64 slot_idx = hash%di_shared->slots_count;
U64 stripe_idx = slot_idx%di_shared->stripes_count;
DI_Slot *slot = &di_shared->slots[slot_idx];
@@ -294,7 +294,7 @@ di_close(String8 path, U64 min_timestamp)
{
String8 path_normalized = path_normalized_from_string(scratch.arena, path);
StringMatchFlags match_flags = path_match_flags_from_os(operating_system_from_context());
U64 hash = di_hash_from_string(path_normalized);
U64 hash = di_hash_from_string(path_normalized, StringMatchFlag_CaseInsensitive);
U64 slot_idx = hash%di_shared->slots_count;
U64 stripe_idx = slot_idx%di_shared->stripes_count;
DI_Slot *slot = &di_shared->slots[slot_idx];
@@ -353,7 +353,7 @@ di_rdi_from_path_min_timestamp(DI_Scope *scope, String8 path, U64 min_timestamp,
Temp scratch = scratch_begin(0, 0);
String8 path_normalized = path_normalized_from_string(scratch.arena, path);
StringMatchFlags match_flags = path_match_flags_from_os(operating_system_from_context());
U64 hash = di_hash_from_string(path_normalized);
U64 hash = di_hash_from_string(path_normalized, StringMatchFlag_CaseInsensitive);
U64 slot_idx = hash%di_shared->slots_count;
U64 stripe_idx = slot_idx%di_shared->stripes_count;
DI_Slot *slot = &di_shared->slots[slot_idx];
@@ -528,7 +528,7 @@ di_parse_thread__entry_point(void *p)
////////////////////////////
//- rjf: unpack key
//
U64 hash = di_hash_from_string(og_path);
U64 hash = di_hash_from_string(og_path, StringMatchFlag_CaseInsensitive);
U64 slot_idx = hash%di_shared->slots_count;
U64 stripe_idx = slot_idx%di_shared->stripes_count;
DI_Slot *slot = &di_shared->slots[slot_idx];
+1 -1
View File
@@ -200,7 +200,7 @@ global RDI_Parsed di_rdi_parsed_nil =
////////////////////////////////
//~ rjf: Basic Helpers
internal U64 di_hash_from_string(String8 string);
internal U64 di_hash_from_string(String8 string, StringMatchFlags match_flags);
////////////////////////////////
//~ rjf: Main Layer Initialization
+2 -2
View File
@@ -2185,7 +2185,7 @@ df_entity_from_path(String8 path, DF_EntityFromPathFlags flags)
// rjf: next parent -> follow it
parent = next_parent;
}
file_no_override = parent;
file_no_override = (parent != df_entity_root() ? parent : &df_g_nil_entity);
}
//- rjf: pass 2: follow overrides
@@ -2244,7 +2244,7 @@ df_entity_from_path(String8 path, DF_EntityFromPathFlags flags)
// rjf: next parent -> follow it
parent = next_parent;
}
file_overrides_applied = parent;
file_overrides_applied = (parent != df_entity_root() ? parent : &df_g_nil_entity);;
}
//- rjf: pick & return result
+9 -8
View File
@@ -2499,19 +2499,19 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
// rjf: extract thread/rip info
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
DF_Entity *debug = df_dbgi_from_module(module);
DF_Entity *dbgi = df_dbgi_from_module(module);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
RDI_Parsed *rdi = df_rdi_from_dbgi(scope, debug);
DF_TextLineDasm2SrcInfo line_info = df_text_line_dasm2src_info_from_dbgi_voff(debug, rip_voff);
RDI_Parsed *rdi = df_rdi_from_dbgi(scope, dbgi);
DF_TextLineDasm2SrcInfo line_info = df_text_line_dasm2src_info_from_dbgi_voff(dbgi, rip_voff);
// rjf: snap to resolved line
B32 missing_rip = (rip_vaddr == 0);
B32 binary_missing = (debug->flags & DF_EntityFlag_IsMissing);
B32 dbg_info_pending = !binary_missing && rdi == &di_rdi_parsed_nil;
B32 dbgi_missing = (dbgi->flags & DF_EntityFlag_IsMissing || df_entity_is_nil(dbgi));
B32 dbgi_pending = !dbgi_missing && rdi == &di_rdi_parsed_nil;
B32 has_line_info = (line_info.voff_range.max != line_info.voff_range.min);
B32 has_module = !df_entity_is_nil(module);
B32 has_dbg_info = has_module && !binary_missing;
if(!dbg_info_pending && (has_line_info || has_module))
B32 has_dbg_info = has_module && !dbgi_missing;
if(!dbgi_pending && (has_line_info || has_module))
{
DF_CmdParams params = df_cmd_params_from_window(ws);
if(has_line_info)
@@ -2527,12 +2527,13 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
params.index = unwind_count;
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualOff);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualAddr);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Index);
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
}
// rjf: retry on stopped, pending debug info
if(!df_ctrl_targets_running() && (dbg_info_pending || missing_rip))
if(!df_ctrl_targets_running() && (dbgi_pending || missing_rip))
{
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindThread));
}