From cd7e2d3f892a2079e17e4dfe471213fc629c8286 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 26 Sep 2025 11:37:07 -0700 Subject: [PATCH] breakpad dumping: include pdb name if missing exe name, include pdb guid if no exe hash --- src/artifact_cache/artifact_cache.c | 2 ++ src/ctrl/ctrl_core.c | 21 ++++++++++++++++++++ src/ctrl/ctrl_core.h | 7 +++++++ src/lib_rdi/rdi.c | 12 ++++++++---- src/radbin/radbin.c | 30 ++++++++++++++++++++++++++++- src/rdi/rdi.mdesk | 12 ++++++++---- 6 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/artifact_cache/artifact_cache.c b/src/artifact_cache/artifact_cache.c index 3952cf37..b9f14027 100644 --- a/src/artifact_cache/artifact_cache.c +++ b/src/artifact_cache/artifact_cache.c @@ -26,6 +26,7 @@ ac_init(void) internal AC_Artifact ac_artifact_from_key_(Access *access, String8 key, AC_ArtifactParams *params, U64 endt_us) { + ProfBeginFunction(); AC_RequestBatch *req_batch = &ac_shared->req_batches[params->flags & AC_Flag_HighPriority ? 0 : 1]; //- rjf: create function -> cache @@ -193,6 +194,7 @@ ac_artifact_from_key_(Access *access, String8 key, AC_ArtifactParams *params, U6 params->stale_out[0] = artifact_is_stale; } + ProfEnd(); return artifact; } diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 2623ea09..e9af43b6 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -7822,3 +7822,24 @@ ctrl_call_stack_from_thread_new(Access *access, CTRL_Handle thread_handle, B32 h } return result; } + +//////////////////////////////// +//~ rjf: Call Stack Tree Artifact Cache Hooks / Lookups + +internal AC_Artifact +ctrl_call_stack_tree_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out) +{ + +} + +internal void +ctrl_call_stack_tree_artifact_destroy(AC_Artifact artifact) +{ + +} + +internal CTRL_CallStackTree +ctrl_call_stack_tree_new(Access *access, U64 endt_us) +{ + +} diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index 216aad93..b2d72f6d 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -1264,4 +1264,11 @@ internal AC_Artifact ctrl_call_stack_artifact_create(String8 key, U64 gen, U64 * internal void ctrl_call_stack_artifact_destroy(AC_Artifact artifact); internal CTRL_CallStack ctrl_call_stack_from_thread_new(Access *access, CTRL_Handle thread_handle, B32 high_priority, U64 endt_us); +//////////////////////////////// +//~ rjf: Call Stack Tree Artifact Cache Hooks / Lookups + +internal AC_Artifact ctrl_call_stack_tree_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out); +internal void ctrl_call_stack_tree_artifact_destroy(AC_Artifact artifact); +internal CTRL_CallStackTree ctrl_call_stack_tree_new(Access *access, U64 endt_us); + #endif // CTRL_CORE_H diff --git a/src/lib_rdi/rdi.c b/src/lib_rdi/rdi.c index 7d6ffc4c..7f2e6515 100644 --- a/src/lib_rdi/rdi.c +++ b/src/lib_rdi/rdi.c @@ -133,11 +133,15 @@ struct {RDI_U8 *str; RDI_U64 size;} rdi_eval_conversion_kind_message_string_tabl RDI_PROC RDI_U64 rdi_hash(RDI_U8 *ptr, RDI_U64 size) { - RDI_U64 result = 5381; - RDI_U8 *opl = ptr + size; - for(;ptr < opl; ptr += 1) + RDI_U64 result = 0; + if(size != 0) { - result = ((result << 5) + result) + *ptr; + result = 5381; + RDI_U8 *opl = ptr + size; + for(;ptr < opl; ptr += 1) + { + result = ((result << 5) + result) + *ptr; + } } return result; } diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index dfc84dc1..9f81bae8 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -807,7 +807,35 @@ rb_thread_entry_point(void *p) //- rjf: dump MODULE record if(lane_idx() == 0) { - str8_list_pushf(arena, &p2b_shared->dump, "MODULE windows x86_64 %I64x %S\n", bake_params.top_level_info.exe_hash, bake_params.top_level_info.exe_name); + // rjf: pick name to identify module + String8 module_name_string = bake_params.top_level_info.exe_name; + if(module_name_string.size == 0 && input_files.first != 0) + { + module_name_string = input_files.first->v->path; + } + + // rjf: pick string for unique code + String8 unique_identifier_string = {0}; + if(unique_identifier_string.size == 0 && bake_params.top_level_info.exe_hash != 0) + { + unique_identifier_string = str8f(arena, "%I64x", bake_params.top_level_info.exe_hash); + } + if(unique_identifier_string.size == 0 && input_files.first != 0 && input_files.first->v->format == RB_FileFormat_PDB) + { + Temp scratch = scratch_begin(&arena, 1); + String8 msf_data = input_files.first->v->data; + MSF_RawStreamTable *st = msf_raw_stream_table_from_data(scratch.arena, msf_data); + String8 info_data = msf_data_from_stream_number(scratch.arena, msf_data, st, PDB_FixedStream_Info); + PDB_Info *info = pdb_info_from_data(scratch.arena, info_data); + if(info != 0) + { + unique_identifier_string = string_from_guid(arena, info->auth_guid); + } + scratch_end(scratch); + } + + // rjf: push record + str8_list_pushf(arena, &p2b_shared->dump, "MODULE windows x86_64 %S %S\n", unique_identifier_string, module_name_string); } //- rjf: dump FILE records diff --git a/src/rdi/rdi.mdesk b/src/rdi/rdi.mdesk index 68876a09..8abb24e8 100644 --- a/src/rdi/rdi.mdesk +++ b/src/rdi/rdi.mdesk @@ -1492,11 +1492,15 @@ RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConver RDI_PROC RDI_U64 rdi_hash(RDI_U8 *ptr, RDI_U64 size) { - RDI_U64 result = 5381; - RDI_U8 *opl = ptr + size; - for(;ptr < opl; ptr += 1) + RDI_U64 result = 0; + if(size != 0) { - result = ((result << 5) + result) + *ptr; + result = 5381; + RDI_U8 *opl = ptr + size; + for(;ptr < opl; ptr += 1) + { + result = ((result << 5) + result) + *ptr; + } } return result; }