extend dbgi matching system with preferred dbgi key, to disambiguate results - fill with primary module dbgi in eval, to always prefer selected thread context when applicable

This commit is contained in:
Ryan Fleury
2025-10-06 14:31:57 -07:00
parent d2216019b9
commit 835a57f918
7 changed files with 23 additions and 14 deletions
+1
View File
@@ -4385,6 +4385,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
//- rjf: fill evaluation module info //- rjf: fill evaluation module info
eval_modules[eval_module_idx].arch = arch; eval_modules[eval_module_idx].arch = arch;
eval_modules[eval_module_idx].dbgi_key = dbgi_key;
eval_modules[eval_module_idx].rdi = rdi; eval_modules[eval_module_idx].rdi = rdi;
eval_modules[eval_module_idx].vaddr_range = mod->vaddr_range; eval_modules[eval_module_idx].vaddr_range = mod->vaddr_range;
eval_modules[eval_module_idx].space = e_space_make(CTRL_EvalSpaceKind_Entity); eval_modules[eval_module_idx].space = e_space_make(CTRL_EvalSpaceKind_Entity);
+8 -2
View File
@@ -1432,9 +1432,11 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
//- rjf: unpack key //- rjf: unpack key
U64 index = 0; U64 index = 0;
String8 name = {0}; String8 name = {0};
DI_Key preferred_key = {0};
{ {
U64 key_read_off = 0; U64 key_read_off = 0;
key_read_off += str8_deserial_read_struct(key, key_read_off, &index); key_read_off += str8_deserial_read_struct(key, key_read_off, &index);
key_read_off += str8_deserial_read_struct(key, key_read_off, &preferred_key);
key_read_off += str8_deserial_read_struct(key, key_read_off, &name.size); key_read_off += str8_deserial_read_struct(key, key_read_off, &name.size);
name.str = push_array_no_zero(scratch.arena, U8, name.size); name.str = push_array_no_zero(scratch.arena, U8, name.size);
key_read_off += str8_deserial_read(key, key_read_off, name.str, name.size, 1); key_read_off += str8_deserial_read(key, key_read_off, name.str, name.size, 1);
@@ -1502,7 +1504,10 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
if(lane_matches[idx].idx != 0) if(lane_matches[idx].idx != 0)
{ {
match = lane_matches[idx]; match = lane_matches[idx];
break; if(di_key_match(di_key_zero(), preferred_key) || di_key_match(match.key, preferred_key))
{
break;
}
} }
} }
@@ -1523,7 +1528,7 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out)
} }
internal DI_Match internal DI_Match
di_match_from_string(String8 string, U64 index, U64 endt_us) di_match_from_string(String8 string, U64 index, DI_Key preferred_dbgi_key, U64 endt_us)
{ {
DI_Match result = {0}; DI_Match result = {0};
Access *access = access_open(); Access *access = access_open();
@@ -1531,6 +1536,7 @@ di_match_from_string(String8 string, U64 index, U64 endt_us)
{ {
String8List key_parts = {0}; String8List key_parts = {0};
str8_list_push(scratch.arena, &key_parts, str8_struct(&index)); str8_list_push(scratch.arena, &key_parts, str8_struct(&index));
str8_list_push(scratch.arena, &key_parts, str8_struct(&preferred_dbgi_key));
str8_list_push(scratch.arena, &key_parts, str8_struct(&string.size)); str8_list_push(scratch.arena, &key_parts, str8_struct(&string.size));
str8_list_push(scratch.arena, &key_parts, string); str8_list_push(scratch.arena, &key_parts, string);
String8 key = str8_list_join(scratch.arena, &key_parts, 0); String8 key = str8_list_join(scratch.arena, &key_parts, 0);
+1 -1
View File
@@ -358,6 +358,6 @@ internal DI_SearchItemArray di_search_item_array_from_target_query(Access *acces
//~ rjf: Match Artifact Cache Hooks / Lookups //~ rjf: Match Artifact Cache Hooks / Lookups
internal AC_Artifact di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out); internal AC_Artifact di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out);
internal DI_Match di_match_from_string(String8 string, U64 index, U64 endt_us); internal DI_Match di_match_from_string(String8 string, U64 index, DI_Key preferred_dbgi_key, U64 endt_us);
#endif // DBG_INFO_H #endif // DBG_INFO_H
+2 -1
View File
@@ -570,6 +570,7 @@ struct E_ConsTypeSlot
typedef struct E_Module E_Module; typedef struct E_Module E_Module;
struct E_Module struct E_Module
{ {
DI_Key dbgi_key;
RDI_Parsed *rdi; RDI_Parsed *rdi;
Rng1U64 vaddr_range; Rng1U64 vaddr_range;
Arch arch; Arch arch;
@@ -1111,7 +1112,7 @@ read_only global E_String2ExprMap e_string2expr_map_nil = {0};
read_only global E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil}; read_only global E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_expr_nil};
read_only global E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil}; read_only global E_IRNode e_irnode_nil = {&e_irnode_nil, &e_irnode_nil, &e_irnode_nil};
read_only global E_Eval e_eval_nil = {{0}, {0}, {0}, &e_expr_nil, {&e_irnode_nil}}; read_only global E_Eval e_eval_nil = {{0}, {0}, {0}, &e_expr_nil, {&e_irnode_nil}};
read_only global E_Module e_module_nil = {&rdi_parsed_nil}; read_only global E_Module e_module_nil = {{0}, &rdi_parsed_nil};
read_only global E_CacheBundle e_cache_bundle_nil = {0, {0}, {0}, {0}, {{0}, 0, &e_expr_nil, &e_expr_nil}, {&e_irnode_nil}}; read_only global E_CacheBundle e_cache_bundle_nil = {0, {0}, {0}, {0}, {{0}, 0, &e_expr_nil, &e_expr_nil}, {&e_irnode_nil}};
thread_static E_BaseCtx *e_base_ctx = 0; thread_static E_BaseCtx *e_base_ctx = 0;
thread_static E_IRCtx *e_ir_ctx = 0; thread_static E_IRCtx *e_ir_ctx = 0;
+2 -2
View File
@@ -1871,7 +1871,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
Access *access = access_open(); Access *access = access_open();
// rjf: find match // rjf: find match
DI_Match match = di_match_from_string(string, 0, 0); DI_Match match = di_match_from_string(string, 0, e_base_ctx->primary_module->dbgi_key, 0);
if(match.idx == 0) if(match.idx == 0)
{ {
String8List namespaceified_strings = {0}; String8List namespaceified_strings = {0};
@@ -1900,7 +1900,7 @@ 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) for(String8Node *n = namespaceified_strings.first; n != 0; n = n->next)
{ {
match = di_match_from_string(n->string, 0, 0); match = di_match_from_string(n->string, 0, e_base_ctx->primary_module->dbgi_key, 0);
if(match.idx != 0) if(match.idx != 0)
{ {
break; break;
+1 -1
View File
@@ -585,7 +585,7 @@ e_leaf_type_key_from_name(String8 name)
E_TypeKey key = e_leaf_builtin_type_key_from_name(name); E_TypeKey key = e_leaf_builtin_type_key_from_name(name);
if(!e_type_key_match(e_type_key_zero(), key)) if(!e_type_key_match(e_type_key_zero(), key))
{ {
DI_Match match = di_match_from_string(name, 0, 0); DI_Match match = di_match_from_string(name, 0, e_base_ctx->primary_module->dbgi_key, 0);
if(match.section_kind == RDI_SectionKind_TypeNodes) if(match.section_kind == RDI_SectionKind_TypeNodes)
{ {
Access *access = access_open(); Access *access = access_open();
+3 -2
View File
@@ -10311,7 +10311,7 @@ rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8
// rjf: try to map using asynchronous matching system // rjf: try to map using asynchronous matching system
if(!mapped && kind == TXT_TokenKind_Identifier) if(!mapped && kind == TXT_TokenKind_Identifier)
{ {
DI_Match match = di_match_from_string(string, 0, 0); DI_Match match = di_match_from_string(string, 0, e_base_ctx->primary_module->dbgi_key, 0);
RDI_SectionKind section_kind = match.section_kind; RDI_SectionKind section_kind = match.section_kind;
mapped = 1; mapped = 1;
switch(section_kind) switch(section_kind)
@@ -11887,6 +11887,7 @@ rd_frame(void)
CTRL_Entity *m = all_modules.v[eval_module_idx]; CTRL_Entity *m = all_modules.v[eval_module_idx];
DI_Key dbgi_key = ctrl_dbgi_key_from_module(m); DI_Key dbgi_key = ctrl_dbgi_key_from_module(m);
eval_modules[eval_module_idx].arch = m->arch; eval_modules[eval_module_idx].arch = m->arch;
eval_modules[eval_module_idx].dbgi_key = dbgi_key;
eval_modules[eval_module_idx].rdi = di_rdi_from_key(rd_state->frame_access, dbgi_key, 0, 0); eval_modules[eval_module_idx].rdi = di_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].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); eval_modules[eval_module_idx].space = rd_eval_space_from_ctrl_entity(ctrl_entity_ancestor_from_kind(m, CTRL_EntityKind_Process), RD_EvalSpaceKind_CtrlEntity);
@@ -14769,7 +14770,7 @@ rd_frame(void)
DI_Key voff_dbgi_key = {0}; DI_Key voff_dbgi_key = {0};
if(!name_resolved) if(!name_resolved)
{ {
DI_Match match = di_match_from_string(name, 0, 0); DI_Match match = di_match_from_string(name, 0, e_base_ctx->primary_module->dbgi_key, 0);
if(match.section_kind == RDI_SectionKind_Procedures) if(match.section_kind == RDI_SectionKind_Procedures)
{ {
Access *access = access_open(); Access *access = access_open();