From 89ff4d0de2a89f7fbb92a138294603cabbaf31ca Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Fri, 17 Jan 2025 15:28:10 -0800 Subject: [PATCH] on lambda types we have to replace unique name with hash, otherwise visual studio wont show local variables in lambdas --- src/linker/lnk_debug_info.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/linker/lnk_debug_info.c b/src/linker/lnk_debug_info.c index 03e4e2bc..055ac556 100644 --- a/src/linker/lnk_debug_info.c +++ b/src/linker/lnk_debug_info.c @@ -2505,7 +2505,7 @@ THREAD_POOL_TASK_FUNC(lnk_replace_type_names_with_hashes_lenient_task) map = &task->maps[task_id]; } - U64 hash_max_chars = hash_length; + U64 hash_max_chars = hash_length*2; U8 temp[128]; for (U64 leaf_idx = range.min; leaf_idx < range.max; ++leaf_idx) { @@ -2513,7 +2513,9 @@ THREAD_POOL_TASK_FUNC(lnk_replace_type_names_with_hashes_lenient_task) if (leaf.kind == CV_LeafKind_STRUCTURE || leaf.kind == CV_LeafKind_CLASS) { CV_UDTInfo udt_info = cv_get_udt_info(leaf.kind, leaf.data); - if (udt_info.props & CV_TypeProp_HasUniqueName && udt_info.unique_name.size > hash_max_chars) { + if ((udt_info.props & CV_TypeProp_HasUniqueName) && + udt_info.unique_name.size > hash_max_chars && + udt_info.name.size > hash_max_chars) { // hash unique name U128 name_hash; blake3_hasher hasher; blake3_hasher_init(&hasher); @@ -2523,27 +2525,33 @@ THREAD_POOL_TASK_FUNC(lnk_replace_type_names_with_hashes_lenient_task) // emit hash -> unique name map if (make_map) { lnk_format_u128(temp, sizeof(temp), hash_length, name_hash); - str8_list_pushf(map_arena, map, "%s %.*s\n", temp, str8_varg(udt_info.unique_name)); + str8_list_pushf(map_arena, map, "%s %S\n", temp, str8_varg(udt_info.unique_name)); } // parse leaf size CV_NumericParsed dummy; U64 numeric_size = cv_read_numeric(leaf.data, sizeof(CV_LeafStruct), &dummy); - U64 colon_pos = str8_find_needle_reverse(udt_info.name, 0, str8_lit("size = sizeof(CV_LeafKind) + sizeof(CV_LeafStruct) + numeric_size + udt_info.name.size + 1; - - // discard unique name - CV_LeafStruct *lf = (CV_LeafStruct *)(header + 1); - lf->props &= ~CV_TypeProp_HasUniqueName; + header->size = sizeof(CV_LeafKind) + + sizeof(CV_LeafStruct) + + numeric_size + + udt_info.name.size + 1 + + udt_info.unique_name.size + 1; } else { // replace uniuqe type name with hash udt_info.unique_name.str = udt_info.name.str + udt_info.name.size + 1;