From 08515428fbc89672d4c64174fdbbbf5b379a6274 Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Mon, 5 May 2025 15:11:34 -0700 Subject: [PATCH] convert typedefs from PDB --- src/rdi_from_pdb/rdi_from_pdb.c | 26 ++++++++++++++++++++++---- src/rdi_from_pdb/rdi_from_pdb.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index d6abec95..5f743620 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -2088,6 +2088,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) RDIM_SymbolChunkList sym_thread_variables = {0}; RDIM_ScopeChunkList sym_scopes = {0}; RDIM_InlineSiteChunkList sym_inline_sites = {0}; + RDIM_TypeChunkList typedefs = {0}; ////////////////////////// //- rjf: symbols pass 1: produce procedure frame info map (procedure -> frame info) @@ -2310,6 +2311,20 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) symbol->container_type = container_type; } }break; + + case CV_SymKind_UDT: + { + if(in->parsing_global_stream && top_scope_node == 0) + { + CV_SymUDT *udt = (CV_SymUDT *)sym_header_struct_base; + String8 name = str8_cstring_capped(udt+1, sym_data_opl); + + RDIM_Type *type = rdim_type_chunk_list_push(arena, &typedefs, 4096); + type->kind = RDI_TypeKind_Alias; + type->name = name; + type->direct_type = p2r_type_ptr_from_itype(udt->itype); + } + }break; //- rjf: LPROC32/GPROC32 case CV_SymKind_LPROC32: @@ -2919,6 +2934,7 @@ ASYNC_WORK_DEF(p2r_symbol_stream_convert_work) out->thread_variables = sym_thread_variables; out->scopes = sym_scopes; out->inline_sites = sym_inline_sites; + out->typedefs = typedefs; } #undef p2r_type_ptr_from_itype @@ -3990,10 +4006,11 @@ p2r_convert(Arena *arena, P2R_User2Convert *in) tasks_inputs[idx].link_name_map = link_name_map; if(idx < global_stream_subdivision_tasks_count) { - tasks_inputs[idx].sym = sym; - tasks_inputs[idx].sym_ranges_first= idx*global_stream_syms_per_task; - tasks_inputs[idx].sym_ranges_opl = tasks_inputs[idx].sym_ranges_first + global_stream_syms_per_task; - tasks_inputs[idx].sym_ranges_opl = ClampTop(tasks_inputs[idx].sym_ranges_opl, sym->sym_ranges.count); + tasks_inputs[idx].parsing_global_stream = 1; + tasks_inputs[idx].sym = sym; + tasks_inputs[idx].sym_ranges_first = idx*global_stream_syms_per_task; + tasks_inputs[idx].sym_ranges_opl = tasks_inputs[idx].sym_ranges_first + global_stream_syms_per_task; + tasks_inputs[idx].sym_ranges_opl = ClampTop(tasks_inputs[idx].sym_ranges_opl, sym->sym_ranges.count); } else { @@ -4019,6 +4036,7 @@ p2r_convert(Arena *arena, P2R_User2Convert *in) rdim_symbol_chunk_list_concat_in_place(&all_thread_variables, &out->thread_variables); rdim_scope_chunk_list_concat_in_place(&all_scopes, &out->scopes); rdim_inline_site_chunk_list_concat_in_place(&all_inline_sites,&out->inline_sites); + rdim_type_chunk_list_concat_in_place(&all_types, &out->typedefs); } } } diff --git a/src/rdi_from_pdb/rdi_from_pdb.h b/src/rdi_from_pdb/rdi_from_pdb.h index 03cae2d2..e8642256 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.h +++ b/src/rdi_from_pdb/rdi_from_pdb.h @@ -249,6 +249,7 @@ struct P2R_UDTConvertIn typedef struct P2R_SymbolStreamConvertIn P2R_SymbolStreamConvertIn; struct P2R_SymbolStreamConvertIn { + B32 parsing_global_stream; RDI_Arch arch; COFF_SectionHeaderArray coff_sections; PDB_TpiHashParsed *tpi_hash; @@ -271,6 +272,7 @@ struct P2R_SymbolStreamConvertOut RDIM_SymbolChunkList thread_variables; RDIM_ScopeChunkList scopes; RDIM_InlineSiteChunkList inline_sites; + RDIM_TypeChunkList typedefs; }; ////////////////////////////////