From 17cdf458d32f2268b4ed43d855543624a635bfb4 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 19 May 2026 12:08:26 -0700 Subject: [PATCH] on ambiguous debug info matches, inside primary debug info -> try building a fully qualified name from context, and replacing initial debug info match if it hits --- src/dbg_info/dbg_info.c | 6 ++++-- src/dbg_info/dbg_info.h | 1 + src/eval/eval_ir.c | 23 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/dbg_info/dbg_info.c b/src/dbg_info/dbg_info.c index 5cbbf1b6..7bd22698 100644 --- a/src/dbg_info/dbg_info.c +++ b/src/dbg_info/dbg_info.c @@ -1699,6 +1699,7 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g 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 = filtered_matches[selected_match_idx]; + lane_matches[lane_idx()].count = filtered_matches_count; } } } @@ -1732,7 +1733,7 @@ di_match_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *g artifact.u64[0] = match.key.u64[0]; artifact.u64[1] = match.key.u64[1]; artifact.u64[2] = match.section_kind; - artifact.u64[3] = match.idx; + artifact.u64[3] = ((U64)(match.idx & 0xffffffffull) << 32) | ((U64)(match.count & 0xffffffffull) << 0); } lane_sync(); @@ -1760,7 +1761,8 @@ di_match_from_string(String8 string, U64 match_index, DI_Key preferred_dbgi_key, result.key.u64[0] = artifact.u64[0]; result.key.u64[1] = artifact.u64[1]; result.section_kind = artifact.u64[2]; - result.idx = artifact.u64[3]; + result.idx = (artifact.u64[3] & 0xffffffff00000000ull) >> 32; + result.count = (artifact.u64[3] & 0x00000000ffffffffull) >> 0; } scratch_end(scratch); access_close(access); diff --git a/src/dbg_info/dbg_info.h b/src/dbg_info/dbg_info.h index 654a94c9..26e821bf 100644 --- a/src/dbg_info/dbg_info.h +++ b/src/dbg_info/dbg_info.h @@ -202,6 +202,7 @@ struct DI_Match DI_Key key; RDI_SectionKind section_kind; U32 idx; + U32 count; }; //////////////////////////////// diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index a8c5906c..5fd76795 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -1900,6 +1900,26 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I // rjf: find match DI_Match match = di_match_from_string(string, match_disambiguating_idx, e_base_ctx->primary_dbg_info->dbgi_key, 0); + // rjf: match -> RDI + RDI_Parsed *rdi = di_rdi_from_key(access, match.key, 0, 0); + + // rjf: ambiguous global/thread variable in primary debug info -> try fully qualifying the name implicitly. + if((match.section_kind == RDI_SectionKind_GlobalVariables || + match.section_kind == RDI_SectionKind_ThreadVariables) && + match.count != 1 && + rdi == e_base_ctx->primary_dbg_info->rdi) + { + U64 voff = e_base_ctx->thread_ip_voff; + RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, voff); + String8 procedure_name = fully_qualified_str8_from_rdi_symbol(scratch.arena, rdi, procedure); + String8 fully_qualified_name = str8f(scratch.arena, "%S.%S", procedure_name, string); + DI_Match fully_qualified_match_maybe = di_match_from_string(fully_qualified_name, match_disambiguating_idx, e_base_ctx->primary_dbg_info->dbgi_key, 0); + if(fully_qualified_match_maybe.idx != 0) + { + match = fully_qualified_match_maybe; + } + } + #if 0 //~ TODO(rjf): vvvvv this used to be used for namespaceifying partially-qualified strings. // now, the debugger just stores partially-qualified strings, so we instead need to do the @@ -1943,9 +1963,6 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I } #endif - // rjf: match -> RDI - RDI_Parsed *rdi = di_rdi_from_key(access, match.key, 0, 0); - // rjf: find dbg info from rdi E_DbgInfo *dbg_info = &e_dbg_info_nil; U32 dbg_info_num = 0;