respect subset flags in pdb -> rdi converter

This commit is contained in:
Ryan Fleury
2025-09-22 17:32:05 -07:00
parent 8078b90f51
commit 5c1cf77fda
2 changed files with 1640 additions and 1588 deletions
+1 -1
View File
@@ -1061,7 +1061,7 @@ lane_sync(); if(flags & RDI_DumpSubsetFlag_##name) ProfScope(#name)
// //
DumpSubset(Scopes) DumpSubset(Scopes)
{ {
dumpf("\n"); if(lane_idx() == 0) { dumpf("\n"); }
RDI_TopLevelInfo *tli = rdi_element_from_name_idx(rdi, TopLevelInfo, 0); RDI_TopLevelInfo *tli = rdi_element_from_name_idx(rdi, TopLevelInfo, 0);
U64 scope_voffs_count = 0; U64 scope_voffs_count = 0;
U64 *scope_voffs = rdi_table_from_name(rdi, ScopeVOffData, &scope_voffs_count); U64 *scope_voffs = rdi_table_from_name(rdi, ScopeVOffData, &scope_voffs_count);
+60 -8
View File
@@ -1046,6 +1046,9 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
//- rjf: build unified collection & map for source files //- rjf: build unified collection & map for source files
// //
if(params->subset_flags & (RDIM_SubsetFlag_NormalSourcePathNameMap|
RDIM_SubsetFlag_LineInfo|
RDIM_SubsetFlag_InlineLineInfo))
{ {
//- rjf: set up table //- rjf: set up table
ProfScope("set up table") if(lane_idx() == 0) ProfScope("set up table") if(lane_idx() == 0)
@@ -1103,11 +1106,14 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
{ {
//- rjf: set up outputs //- rjf: set up outputs
ProfScope("set up outputs") if(lane_idx() == 0) ProfScope("set up outputs") if(lane_idx() == 0)
{
if(params->subset_flags & RDIM_SubsetFlag_Units)
{ {
for EachIndex(idx, comp_units->count) for EachIndex(idx, comp_units->count)
{ {
rdim_unit_chunk_list_push(arena, &p2r_shared->all_units, comp_units->count); rdim_unit_chunk_list_push(arena, &p2r_shared->all_units, comp_units->count);
} }
}
p2r_shared->units_line_tables = push_array(arena, RDIM_LineTableChunkList, comp_units->count); p2r_shared->units_line_tables = push_array(arena, RDIM_LineTableChunkList, comp_units->count);
p2r_shared->units_first_inline_site_line_tables = push_array(arena, RDIM_LineTable *, comp_units->count); p2r_shared->units_first_inline_site_line_tables = push_array(arena, RDIM_LineTable *, comp_units->count);
p2r_shared->sym_lane_take_counter = 0; p2r_shared->sym_lane_take_counter = 0;
@@ -1119,6 +1125,11 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
Assert(units_count == comp_units->count); Assert(units_count == comp_units->count);
//- rjf: do per-lane work //- rjf: do per-lane work
if(params->subset_flags & (RDIM_SubsetFlag_Units|
RDIM_SubsetFlag_NormalSourcePathNameMap|
RDIM_SubsetFlag_LineInfo|
RDIM_SubsetFlag_InlineLineInfo))
{
ProfScope("wide fill") for(;;) ProfScope("wide fill") for(;;)
{ {
//- rjf: take next unit //- rjf: take next unit
@@ -1133,7 +1144,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
PDB_CompUnit *src_unit = comp_units->units[unit_idx]; PDB_CompUnit *src_unit = comp_units->units[unit_idx];
CV_SymParsed *src_unit_sym = all_syms[unit_idx+1]; CV_SymParsed *src_unit_sym = all_syms[unit_idx+1];
CV_C13Parsed *src_unit_c13 = all_c13s[unit_idx+1]; CV_C13Parsed *src_unit_c13 = all_c13s[unit_idx+1];
RDIM_Unit *dst_unit = &units[unit_idx]; RDIM_Unit *dst_unit = 0;
if(params->subset_flags & RDIM_SubsetFlag_Units) { dst_unit = &units[unit_idx]; }
// rjf: extract unit name // rjf: extract unit name
String8 unit_name = src_unit->obj_name; String8 unit_name = src_unit->obj_name;
@@ -1156,7 +1168,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
String8 obj_folder_path = backslashed_from_str8(scratch.arena, str8_chop_last_slash(obj_name)); String8 obj_folder_path = backslashed_from_str8(scratch.arena, str8_chop_last_slash(obj_name));
//- rjf: main unit line table conversion //- rjf: main unit line table conversion
ProfScope("main unit line table conversion") if(params->subset_flags & RDIM_SubsetFlag_LineInfo) ProfScope("main unit line table conversion")
{ {
RDIM_LineTable *line_table = 0; RDIM_LineTable *line_table = 0;
for(CV_C13SubSectionNode *node = src_unit_c13->first_sub_section; for(CV_C13SubSectionNode *node = src_unit_c13->first_sub_section;
@@ -1218,6 +1230,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
} }
// rjf: fill unit // rjf: fill unit
if(dst_unit != 0)
{
dst_unit->unit_name = unit_name; dst_unit->unit_name = unit_name;
dst_unit->compiler_name = src_unit_sym->info.compiler_name; dst_unit->compiler_name = src_unit_sym->info.compiler_name;
dst_unit->object_file = obj_name; dst_unit->object_file = obj_name;
@@ -1226,9 +1240,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
dst_unit->line_table = line_table; dst_unit->line_table = line_table;
dst_unit->voff_ranges = unit_ranges[unit_idx]; dst_unit->voff_ranges = unit_ranges[unit_idx];
} }
}
//- rjf: build per-inline-site line tables //- rjf: build per-inline-site line tables
ProfScope("build per-inline-site line tables") if(params->subset_flags & RDIM_SubsetFlag_InlineLineInfo) ProfScope("build per-inline-site line tables")
{ {
CV_RecRange *rec_ranges_first = src_unit_sym->sym_ranges.ranges; CV_RecRange *rec_ranges_first = src_unit_sym->sym_ranges.ranges;
CV_RecRange *rec_ranges_opl = src_unit_sym->sym_ranges.ranges + src_unit_sym->sym_ranges.count; CV_RecRange *rec_ranges_opl = src_unit_sym->sym_ranges.ranges + src_unit_sym->sym_ranges.count;
@@ -1450,6 +1465,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
scratch_end(scratch); scratch_end(scratch);
} }
} }
}
lane_sync(); lane_sync();
RDIM_UnitChunkList all_units = p2r_shared->all_units; RDIM_UnitChunkList all_units = p2r_shared->all_units;
RDIM_LineTableChunkList *units_line_tables = p2r_shared->units_line_tables; RDIM_LineTableChunkList *units_line_tables = p2r_shared->units_line_tables;
@@ -1511,6 +1527,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
lane_sync(); lane_sync();
//- rjf: do wide fill //- rjf: do wide fill
if(params->subset_flags & RDIM_SubsetFlag_Types)
{ {
Rng1U64 range = lane_range(p2r_shared->itype_opl); Rng1U64 range = lane_range(p2r_shared->itype_opl);
for EachInRange(idx, range) for EachInRange(idx, range)
@@ -1658,6 +1675,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
lane_sync(); lane_sync();
//- rjf: do wide fill //- rjf: do wide fill
if(params->subset_flags & RDIM_SubsetFlag_Types)
{ {
Rng1U64 range = lane_range(p2r_shared->itype_opl); Rng1U64 range = lane_range(p2r_shared->itype_opl);
for EachInRange(idx, range) for EachInRange(idx, range)
@@ -1974,6 +1992,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////// ////////////////////////////
//- rjf: build basic types //- rjf: build basic types
// //
if(params->subset_flags & RDIM_SubsetFlag_Types)
{ {
for(RDI_TypeKind type_kind = RDI_TypeKind_FirstBuiltIn; for(RDI_TypeKind type_kind = RDI_TypeKind_FirstBuiltIn;
type_kind <= RDI_TypeKind_LastBuiltIn; type_kind <= RDI_TypeKind_LastBuiltIn;
@@ -1990,6 +2009,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////// ////////////////////////////
//- rjf: build basic type aliases //- rjf: build basic type aliases
// //
if(params->subset_flags & RDIM_SubsetFlag_Types)
{ {
RDIM_DataModel data_model = rdim_data_model_from_os_arch(OperatingSystem_Windows, arch); RDIM_DataModel data_model = rdim_data_model_from_os_arch(OperatingSystem_Windows, arch);
RDI_TypeKind short_type = rdim_short_type_kind_from_data_model(data_model); RDI_TypeKind short_type = rdim_short_type_kind_from_data_model(data_model);
@@ -2065,6 +2085,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////// ////////////////////////////
//- rjf: build types from TPI //- rjf: build types from TPI
// //
if(params->subset_flags & RDIM_SubsetFlag_Types)
{
for(CV_TypeId root_itype = 0; root_itype < itype_opl; root_itype += 1) for(CV_TypeId root_itype = 0; root_itype < itype_opl; root_itype += 1)
{ {
for(P2R_TypeIdChain *itype_chain = itype_chains[root_itype]; for(P2R_TypeIdChain *itype_chain = itype_chains[root_itype];
@@ -2494,6 +2516,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
} }
} }
} }
}
p2r_shared->itype_type_ptrs = itype_type_ptrs; p2r_shared->itype_type_ptrs = itype_type_ptrs;
p2r_shared->basic_type_ptrs = basic_type_ptrs; p2r_shared->basic_type_ptrs = basic_type_ptrs;
p2r_shared->all_types__pre_typedefs = all_types; p2r_shared->all_types__pre_typedefs = all_types;
@@ -2520,6 +2543,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
lane_sync(); lane_sync();
//- rjf: do wide fill //- rjf: do wide fill
if(params->subset_flags & RDIM_SubsetFlag_Types &&
params->subset_flags & RDIM_SubsetFlag_UDTs)
{ {
U64 udts_chunk_cap = 4096; U64 udts_chunk_cap = 4096;
RDIM_UDTChunkList *udts = &p2r_shared->lanes_udts[lane_idx()]; RDIM_UDTChunkList *udts = &p2r_shared->lanes_udts[lane_idx()];
@@ -3187,6 +3212,18 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//////////////////////////// ////////////////////////////
//- rjf: fill outputs for all unit sym blocks in this lane //- rjf: fill outputs for all unit sym blocks in this lane
// //
if(params->subset_flags & (RDIM_SubsetFlag_Procedures|
RDIM_SubsetFlag_GlobalVariables|
RDIM_SubsetFlag_ThreadVariables|
RDIM_SubsetFlag_Scopes|
RDIM_SubsetFlag_Locals|
RDIM_SubsetFlag_GlobalVariableNameMap|
RDIM_SubsetFlag_ThreadVariableNameMap|
RDIM_SubsetFlag_ProcedureNameMap|
RDIM_SubsetFlag_ConstantNameMap|
RDIM_SubsetFlag_LinkNameProcedureNameMap|
RDIM_SubsetFlag_Types))
{
for(;;) for(;;)
{ {
//- rjf: take next sym //- rjf: take next sym
@@ -3442,6 +3479,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: UDT (typedefs) //- rjf: UDT (typedefs)
case CV_SymKind_UDT: case CV_SymKind_UDT:
if(sym == all_syms[0] && top_scope_node == 0) if(sym == all_syms[0] && top_scope_node == 0)
{
if(params->subset_flags & (RDIM_SubsetFlag_Types|RDIM_SubsetFlag_UDTs|RDIM_SubsetFlag_TypeNameMap))
{ {
CV_SymUDT *udt = (CV_SymUDT *)sym_header_struct_base; CV_SymUDT *udt = (CV_SymUDT *)sym_header_struct_base;
String8 name = str8_cstring_capped(udt+1, sym_data_opl); String8 name = str8_cstring_capped(udt+1, sym_data_opl);
@@ -3453,6 +3492,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
{ {
type->byte_size = type->direct_type->byte_size; type->byte_size = type->direct_type->byte_size;
} }
}
}break; }break;
//- rjf: LPROC32/GPROC32 //- rjf: LPROC32/GPROC32
@@ -3488,8 +3528,10 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
// it here because these scopes refer to the ranges of code that make up a // it here because these scopes refer to the ranges of code that make up a
// procedure *not* the namespaces, so a procedure's root scope always has // procedure *not* the namespaces, so a procedure's root scope always has
// no parent. // no parent.
RDIM_Scope *procedure_root_scope = rdim_scope_chunk_list_push(arena, sym_scopes, sym_scopes_chunk_cap); RDIM_Scope *procedure_root_scope = 0;
if(params->subset_flags & RDIM_SubsetFlag_Scopes)
{ {
procedure_root_scope = rdim_scope_chunk_list_push(arena, sym_scopes, sym_scopes_chunk_cap);
COFF_SectionHeader *section = (0 < proc32->sec && proc32->sec <= coff_sections.count) ? &coff_sections.v[proc32->sec-1] : 0; COFF_SectionHeader *section = (0 < proc32->sec && proc32->sec <= coff_sections.count) ? &coff_sections.v[proc32->sec-1] : 0;
if(section != 0) if(section != 0)
{ {
@@ -3503,7 +3545,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
// rjf: root scope voff minimum range -> link name // rjf: root scope voff minimum range -> link name
String8 link_name = {0}; String8 link_name = {0};
if(procedure_root_scope->voff_ranges.min != 0) if(procedure_root_scope && procedure_root_scope->voff_ranges.min != 0)
{ {
U64 voff = procedure_root_scope->voff_ranges.min; U64 voff = procedure_root_scope->voff_ranges.min;
U64 hash = p2r_hash_from_voff(voff); U64 hash = p2r_hash_from_voff(voff);
@@ -3520,6 +3562,8 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
} }
// rjf: build procedure symbol // rjf: build procedure symbol
if(params->subset_flags & (RDIM_SubsetFlag_Procedures|RDIM_SubsetFlag_ProcedureNameMap))
{
RDIM_Symbol *procedure_symbol = rdim_symbol_chunk_list_push(arena, sym_procedures, sym_procedures_chunk_cap); RDIM_Symbol *procedure_symbol = rdim_symbol_chunk_list_push(arena, sym_procedures, sym_procedures_chunk_cap);
procedure_symbol->is_extern = (kind == CV_SymKind_GPROC32); procedure_symbol->is_extern = (kind == CV_SymKind_GPROC32);
procedure_symbol->name = name; procedure_symbol->name = name;
@@ -3528,11 +3572,14 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
procedure_symbol->container_symbol = container_symbol; procedure_symbol->container_symbol = container_symbol;
procedure_symbol->container_type = container_type; procedure_symbol->container_type = container_type;
procedure_symbol->root_scope = procedure_root_scope; procedure_symbol->root_scope = procedure_root_scope;
if(procedure_root_scope != 0)
// rjf: fill root scope's symbol {
procedure_root_scope->symbol = procedure_symbol; procedure_root_scope->symbol = procedure_symbol;
}
}
// rjf: push scope to scope stack // rjf: push scope to scope stack
if(procedure_root_scope)
{ {
P2R_ScopeNode *node = free_scope_node; P2R_ScopeNode *node = free_scope_node;
if(node != 0) { SLLStackPop(free_scope_node); } if(node != 0) { SLLStackPop(free_scope_node); }
@@ -3547,6 +3594,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: REGREL32 //- rjf: REGREL32
case CV_SymKind_REGREL32: case CV_SymKind_REGREL32:
if(params->subset_flags & RDIM_SubsetFlag_Locals)
{ {
// TODO(rjf): apparently some of the information here may end up being // TODO(rjf): apparently some of the information here may end up being
// redundant with "better" information from CV_SymKind_LOCAL record. // redundant with "better" information from CV_SymKind_LOCAL record.
@@ -3644,6 +3692,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: LTHREAD32/GTHREAD32 //- rjf: LTHREAD32/GTHREAD32
case CV_SymKind_LTHREAD32: case CV_SymKind_LTHREAD32:
case CV_SymKind_GTHREAD32: case CV_SymKind_GTHREAD32:
if(params->subset_flags & (RDIM_SubsetFlag_ThreadVariables|RDIM_SubsetFlag_ThreadVariableNameMap))
{ {
// rjf: unpack sym // rjf: unpack sym
CV_SymThread32 *thread32 = (CV_SymThread32 *)sym_header_struct_base; CV_SymThread32 *thread32 = (CV_SymThread32 *)sym_header_struct_base;
@@ -3680,6 +3729,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: LOCAL //- rjf: LOCAL
case CV_SymKind_LOCAL: case CV_SymKind_LOCAL:
if(params->subset_flags & (RDIM_SubsetFlag_Locals))
{ {
// rjf: no containing scope? -> malformed data; locals cannot be produced // rjf: no containing scope? -> malformed data; locals cannot be produced
// outside of a containing scope // outside of a containing scope
@@ -3926,6 +3976,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: INLINESITE //- rjf: INLINESITE
case CV_SymKind_INLINESITE: case CV_SymKind_INLINESITE:
if(params->subset_flags & (RDIM_SubsetFlag_Scopes))
{ {
// rjf: unpack sym // rjf: unpack sym
CV_SymInlineSite *sym = (CV_SymInlineSite *)sym_header_struct_base; CV_SymInlineSite *sym = (CV_SymInlineSite *)sym_header_struct_base;
@@ -4094,6 +4145,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
scratch_end(scratch); scratch_end(scratch);
} }
}
#undef p2r_type_ptr_from_itype #undef p2r_type_ptr_from_itype
} }
lane_sync(); lane_sync();
@@ -4190,7 +4242,7 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params)
//- rjf: build binary sections list //- rjf: build binary sections list
RDIM_BinarySectionList binary_sections = {0}; RDIM_BinarySectionList binary_sections = {0};
ProfScope("build binary section list") if(params->subset_flags & RDIM_SubsetFlag_BinarySections) ProfScope("build binary section list")
{ {
COFF_SectionHeader *coff_ptr = coff_sections.v; COFF_SectionHeader *coff_ptr = coff_sections.v;
COFF_SectionHeader *coff_opl = coff_ptr + coff_sections.count; COFF_SectionHeader *coff_opl = coff_ptr + coff_sections.count;