mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-16 09:02:22 -07:00
rdi: first pass of eliminating remainder of non-top-level sections; simplification/cleanup of rdi parsing layer
This commit is contained in:
+26
-33
@@ -2944,11 +2944,11 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_MachineID m
|
||||
// rjf: filename -> src_id
|
||||
U32 src_id = 0;
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_name_map_from_kind(rdi, RDI_NameMapKind_NormalSourcePaths);
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_NormalSourcePaths);
|
||||
if(mapptr != 0)
|
||||
{
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, mapptr, &map);
|
||||
rdi_parsed_from_name_map(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, filename_normalized.str, filename_normalized.size);
|
||||
if(node != 0)
|
||||
{
|
||||
@@ -2964,8 +2964,8 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_MachineID m
|
||||
|
||||
// rjf: src_id * pt -> push
|
||||
{
|
||||
RDI_SourceFile *src = rdi_element_from_idx(rdi, source_files, src_id);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, src->source_line_map_idx);
|
||||
RDI_SourceFile *src = rdi_element_from_name_idx(rdi, SourceFiles, src_id);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_name_idx(rdi, SourceLineMaps, src->source_line_map_idx);
|
||||
RDI_ParsedSourceLineMap line_map = {0};
|
||||
rdi_parsed_from_source_line_map(rdi, src_line_map, &line_map);
|
||||
U32 voff_count = 0;
|
||||
@@ -2984,26 +2984,20 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_MachineID m
|
||||
{
|
||||
String8 symbol_name = bp->string;
|
||||
U64 voff = bp->u64;
|
||||
if(rdi != 0 && rdi->procedures != 0)
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_parsed_from_name_map(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, symbol_name.str, symbol_name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Procedures);
|
||||
if(mapptr != 0)
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
for(U32 match_i = 0; match_i < id_count; match_i += 1)
|
||||
{
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, symbol_name.str, symbol_name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
for(U32 match_i = 0; match_i < id_count; match_i += 1)
|
||||
{
|
||||
U64 proc_voff = rdi_first_voff_from_proc(rdi, ids[match_i]);
|
||||
U64 proc_vaddr = proc_voff + base_vaddr;
|
||||
DMN_Trap trap = {process, proc_vaddr + voff, (U64)bp};
|
||||
dmn_trap_chunk_list_push(arena, traps_out, 256, &trap);
|
||||
}
|
||||
}
|
||||
U64 proc_voff = rdi_first_voff_from_proc_idx(rdi, ids[match_i]);
|
||||
U64 proc_vaddr = proc_voff + base_vaddr;
|
||||
DMN_Trap trap = {process, proc_vaddr + voff, (U64)bp};
|
||||
dmn_trap_chunk_list_push(arena, traps_out, 256, &trap);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
@@ -3446,11 +3440,10 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
||||
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
||||
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
|
||||
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, max_U64);
|
||||
RDI_NameMap *unparsed_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_GlobalVariables);
|
||||
if(rdi->global_variables != 0 && unparsed_map != 0)
|
||||
RDI_NameMap *unparsed_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
||||
{
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, unparsed_map, &map);
|
||||
rdi_parsed_from_name_map(rdi, unparsed_map, &map);
|
||||
String8 name = str8_lit("__asan_shadow_memory_dynamic_address");
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, name.str, name.size);
|
||||
if(node != 0)
|
||||
@@ -3459,7 +3452,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
if(id_count > 0)
|
||||
{
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_idx(rdi, global_variables, ids[0]);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, ids[0]);
|
||||
U64 global_var_voff = global_var->voff;
|
||||
U64 global_var_vaddr = global_var->voff + module->vaddr_range.min;
|
||||
Architecture arch = process->arch;
|
||||
@@ -4248,9 +4241,9 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
||||
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
|
||||
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, max_U64);
|
||||
RDI_NameMap *unparsed_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Procedures);
|
||||
RDI_NameMap *unparsed_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, unparsed_map, &map);
|
||||
rdi_parsed_from_name_map(rdi, unparsed_map, &map);
|
||||
|
||||
//- rjf: add traps for user-specified entry points on this message, if specified
|
||||
B32 entries_found = 0;
|
||||
@@ -4269,7 +4262,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
procedure_id = ids[0];
|
||||
}
|
||||
}
|
||||
U64 voff = rdi_first_voff_from_proc(rdi, procedure_id);
|
||||
U64 voff = rdi_first_voff_from_proc_idx(rdi, procedure_id);
|
||||
if(voff != 0)
|
||||
{
|
||||
entries_found = 1;
|
||||
@@ -4297,7 +4290,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
procedure_id = ids[0];
|
||||
}
|
||||
}
|
||||
U64 voff = rdi_first_voff_from_proc(rdi, procedure_id);
|
||||
U64 voff = rdi_first_voff_from_proc_idx(rdi, procedure_id);
|
||||
if(voff != 0)
|
||||
{
|
||||
entries_found = 1;
|
||||
@@ -4324,7 +4317,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
procedure_id = ids[0];
|
||||
}
|
||||
}
|
||||
U64 voff = rdi_first_voff_from_proc(rdi, procedure_id);
|
||||
U64 voff = rdi_first_voff_from_proc_idx(rdi, procedure_id);
|
||||
if(voff != 0)
|
||||
{
|
||||
DMN_Trap trap = {process->handle, module_base_vaddr + voff};
|
||||
@@ -4357,7 +4350,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
procedure_id = ids[0];
|
||||
}
|
||||
}
|
||||
U64 voff = rdi_first_voff_from_proc(rdi, procedure_id);
|
||||
U64 voff = rdi_first_voff_from_proc_idx(rdi, procedure_id);
|
||||
if(voff != 0)
|
||||
{
|
||||
entries_found = 1;
|
||||
@@ -4401,7 +4394,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
procedure_id = ids[0];
|
||||
}
|
||||
}
|
||||
U64 voff = rdi_first_voff_from_proc(rdi, procedure_id);
|
||||
U64 voff = rdi_first_voff_from_proc_idx(rdi, procedure_id);
|
||||
if(voff != 0)
|
||||
{
|
||||
entries_found = 1;
|
||||
|
||||
@@ -433,7 +433,7 @@ dasm_parse_thread__entry_point(void *p)
|
||||
ud_set_syntax(&udc, params.syntax == DASM_Syntax_Intel ? UD_SYN_INTEL : UD_SYN_ATT);
|
||||
|
||||
// rjf: disassemble
|
||||
RDI_SourceFile *last_file = &rdi_source_file_nil;
|
||||
RDI_SourceFile *last_file = &rdi_nil_element_union.source_file;
|
||||
RDI_Line *last_line = 0;
|
||||
for(U64 off = 0; off < data.size;)
|
||||
{
|
||||
@@ -455,16 +455,16 @@ dasm_parse_thread__entry_point(void *p)
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
{
|
||||
U64 voff = (params.vaddr+off) - params.base_vaddr;
|
||||
U32 unit_idx = rdi_vmap_idx_from_voff(rdi->unit_vmap, rdi->unit_vmap_count, voff);
|
||||
RDI_Unit *unit = rdi_element_from_idx(rdi, units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_idx(rdi, line_tables, unit->line_table_idx);
|
||||
U32 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, voff);
|
||||
RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx);
|
||||
RDI_ParsedLineTable unit_line_info = {0};
|
||||
rdi_parsed_from_line_table(rdi, line_table, &unit_line_info);
|
||||
U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, voff);
|
||||
if(line_info_idx < unit_line_info.count)
|
||||
{
|
||||
RDI_Line *line = &unit_line_info.lines[line_info_idx];
|
||||
RDI_SourceFile *file = rdi_element_from_idx(rdi, source_files, line->file_idx);
|
||||
RDI_SourceFile *file = rdi_element_from_name_idx(rdi, SourceFiles, line->file_idx);
|
||||
String8 file_normalized_full_path = {0};
|
||||
file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size);
|
||||
if(file != last_file)
|
||||
@@ -552,12 +552,12 @@ dasm_parse_thread__entry_point(void *p)
|
||||
String8 symbol_part = {0};
|
||||
if(jump_dst_vaddr != 0 && rdi != &di_rdi_parsed_nil && params.style_flags & DASM_StyleFlag_SymbolNames)
|
||||
{
|
||||
RDI_U32 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, jump_dst_vaddr-params.base_vaddr);
|
||||
RDI_U32 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, jump_dst_vaddr-params.base_vaddr);
|
||||
if(scope_idx != 0)
|
||||
{
|
||||
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, scope_idx);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
RDI_U32 procedure_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = rdi_element_from_idx(rdi, procedures, procedure_idx);
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, procedure_idx);
|
||||
String8 procedure_name = {0};
|
||||
procedure_name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &procedure_name.size);
|
||||
if(procedure_name.size != 0)
|
||||
|
||||
+1
-40
@@ -192,46 +192,7 @@ struct DI_Shared
|
||||
|
||||
global DI_Shared *di_shared = 0;
|
||||
thread_static DI_TCTX *di_tctx = 0;
|
||||
global RDI_Parsed di_rdi_parsed_nil =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
{0},
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&rdi_top_level_info_nil,
|
||||
&rdi_binary_section_nil, 1,
|
||||
&rdi_file_path_node_nil, 1,
|
||||
&rdi_source_file_nil, 1,
|
||||
&rdi_line_table_nil, 1,
|
||||
&rdi_source_line_map_nil, 1,
|
||||
&rdi_voff_nil, 1,
|
||||
&rdi_line_nil, 1,
|
||||
&rdi_column_nil, 1,
|
||||
&rdi_unit_nil, 1,
|
||||
&rdi_vmap_entry_nil, 1,
|
||||
&rdi_type_node_nil, 1,
|
||||
&rdi_udt_nil, 1,
|
||||
&rdi_member_nil, 1,
|
||||
&rdi_enum_member_nil, 1,
|
||||
&rdi_global_variable_nil, 1,
|
||||
&rdi_vmap_entry_nil, 1,
|
||||
&rdi_thread_variable_nil, 1,
|
||||
&rdi_procedure_nil, 1,
|
||||
&rdi_scope_nil, 1,
|
||||
&rdi_voff_nil, 1,
|
||||
&rdi_vmap_entry_nil, 1,
|
||||
&rdi_local_nil, 1,
|
||||
&rdi_location_block_nil, 1,
|
||||
0, 0,
|
||||
0, 0,
|
||||
};
|
||||
global RDI_Parsed di_rdi_parsed_nil = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Basic Helpers
|
||||
|
||||
+53
-60
@@ -3168,20 +3168,20 @@ df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
DI_Scope *scope = di_scope_open();
|
||||
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 0);
|
||||
if(result.size == 0 && rdi->scope_vmap != 0)
|
||||
if(result.size == 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, scope_idx);
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = &rdi->procedures[proc_idx];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||
result = push_str8_copy(arena, str8(name_ptr, name_size));
|
||||
}
|
||||
if(result.size == 0 && rdi->global_vmap != 0)
|
||||
if(result.size == 0)
|
||||
{
|
||||
U64 global_idx = rdi_vmap_idx_from_voff(rdi->global_vmap, rdi->global_vmap_count, voff);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_idx(rdi, global_variables, global_idx);
|
||||
U64 global_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_GlobalVMap, voff);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, global_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(rdi, global_var->name_string_idx, &name_size);
|
||||
result = push_str8_copy(arena, str8(name_ptr, name_size));
|
||||
@@ -3239,21 +3239,18 @@ df_text_line_src2dasm_info_list_array_from_src_line_range(Arena *arena, DF_Entit
|
||||
U32 src_id = 0;
|
||||
if(rdi != &di_rdi_parsed_nil)
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_name_map_from_kind(rdi, RDI_NameMapKind_NormalSourcePaths);
|
||||
if(mapptr != 0)
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_NormalSourcePaths);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_parsed_from_name_map(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, file_path_normalized.str, file_path_normalized.size);
|
||||
if(node != 0)
|
||||
{
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, file_path_normalized.str, file_path_normalized.size);
|
||||
if(node != 0)
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
if(id_count > 0)
|
||||
{
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
if(id_count > 0)
|
||||
{
|
||||
good_src_id = 1;
|
||||
src_id = ids[0];
|
||||
}
|
||||
good_src_id = 1;
|
||||
src_id = ids[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3261,8 +3258,8 @@ df_text_line_src2dasm_info_list_array_from_src_line_range(Arena *arena, DF_Entit
|
||||
// rjf: good src-id -> look up line info for visible range
|
||||
if(good_src_id)
|
||||
{
|
||||
RDI_SourceFile *src = rdi->source_files+src_id;
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, src->source_line_map_idx);
|
||||
RDI_SourceFile *src = rdi_element_from_name_idx(rdi, SourceFiles, src_id);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_name_idx(rdi, SourceLineMaps, src->source_line_map_idx);
|
||||
RDI_ParsedSourceLineMap line_map = {0};
|
||||
rdi_parsed_from_source_line_map(rdi, src_line_map, &line_map);
|
||||
U64 line_idx = 0;
|
||||
@@ -3276,9 +3273,9 @@ df_text_line_src2dasm_info_list_array_from_src_line_range(Arena *arena, DF_Entit
|
||||
for(U64 idx = 0; idx < voff_count; idx += 1)
|
||||
{
|
||||
U64 base_voff = voffs[idx];
|
||||
U64 unit_idx = rdi_vmap_idx_from_voff(rdi->unit_vmap, rdi->unit_vmap_count, base_voff);
|
||||
RDI_Unit *unit = rdi_element_from_idx(rdi, units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_idx(rdi, line_tables, unit->line_table_idx);
|
||||
U64 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, base_voff);
|
||||
RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx);
|
||||
RDI_ParsedLineTable unit_line_info = {0};
|
||||
rdi_parsed_from_line_table(rdi, line_table, &unit_line_info);
|
||||
U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, base_voff);
|
||||
@@ -3319,11 +3316,10 @@ df_text_line_dasm2src_info_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
|
||||
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 0);
|
||||
DF_TextLineDasm2SrcInfo result = {0};
|
||||
result.file = &df_g_nil_entity;
|
||||
if(rdi->unit_vmap != 0 && rdi->units != 0 && rdi->source_files != 0)
|
||||
{
|
||||
U64 unit_idx = rdi_vmap_idx_from_voff(rdi->unit_vmap, rdi->unit_vmap_count, voff);
|
||||
RDI_Unit *unit = rdi_element_from_idx(rdi, units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_idx(rdi, line_tables, unit->line_table_idx);
|
||||
U64 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, voff);
|
||||
RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx);
|
||||
RDI_ParsedLineTable unit_line_info = {0};
|
||||
rdi_parsed_from_line_table(rdi, line_table, &unit_line_info);
|
||||
U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, voff);
|
||||
@@ -3331,7 +3327,7 @@ df_text_line_dasm2src_info_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff)
|
||||
{
|
||||
RDI_Line *line = &unit_line_info.lines[line_info_idx];
|
||||
RDI_Column *column = (line_info_idx < unit_line_info.col_count) ? &unit_line_info.cols[line_info_idx] : 0;
|
||||
RDI_SourceFile *file = rdi_element_from_idx(rdi, source_files, line->file_idx);
|
||||
RDI_SourceFile *file = rdi_element_from_name_idx(rdi, SourceFiles, line->file_idx);
|
||||
String8 file_normalized_full_path = {0};
|
||||
file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size);
|
||||
MemoryCopyStruct(&result.dbgi_key, dbgi_key);
|
||||
@@ -3371,9 +3367,9 @@ df_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name)
|
||||
name_map_kind_idx += 1)
|
||||
{
|
||||
RDI_NameMapKind name_map_kind = name_map_kinds[name_map_kind_idx];
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdi, name_map_kind);
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, name_map_kind);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(rdi, name_map, &parsed_name_map);
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, symbol_name.str, symbol_name.size);
|
||||
|
||||
// rjf: node -> num
|
||||
@@ -3405,14 +3401,14 @@ df_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name)
|
||||
default:{}break;
|
||||
case RDI_NameMapKind_GlobalVariables:
|
||||
{
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_idx(rdi, global_variables, entity_num-1);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, entity_num-1);
|
||||
voff = global_var->voff;
|
||||
}break;
|
||||
case RDI_NameMapKind_Procedures:
|
||||
{
|
||||
RDI_Procedure *procedure = rdi_element_from_idx(rdi, procedures, entity_num-1);
|
||||
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, procedure->root_scope_idx);
|
||||
voff = rdi->scope_voffs[scope->voff_range_first];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, entity_num-1);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
|
||||
voff = *rdi_element_from_name_idx(rdi, ScopeVOffData, scope->voff_range_first);
|
||||
}break;
|
||||
}
|
||||
|
||||
@@ -3439,9 +3435,9 @@ df_type_num_from_dbgi_key_name(DI_Key *dbgi_key, String8 name)
|
||||
U64 result = 0;
|
||||
{
|
||||
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 0);
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Types);
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Types);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(rdi, name_map, &parsed_name_map);
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, name.str, name.size);
|
||||
U64 entity_num = 0;
|
||||
if(node != 0)
|
||||
@@ -3928,21 +3924,18 @@ df_eval_parse_ctx_from_src_loc(DI_Scope *scope, DF_Entity *file, TxtPt pt)
|
||||
B32 good_src_id = 0;
|
||||
U32 src_id = 0;
|
||||
{
|
||||
RDI_NameMap *mapptr = rdi_name_map_from_kind(rdi, RDI_NameMapKind_NormalSourcePaths);
|
||||
if(mapptr != 0)
|
||||
RDI_NameMap *mapptr = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_NormalSourcePaths);
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_parsed_from_name_map(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, file_path_normalized.str, file_path_normalized.size);
|
||||
if(node != 0)
|
||||
{
|
||||
RDI_ParsedNameMap map = {0};
|
||||
rdi_name_map_parse(rdi, mapptr, &map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &map, file_path_normalized.str, file_path_normalized.size);
|
||||
if(node != 0)
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
if(id_count > 0)
|
||||
{
|
||||
U32 id_count = 0;
|
||||
U32 *ids = rdi_matches_from_map_node(rdi, node, &id_count);
|
||||
if(id_count > 0)
|
||||
{
|
||||
good_src_id = 1;
|
||||
src_id = ids[0];
|
||||
}
|
||||
good_src_id = 1;
|
||||
src_id = ids[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3950,8 +3943,8 @@ df_eval_parse_ctx_from_src_loc(DI_Scope *scope, DF_Entity *file, TxtPt pt)
|
||||
// rjf: good src-id -> look up line info for visible range
|
||||
if(good_src_id)
|
||||
{
|
||||
RDI_SourceFile *src = rdi->source_files+src_id;
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, src->source_line_map_idx);
|
||||
RDI_SourceFile *src = rdi_element_from_name_idx(rdi, SourceFiles, src_id);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_name_idx(rdi, SourceLineMaps, src->source_line_map_idx);
|
||||
RDI_ParsedSourceLineMap line_map = {0};
|
||||
rdi_parsed_from_source_line_map(rdi, src_line_map, &line_map);
|
||||
U32 voff_count = 0;
|
||||
@@ -3959,9 +3952,9 @@ df_eval_parse_ctx_from_src_loc(DI_Scope *scope, DF_Entity *file, TxtPt pt)
|
||||
for(U64 idx = 0; idx < voff_count; idx += 1)
|
||||
{
|
||||
U64 base_voff = voffs[idx];
|
||||
U64 unit_idx = rdi_vmap_idx_from_voff(rdi->unit_vmap, rdi->unit_vmap_count, base_voff);
|
||||
RDI_Unit *unit = rdi_element_from_idx(rdi, units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_idx(rdi, line_tables, unit->line_table_idx);
|
||||
U64 unit_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_UnitVMap, base_voff);
|
||||
RDI_Unit *unit = rdi_element_from_name_idx(rdi, Units, unit_idx);
|
||||
RDI_LineTable *line_table = rdi_element_from_name_idx(rdi, LineTables, unit->line_table_idx);
|
||||
RDI_ParsedLineTable unit_line_info = {0};
|
||||
rdi_parsed_from_line_table(rdi, line_table, &unit_line_info);
|
||||
U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, base_voff);
|
||||
@@ -4270,12 +4263,12 @@ df_dynamically_typed_eval_from_eval(TG_Graph *graph, RDI_Parsed *rdi, DF_CtrlCtx
|
||||
U64 vtable_vaddr = 0;
|
||||
MemoryCopy(&vtable_vaddr, vtable_base_ptr_memory.str, addr_size);
|
||||
U64 vtable_voff = df_voff_from_vaddr(module, vtable_vaddr);
|
||||
U64 global_idx = rdi_vmap_idx_from_voff(rdi->global_vmap, rdi->global_vmap_count, vtable_voff);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_idx(rdi, global_variables, global_idx);
|
||||
U64 global_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_GlobalVMap, vtable_voff);
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, global_idx);
|
||||
if(global_var->link_flags & RDI_LinkFlag_TypeScoped)
|
||||
{
|
||||
RDI_UDT *udt = rdi_element_from_idx(rdi, udts, global_var->container_idx);
|
||||
RDI_TypeNode *type = rdi_element_from_idx(rdi, type_nodes, udt->self_type_idx);
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, global_var->container_idx);
|
||||
RDI_TypeNode *type = rdi_element_from_name_idx(rdi, TypeNodes, udt->self_type_idx);
|
||||
TG_Key derived_type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type->kind), (U64)udt->self_type_idx);
|
||||
TG_Key ptr_to_derived_type_key = tg_cons_type_make(graph, TG_Kind_Ptr, derived_type_key, 0);
|
||||
eval.type_key = ptr_to_derived_type_key;
|
||||
|
||||
+21
-15
@@ -3272,8 +3272,10 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
{
|
||||
for(U64 idx = 0; idx < rdis_count; idx += 1)
|
||||
{
|
||||
rdis[idx] = di_rdi_from_key(di_scope, &dbgi_keys.v[idx], endt_us);
|
||||
graphs[idx] = tg_graph_begin(rdi_addr_size_from_arch(rdis[idx]->top_level_info->arch), 256);
|
||||
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_keys.v[idx], endt_us);
|
||||
RDI_TopLevelInfo *tli = rdi_element_from_name_idx(rdi, TopLevelInfo, 0);
|
||||
rdis[idx] = rdi;
|
||||
graphs[idx] = tg_graph_begin(rdi_addr_size_from_arch(tli->arch), 256);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3302,9 +3304,11 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1)
|
||||
{
|
||||
RDI_Parsed *rdi = rdis[rdi_idx];
|
||||
if(base_idx <= item->idx && item->idx < base_idx + rdi->procedures_count)
|
||||
U64 rdi_procedures_count = 0;
|
||||
rdi_section_raw_table_from_kind(rdi, RDI_SectionKind_Procedures, &rdi_procedures_count);
|
||||
if(base_idx <= item->idx && item->idx < base_idx + rdi_procedures_count)
|
||||
{
|
||||
RDI_Procedure *procedure = rdi_element_from_idx(rdi, procedures, item->idx-base_idx);
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, item->idx-base_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||
String8 name = str8(name_base, name_size);
|
||||
@@ -3317,7 +3321,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
}
|
||||
break;
|
||||
}
|
||||
base_idx += rdi->procedures_count;
|
||||
base_idx += rdi_procedures_count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3360,23 +3364,25 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
||||
{
|
||||
for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1)
|
||||
{
|
||||
if(base_idx <= item->idx && item->idx < base_idx + rdis[rdi_idx]->procedures_count)
|
||||
U64 procedures_count = 0;
|
||||
rdi_section_raw_table_from_kind(rdis[rdi_idx], RDI_SectionKind_Procedures, &procedures_count);
|
||||
if(base_idx <= item->idx && item->idx < base_idx + procedures_count)
|
||||
{
|
||||
dbgi_key = dbgi_keys.v[rdi_idx];
|
||||
rdi = rdis[rdi_idx];
|
||||
graph = graphs[rdi_idx];
|
||||
break;
|
||||
}
|
||||
base_idx += rdis[rdi_idx]->procedures_count;
|
||||
base_idx += procedures_count;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: unpack this item's info
|
||||
RDI_Procedure *procedure = rdi_element_from_idx(rdi, procedures, item->idx-base_idx);
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, item->idx-base_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||
String8 name = str8(name_base, name_size);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, procedure->type_idx);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, procedure->type_idx);
|
||||
TG_Key type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), procedure->type_idx);
|
||||
|
||||
//- rjf: build item button
|
||||
@@ -4926,17 +4932,17 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
|
||||
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 0);
|
||||
String8 symbol_name = {0};
|
||||
String8 symbol_type_string = {0};
|
||||
if(rdi->scope_vmap != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, rip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, scope_idx);
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, rip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = &rdi->procedures[proc_idx];
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, procedure->type_idx);
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, procedure->type_idx);
|
||||
TG_Key type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), procedure->type_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||
TG_Graph *graph = tg_graph_begin(rdi_addr_size_from_arch(rdi->top_level_info->arch), 256);
|
||||
RDI_TopLevelInfo *top_level_info = rdi_element_from_name_idx(rdi, TopLevelInfo, 0);
|
||||
TG_Graph *graph = tg_graph_begin(rdi_addr_size_from_arch(top_level_info->arch), 256);
|
||||
symbol_name = str8(name_ptr, name_size);
|
||||
symbol_type_string = tg_string_from_key(scratch.arena, graph, rdi, type_key);
|
||||
}
|
||||
|
||||
+115
-155
@@ -73,10 +73,9 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
@@ -84,10 +83,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
}
|
||||
|
||||
//- rjf: voff-1 -> scope
|
||||
if(voff > 0 && rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
if(voff > 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff-1);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff-1);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
if(scope != tightest_scope)
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
@@ -99,9 +98,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
//- rjf: tightest scope -> walk up the tree & build tasks for each parent scope
|
||||
if(tightest_scope != 0)
|
||||
{
|
||||
for(RDI_Scope *scope = &rdi->scopes[tightest_scope->parent_scope_idx];
|
||||
scope != 0 && scope != &rdi->scopes[0];
|
||||
scope = &rdi->scopes[scope->parent_scope_idx])
|
||||
RDI_Scope *nil_scope = rdi_element_from_name_idx(rdi, Scopes, 0);
|
||||
for(RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, tightest_scope->parent_scope_idx);
|
||||
scope != 0 && scope != nil_scope;
|
||||
scope = rdi_element_from_name_idx(rdi, Scopes, scope->parent_scope_idx))
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
@@ -122,7 +122,7 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
U32 local_opl_idx = scope->local_first + scope->local_count;
|
||||
for(U32 local_idx = scope->local_first; local_idx < local_opl_idx; local_idx += 1)
|
||||
{
|
||||
RDI_Local *local_var = &rdi->locals[local_idx];
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(rdi, Locals, local_idx);
|
||||
U64 local_name_size = 0;
|
||||
U8 *local_name_str = rdi_string_from_idx(rdi, local_var->name_string_idx, &local_name_size);
|
||||
String8 name = push_str8_copy(arena, str8(local_name_str, local_name_size));
|
||||
@@ -139,52 +139,30 @@ internal EVAL_String2NumMap *
|
||||
eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
{
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
tightest_scope = &rdi->scopes[scope_idx];
|
||||
}
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
|
||||
RDI_Scope *tightest_scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
|
||||
//- rjf: tightest scope -> procedure
|
||||
RDI_Procedure *procedure = 0;
|
||||
if(tightest_scope != 0 && rdi->procedures != 0)
|
||||
{
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
if(0 < proc_idx && proc_idx < rdi->procedures_count)
|
||||
{
|
||||
procedure = &rdi->procedures[proc_idx];
|
||||
}
|
||||
}
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||
|
||||
//- rjf: procedure -> udt
|
||||
RDI_UDT *udt = 0;
|
||||
if(procedure != 0 && rdi->udts != 0 && procedure->link_flags & RDI_LinkFlag_TypeScoped)
|
||||
{
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
if(0 < udt_idx && udt_idx < rdi->udts_count)
|
||||
{
|
||||
udt = &rdi->udts[udt_idx];
|
||||
}
|
||||
}
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, udt_idx);
|
||||
|
||||
//- rjf: build blank map
|
||||
EVAL_String2NumMap *map = push_array(arena, EVAL_String2NumMap, 1);
|
||||
*map = eval_string2num_map_make(arena, 64);
|
||||
|
||||
//- rjf: udt -> fill member map
|
||||
if(udt != 0 && !(udt->flags & RDI_UDTFlag_EnumMembers) && rdi->members != 0)
|
||||
if(!(udt->flags & RDI_UDTFlag_EnumMembers))
|
||||
{
|
||||
U64 data_member_num = 1;
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
if(member_idx < 1 || rdi->members_count <= member_idx)
|
||||
{
|
||||
break;
|
||||
}
|
||||
RDI_Member *m = &rdi->members[member_idx];
|
||||
RDI_Member *m = rdi_element_from_name_idx(rdi, Members, member_idx);
|
||||
if(m->kind == RDI_MemberKind_DataField)
|
||||
{
|
||||
String8 name = {0};
|
||||
@@ -476,11 +454,10 @@ eval_leaf_type_from_name(RDI_Parsed *rdi, String8 name)
|
||||
{
|
||||
TG_Key key = zero_struct;
|
||||
B32 found = 0;
|
||||
if(rdi->type_nodes != 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Types);
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Types);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(rdi, name_map, &parsed_name_map);
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, name.str, name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
@@ -488,7 +465,7 @@ eval_leaf_type_from_name(RDI_Parsed *rdi, String8 name)
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &match_count);
|
||||
if(match_count != 0)
|
||||
{
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, matches[0]);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, matches[0]);
|
||||
found = type_node->kind != RDI_TypeKind_NULL;
|
||||
key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)matches[0]);
|
||||
}
|
||||
@@ -838,12 +815,11 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
|
||||
//- rjf: form namespaceified fallback versions of this lookup string
|
||||
String8List namespaceified_token_strings = {0};
|
||||
if(ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_vmap != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(ctx->rdi->scope_vmap, ctx->rdi->scope_vmap_count, ctx->ip_voff);
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(ctx->rdi, RDI_SectionKind_ScopeVMap, ctx->ip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(ctx->rdi, Scopes, scope_idx);
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[proc_idx];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(ctx->rdi, Procedures, proc_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(ctx->rdi, procedure->name_string_idx, &name_size);
|
||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||
@@ -883,8 +859,8 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||
RDI_Local *local_var = rdi_element_from_idx(ctx->rdi, locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(ctx->rdi, type_nodes, local_var->type_idx);
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(ctx->rdi, Locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, local_var->type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)local_var->type_idx);
|
||||
|
||||
// rjf: grab location info
|
||||
@@ -892,19 +868,21 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
loc_block_idx < local_var->location_opl;
|
||||
loc_block_idx += 1)
|
||||
{
|
||||
RDI_LocationBlock *block = &ctx->rdi->location_blocks[loc_block_idx];
|
||||
RDI_LocationBlock *block = rdi_element_from_name_idx(ctx->rdi, LocationBlocks, loc_block_idx);
|
||||
if(block->scope_off_first <= ctx->ip_voff && ctx->ip_voff < block->scope_off_opl)
|
||||
{
|
||||
loc_kind = *((RDI_LocationKind *)(ctx->rdi->location_data + block->location_data_off));
|
||||
U64 all_location_data_size = 0;
|
||||
U8 *all_location_data = rdi_table_from_name(ctx->rdi, LocationData, &all_location_data_size);
|
||||
loc_kind = *((RDI_LocationKind *)(all_location_data + block->location_data_off));
|
||||
switch(loc_kind)
|
||||
{
|
||||
default:{mapped_identifier = 0;}break;
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
U8 *bytecode_base = ctx->rdi->location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U8 *bytecode_base = all_location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U64 bytecode_size = 0;
|
||||
for(U64 idx = 0; idx < ctx->rdi->location_data_size; idx += 1)
|
||||
for(U64 idx = 0; idx < all_location_data_size; idx += 1)
|
||||
{
|
||||
U8 op = bytecode_base[idx];
|
||||
if(op == 0)
|
||||
@@ -920,11 +898,11 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
case RDI_LocationKind_AddrRegPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||
{
|
||||
MemoryCopy(&loc_reg_u16, (ctx->rdi->location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
MemoryCopy(&loc_reg_u16, (all_location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
}break;
|
||||
case RDI_LocationKind_ValReg:
|
||||
{
|
||||
MemoryCopy(&loc_reg, (ctx->rdi->location_data + block->location_data_off), sizeof(loc_reg));
|
||||
MemoryCopy(&loc_reg, (all_location_data + block->location_data_off), sizeof(loc_reg));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
@@ -959,120 +937,102 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try global variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_GlobalVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
// NOTE(rjf): apparently, PDBs can be produced such that they
|
||||
// also keep stale *GLOBAL VARIABLE SYMBOLS* around too. I
|
||||
// don't know of a magic hash table fixup path in PDBs, so
|
||||
// in this case, I'm going to prefer the latest-added global.
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = &ctx->rdi->global_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
// NOTE(rjf): apparently, PDBs can be produced such that they
|
||||
// also keep stale *GLOBAL VARIABLE SYMBOLS* around too. I
|
||||
// don't know of a magic hash table fixup path in PDBs, so
|
||||
// in this case, I'm going to prefer the latest-added global.
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(ctx->rdi, GlobalVariables, match_idx);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try thread variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_ThreadVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_ThreadVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = &ctx->rdi->thread_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = rdi_element_from_name_idx(ctx->rdi, ThreadVariables, match_idx);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try procedures
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_Procedures);
|
||||
if(name_map != 0 && ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_voffs)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[match_idx];
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[procedure->root_scope_idx];
|
||||
U64 voff = ctx->rdi->scope_voffs[scope->voff_range_first];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(ctx->rdi, Procedures, match_idx);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(ctx->rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(ctx->rdi, ScopeVOffData, scope->voff_range_first);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,29 +52,29 @@ fzy_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, FZY_Target target,
|
||||
// NOTE(rjf): no default - warn if we miss a case
|
||||
case FZY_Target_Procedures:
|
||||
{
|
||||
RDI_Procedure *proc = rdi_element_from_idx(rdi, procedures, element_idx);
|
||||
RDI_Procedure *proc = rdi_element_from_name_idx(rdi, Procedures, element_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, proc->name_string_idx, &name_size);
|
||||
result = str8(name_base, name_size);
|
||||
}break;
|
||||
case FZY_Target_GlobalVariables:
|
||||
{
|
||||
RDI_GlobalVariable *gvar = rdi_element_from_idx(rdi, global_variables, element_idx);
|
||||
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(rdi, GlobalVariables, element_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, gvar->name_string_idx, &name_size);
|
||||
result = str8(name_base, name_size);
|
||||
}break;
|
||||
case FZY_Target_ThreadVariables:
|
||||
{
|
||||
RDI_ThreadVariable *tvar = rdi_element_from_idx(rdi, thread_variables, element_idx);
|
||||
RDI_ThreadVariable *tvar = rdi_element_from_name_idx(rdi, ThreadVariables, element_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, tvar->name_string_idx, &name_size);
|
||||
result = str8(name_base, name_size);
|
||||
}break;
|
||||
case FZY_Target_UDTs:
|
||||
{
|
||||
RDI_UDT *udt = rdi_element_from_idx(rdi, udts, element_idx);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, udt->self_type_idx);
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, element_idx);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, udt->self_type_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_base = rdi_string_from_idx(rdi, type_node->user_defined.name_string_idx, &name_size);
|
||||
result = str8(name_base, name_size);
|
||||
@@ -407,10 +407,8 @@ fzy_search_thread__entry_point(void *p)
|
||||
////////////////////////////
|
||||
//- rjf: search target -> info about search space
|
||||
//
|
||||
U64 table_ptr_off = 0;
|
||||
U64 table_count_off = 0;
|
||||
RDI_SectionKind section_kind = RDI_SectionKind_NULL;
|
||||
U64 element_name_idx_off = 0;
|
||||
U64 element_size = 0;
|
||||
if(task_is_good)
|
||||
{
|
||||
switch(params.target)
|
||||
@@ -419,30 +417,22 @@ fzy_search_thread__entry_point(void *p)
|
||||
case FZY_Target_COUNT:{}break;
|
||||
case FZY_Target_Procedures:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RDI_Parsed, procedures);
|
||||
table_count_off = OffsetOf(RDI_Parsed, procedures_count);
|
||||
section_kind = RDI_SectionKind_Procedures;
|
||||
element_name_idx_off = OffsetOf(RDI_Procedure, name_string_idx);
|
||||
element_size = sizeof(RDI_Procedure);
|
||||
}break;
|
||||
case FZY_Target_GlobalVariables:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RDI_Parsed, global_variables);
|
||||
table_count_off = OffsetOf(RDI_Parsed, global_variables_count);
|
||||
section_kind = RDI_SectionKind_GlobalVariables;
|
||||
element_name_idx_off = OffsetOf(RDI_GlobalVariable, name_string_idx);
|
||||
element_size = sizeof(RDI_GlobalVariable);
|
||||
}break;
|
||||
case FZY_Target_ThreadVariables:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RDI_Parsed, thread_variables);
|
||||
table_count_off = OffsetOf(RDI_Parsed, thread_variables_count);
|
||||
section_kind = RDI_SectionKind_ThreadVariables;
|
||||
element_name_idx_off = OffsetOf(RDI_ThreadVariable, name_string_idx);
|
||||
element_size = sizeof(RDI_ThreadVariable);
|
||||
}break;
|
||||
case FZY_Target_UDTs:
|
||||
{
|
||||
table_ptr_off = OffsetOf(RDI_Parsed, udts);
|
||||
table_count_off = OffsetOf(RDI_Parsed, udts_count);
|
||||
element_size = sizeof(RDI_UDT);
|
||||
section_kind = RDI_SectionKind_UDTs;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
@@ -457,8 +447,9 @@ fzy_search_thread__entry_point(void *p)
|
||||
for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1)
|
||||
{
|
||||
RDI_Parsed *rdi = rdis[rdi_idx];
|
||||
void *table_base = (U8*)rdi + table_ptr_off;
|
||||
U64 element_count = *MemberFromOffset(U64 *, rdi, table_count_off);
|
||||
U64 element_count = 0;
|
||||
void *table_base = rdi_section_raw_table_from_kind(rdi, section_kind, &element_count);
|
||||
U64 element_size = rdi_section_element_size_table[section_kind];
|
||||
for(U64 idx = 1; task_is_good && idx < element_count; idx += 1)
|
||||
{
|
||||
void *element = (U8 *)(*(void **)table_base) + element_size*idx;
|
||||
@@ -466,7 +457,7 @@ fzy_search_thread__entry_point(void *p)
|
||||
if(params.target == FZY_Target_UDTs)
|
||||
{
|
||||
RDI_UDT *udt = (RDI_UDT *)element;
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, udt->self_type_idx);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, udt->self_type_idx);
|
||||
name_idx_ptr = &type_node->user_defined.name_string_idx;
|
||||
}
|
||||
U32 name_idx = *name_idx_ptr;
|
||||
|
||||
@@ -10,6 +10,88 @@
|
||||
#ifndef RDI_FORMAT_C
|
||||
#define RDI_FORMAT_C
|
||||
|
||||
RDI_U16 rdi_section_element_size_table[37] =
|
||||
{
|
||||
sizeof(RDI_U8),
|
||||
sizeof(RDI_TopLevelInfo),
|
||||
sizeof(RDI_U8),
|
||||
sizeof(RDI_U32),
|
||||
sizeof(RDI_U32),
|
||||
sizeof(RDI_BinarySection),
|
||||
sizeof(RDI_FilePathNode),
|
||||
sizeof(RDI_SourceFile),
|
||||
sizeof(RDI_LineTable),
|
||||
sizeof(RDI_U64),
|
||||
sizeof(RDI_Line),
|
||||
sizeof(RDI_Column),
|
||||
sizeof(RDI_SourceLineMap),
|
||||
sizeof(RDI_U32),
|
||||
sizeof(RDI_U32),
|
||||
sizeof(RDI_U64),
|
||||
sizeof(RDI_Unit),
|
||||
sizeof(RDI_VMapEntry),
|
||||
sizeof(RDI_TypeNode),
|
||||
sizeof(RDI_UDT),
|
||||
sizeof(RDI_Member),
|
||||
sizeof(RDI_EnumMember),
|
||||
sizeof(RDI_GlobalVariable),
|
||||
sizeof(RDI_VMapEntry),
|
||||
sizeof(RDI_ThreadVariable),
|
||||
sizeof(RDI_Procedure),
|
||||
sizeof(RDI_Scope),
|
||||
sizeof(RDI_U64),
|
||||
sizeof(RDI_VMapEntry),
|
||||
sizeof(RDI_InlineSite),
|
||||
sizeof(RDI_Local),
|
||||
sizeof(RDI_LocationBlock),
|
||||
sizeof(RDI_U8),
|
||||
sizeof(RDI_NameMap),
|
||||
sizeof(RDI_NameMapBucket),
|
||||
sizeof(RDI_NameMapNode),
|
||||
sizeof(RDI_U8),
|
||||
};
|
||||
|
||||
RDI_U8 rdi_section_is_required_table[37] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
RDI_U8 rdi_eval_op_ctrlbits_table[45] =
|
||||
{
|
||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||
|
||||
+219
-102
@@ -40,65 +40,71 @@ typedef int32_t RDI_S32;
|
||||
typedef int64_t RDI_S64;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//~ Overridable Enabling/Disabling Of Table Index Typechecking
|
||||
|
||||
#if !defined(RDI_DISABLE_TABLE_INDEX_TYPECHECKING)
|
||||
# define RDI_DISABLE_TABLE_INDEX_TYPECHECKING 0
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//~ Format Constants
|
||||
|
||||
// \"raddbg\0\0\"
|
||||
#define RDI_MAGIC_CONSTANT 0x0000676264646172
|
||||
#define RDI_ENCODING_VERSION 3
|
||||
#define RDI_ENCODING_VERSION 4
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//~ Format Types & Functions
|
||||
|
||||
typedef RDI_U32 RDI_DataSectionTag;
|
||||
typedef enum RDI_DataSectionTagEnum
|
||||
typedef RDI_U32 RDI_SectionKind;
|
||||
typedef enum RDI_SectionKindEnum
|
||||
{
|
||||
RDI_DataSectionTag_NULL = 0x0000,
|
||||
RDI_DataSectionTag_TopLevelInfo = 0x0001,
|
||||
RDI_DataSectionTag_StringData = 0x0002,
|
||||
RDI_DataSectionTag_StringTable = 0x0003,
|
||||
RDI_DataSectionTag_IndexRuns = 0x0004,
|
||||
RDI_DataSectionTag_BinarySections = 0x0005,
|
||||
RDI_DataSectionTag_FilePathNodes = 0x0006,
|
||||
RDI_DataSectionTag_SourceFiles = 0x0007,
|
||||
RDI_DataSectionTag_LineTables = 0x0008,
|
||||
RDI_DataSectionTag_LineInfoVoffs = 0x0009,
|
||||
RDI_DataSectionTag_LineInfoLines = 0x000A,
|
||||
RDI_DataSectionTag_LineInfoColumns = 0x000B,
|
||||
RDI_DataSectionTag_SourceLineMaps = 0x000C,
|
||||
RDI_DataSectionTag_SourceLineMapNumbers = 0x000D,
|
||||
RDI_DataSectionTag_SourceLineMapRanges = 0x000E,
|
||||
RDI_DataSectionTag_SourceLineMapVOffs = 0x000F,
|
||||
RDI_DataSectionTag_Units = 0x0010,
|
||||
RDI_DataSectionTag_UnitVmap = 0x0011,
|
||||
RDI_DataSectionTag_TypeNodes = 0x0012,
|
||||
RDI_DataSectionTag_UDTs = 0x0013,
|
||||
RDI_DataSectionTag_Members = 0x0014,
|
||||
RDI_DataSectionTag_EnumMembers = 0x0015,
|
||||
RDI_DataSectionTag_GlobalVariables = 0x0016,
|
||||
RDI_DataSectionTag_GlobalVmap = 0x0017,
|
||||
RDI_DataSectionTag_ThreadVariables = 0x0018,
|
||||
RDI_DataSectionTag_Procedures = 0x0019,
|
||||
RDI_DataSectionTag_Scopes = 0x001A,
|
||||
RDI_DataSectionTag_ScopeVoffData = 0x001B,
|
||||
RDI_DataSectionTag_ScopeVmap = 0x001C,
|
||||
RDI_DataSectionTag_InlineSites = 0x001D,
|
||||
RDI_DataSectionTag_Locals = 0x001E,
|
||||
RDI_DataSectionTag_LocationBlocks = 0x001F,
|
||||
RDI_DataSectionTag_LocationData = 0x0020,
|
||||
RDI_DataSectionTag_NameMaps = 0x0021,
|
||||
RDI_DataSectionTag_PRIMARY_COUNT = 0x0022,
|
||||
RDI_DataSectionTag_SECONDARY = 0x80000000,
|
||||
RDI_DataSectionTag_NameMapBuckets = RDI_DataSectionTag_SECONDARY|0x0001,
|
||||
RDI_DataSectionTag_NameMapNodes = RDI_DataSectionTag_SECONDARY|0x0002,
|
||||
} RDI_DataSectionTagEnum;
|
||||
RDI_SectionKind_NULL = 0x0000,
|
||||
RDI_SectionKind_TopLevelInfo = 0x0001,
|
||||
RDI_SectionKind_StringData = 0x0002,
|
||||
RDI_SectionKind_StringTable = 0x0003,
|
||||
RDI_SectionKind_IndexRuns = 0x0004,
|
||||
RDI_SectionKind_BinarySections = 0x0005,
|
||||
RDI_SectionKind_FilePathNodes = 0x0006,
|
||||
RDI_SectionKind_SourceFiles = 0x0007,
|
||||
RDI_SectionKind_LineTables = 0x0008,
|
||||
RDI_SectionKind_LineInfoVOffs = 0x0009,
|
||||
RDI_SectionKind_LineInfoLines = 0x000A,
|
||||
RDI_SectionKind_LineInfoColumns = 0x000B,
|
||||
RDI_SectionKind_SourceLineMaps = 0x000C,
|
||||
RDI_SectionKind_SourceLineMapNumbers = 0x000D,
|
||||
RDI_SectionKind_SourceLineMapRanges = 0x000E,
|
||||
RDI_SectionKind_SourceLineMapVOffs = 0x000F,
|
||||
RDI_SectionKind_Units = 0x0010,
|
||||
RDI_SectionKind_UnitVMap = 0x0011,
|
||||
RDI_SectionKind_TypeNodes = 0x0012,
|
||||
RDI_SectionKind_UDTs = 0x0013,
|
||||
RDI_SectionKind_Members = 0x0014,
|
||||
RDI_SectionKind_EnumMembers = 0x0015,
|
||||
RDI_SectionKind_GlobalVariables = 0x0016,
|
||||
RDI_SectionKind_GlobalVMap = 0x0017,
|
||||
RDI_SectionKind_ThreadVariables = 0x0018,
|
||||
RDI_SectionKind_Procedures = 0x0019,
|
||||
RDI_SectionKind_Scopes = 0x001A,
|
||||
RDI_SectionKind_ScopeVOffData = 0x001B,
|
||||
RDI_SectionKind_ScopeVMap = 0x001C,
|
||||
RDI_SectionKind_InlineSites = 0x001D,
|
||||
RDI_SectionKind_Locals = 0x001E,
|
||||
RDI_SectionKind_LocationBlocks = 0x001F,
|
||||
RDI_SectionKind_LocationData = 0x0020,
|
||||
RDI_SectionKind_NameMaps = 0x0021,
|
||||
RDI_SectionKind_NameMapBuckets = 0x0022,
|
||||
RDI_SectionKind_NameMapNodes = 0x0023,
|
||||
RDI_SectionKind_COUNT = 0x0024,
|
||||
} RDI_SectionKindEnum;
|
||||
|
||||
typedef RDI_U32 RDI_DataSectionEncoding;
|
||||
typedef enum RDI_DataSectionEncodingEnum
|
||||
typedef RDI_U32 RDI_SectionEncoding;
|
||||
typedef enum RDI_SectionEncodingEnum
|
||||
{
|
||||
RDI_DataSectionEncoding_Unpacked = 0,
|
||||
RDI_DataSectionEncoding_LZB = 1,
|
||||
} RDI_DataSectionEncodingEnum;
|
||||
RDI_SectionEncoding_Unpacked = 0,
|
||||
RDI_SectionEncoding_LZB = 1,
|
||||
} RDI_SectionEncodingEnum;
|
||||
|
||||
typedef RDI_U32 RDI_Arch;
|
||||
typedef enum RDI_ArchEnum
|
||||
@@ -494,53 +500,51 @@ X(RDI_U32, encoding_version)\
|
||||
X(RDI_U32, data_section_off)\
|
||||
X(RDI_U32, data_section_count)\
|
||||
|
||||
#define RDI_DataSectionTag_XList \
|
||||
X(NULL)\
|
||||
X(TopLevelInfo)\
|
||||
X(StringData)\
|
||||
X(StringTable)\
|
||||
X(IndexRuns)\
|
||||
X(BinarySections)\
|
||||
X(FilePathNodes)\
|
||||
X(SourceFiles)\
|
||||
X(LineTables)\
|
||||
X(LineInfoVoffs)\
|
||||
X(LineInfoLines)\
|
||||
X(LineInfoColumns)\
|
||||
X(SourceLineMaps)\
|
||||
X(SourceLineMapNumbers)\
|
||||
X(SourceLineMapRanges)\
|
||||
X(SourceLineMapVOffs)\
|
||||
X(Units)\
|
||||
X(UnitVmap)\
|
||||
X(TypeNodes)\
|
||||
X(UDTs)\
|
||||
X(Members)\
|
||||
X(EnumMembers)\
|
||||
X(GlobalVariables)\
|
||||
X(GlobalVmap)\
|
||||
X(ThreadVariables)\
|
||||
X(Procedures)\
|
||||
X(Scopes)\
|
||||
X(ScopeVoffData)\
|
||||
X(ScopeVmap)\
|
||||
X(InlineSites)\
|
||||
X(Locals)\
|
||||
X(LocationBlocks)\
|
||||
X(LocationData)\
|
||||
X(NameMaps)\
|
||||
X(PRIMARY_COUNT)\
|
||||
X(SECONDARY)\
|
||||
X(NameMapBuckets)\
|
||||
X(NameMapNodes)\
|
||||
#define RDI_SectionKind_XList \
|
||||
X(NULL, null, RDI_U8)\
|
||||
X(TopLevelInfo, top_level_info, RDI_TopLevelInfo)\
|
||||
X(StringData, string_data, RDI_U8)\
|
||||
X(StringTable, string_table, RDI_U32)\
|
||||
X(IndexRuns, index_runs, RDI_U32)\
|
||||
X(BinarySections, binary_sections, RDI_BinarySection)\
|
||||
X(FilePathNodes, file_path_nodes, RDI_FilePathNode)\
|
||||
X(SourceFiles, source_files, RDI_SourceFile)\
|
||||
X(LineTables, line_tables, RDI_LineTable)\
|
||||
X(LineInfoVOffs, line_info_voffs, RDI_U64)\
|
||||
X(LineInfoLines, line_info_lines, RDI_Line)\
|
||||
X(LineInfoColumns, line_info_columns, RDI_Column)\
|
||||
X(SourceLineMaps, source_line_maps, RDI_SourceLineMap)\
|
||||
X(SourceLineMapNumbers, source_line_map_numbers, RDI_U32)\
|
||||
X(SourceLineMapRanges, source_line_map_ranges, RDI_U32)\
|
||||
X(SourceLineMapVOffs, source_line_map_voffs, RDI_U64)\
|
||||
X(Units, units, RDI_Unit)\
|
||||
X(UnitVMap, unit_vmap, RDI_VMapEntry)\
|
||||
X(TypeNodes, type_nodes, RDI_TypeNode)\
|
||||
X(UDTs, udts, RDI_UDT)\
|
||||
X(Members, members, RDI_Member)\
|
||||
X(EnumMembers, enum_members, RDI_EnumMember)\
|
||||
X(GlobalVariables, global_variables, RDI_GlobalVariable)\
|
||||
X(GlobalVMap, global_vmap, RDI_VMapEntry)\
|
||||
X(ThreadVariables, thread_variables, RDI_ThreadVariable)\
|
||||
X(Procedures, procedures, RDI_Procedure)\
|
||||
X(Scopes, scopes, RDI_Scope)\
|
||||
X(ScopeVOffData, scope_voff_data, RDI_U64)\
|
||||
X(ScopeVMap, scope_vmap, RDI_VMapEntry)\
|
||||
X(InlineSites, inline_sites, RDI_InlineSite)\
|
||||
X(Locals, locals, RDI_Local)\
|
||||
X(LocationBlocks, location_blocks, RDI_LocationBlock)\
|
||||
X(LocationData, location_data, RDI_U8)\
|
||||
X(NameMaps, name_maps, RDI_NameMap)\
|
||||
X(NameMapBuckets, name_map_buckets, RDI_NameMapBucket)\
|
||||
X(NameMapNodes, name_map_nodes, RDI_NameMapNode)\
|
||||
|
||||
#define RDI_DataSectionEncoding_XList \
|
||||
#define RDI_SectionEncoding_XList \
|
||||
X(Unpacked)\
|
||||
X(LZB)\
|
||||
|
||||
#define RDI_DataSection_XList \
|
||||
X(RDI_DataSectionTag, tag)\
|
||||
X(RDI_DataSectionEncoding, encoding)\
|
||||
#define RDI_Section_XList \
|
||||
X(RDI_SectionEncoding, encoding)\
|
||||
X(RDI_U32, pad)\
|
||||
X(RDI_U64, off)\
|
||||
X(RDI_U64, encoded_size)\
|
||||
X(RDI_U64, unpacked_size)\
|
||||
@@ -885,8 +889,10 @@ X(COUNT)\
|
||||
|
||||
#define RDI_NameMap_XList \
|
||||
X(RDI_NameMapKind, kind)\
|
||||
X(RDI_U32, bucket_data_idx)\
|
||||
X(RDI_U32, node_data_idx)\
|
||||
X(RDI_U32, bucket_base_idx)\
|
||||
X(RDI_U32, node_base_idx)\
|
||||
X(RDI_U32, bucket_count)\
|
||||
X(RDI_U32, node_count)\
|
||||
|
||||
#define RDI_NameMapBucket_XList \
|
||||
X(RDI_U32, first_node)\
|
||||
@@ -897,6 +903,72 @@ X(RDI_U32, string_idx)\
|
||||
X(RDI_U32, match_count)\
|
||||
X(RDI_U32, match_idx_or_idx_run_first)\
|
||||
|
||||
#if !RDI_DISABLE_TABLE_INDEX_TYPECHECKING
|
||||
typedef struct RDI_U32_StringTable { RDI_U32 v; } RDI_U32_StringTable;
|
||||
typedef struct RDI_U32_IndexRuns { RDI_U32 v; } RDI_U32_IndexRuns;
|
||||
typedef struct RDI_U32_BinarySections { RDI_U32 v; } RDI_U32_BinarySections;
|
||||
typedef struct RDI_U32_FilePathNodes { RDI_U32 v; } RDI_U32_FilePathNodes;
|
||||
typedef struct RDI_U32_SourceFiles { RDI_U32 v; } RDI_U32_SourceFiles;
|
||||
typedef struct RDI_U32_LineTables { RDI_U32 v; } RDI_U32_LineTables;
|
||||
typedef struct RDI_U32_LineInfoVOffs { RDI_U32 v; } RDI_U32_LineInfoVOffs;
|
||||
typedef struct RDI_U32_LineInfoLines { RDI_U32 v; } RDI_U32_LineInfoLines;
|
||||
typedef struct RDI_U32_LineInfoColumns { RDI_U32 v; } RDI_U32_LineInfoColumns;
|
||||
typedef struct RDI_U32_SourceLineMaps { RDI_U32 v; } RDI_U32_SourceLineMaps;
|
||||
typedef struct RDI_U32_SourceLineMapNumbers { RDI_U32 v; } RDI_U32_SourceLineMapNumbers;
|
||||
typedef struct RDI_U32_SourceLineMapRanges { RDI_U32 v; } RDI_U32_SourceLineMapRanges;
|
||||
typedef struct RDI_U32_SourceLineMapVOffs { RDI_U32 v; } RDI_U32_SourceLineMapVOffs;
|
||||
typedef struct RDI_U32_Units { RDI_U32 v; } RDI_U32_Units;
|
||||
typedef struct RDI_U32_TypeNodes { RDI_U32 v; } RDI_U32_TypeNodes;
|
||||
typedef struct RDI_U32_UDTs { RDI_U32 v; } RDI_U32_UDTs;
|
||||
typedef struct RDI_U32_Members { RDI_U32 v; } RDI_U32_Members;
|
||||
typedef struct RDI_U32_EnumMembers { RDI_U32 v; } RDI_U32_EnumMembers;
|
||||
typedef struct RDI_U32_GlobalVariables { RDI_U32 v; } RDI_U32_GlobalVariables;
|
||||
typedef struct RDI_U32_ThreadVariables { RDI_U32 v; } RDI_U32_ThreadVariables;
|
||||
typedef struct RDI_U32_Procedures { RDI_U32 v; } RDI_U32_Procedures;
|
||||
typedef struct RDI_U32_Scopes { RDI_U32 v; } RDI_U32_Scopes;
|
||||
typedef struct RDI_U32_ScopeVOffData { RDI_U32 v; } RDI_U32_ScopeVOffData;
|
||||
typedef struct RDI_U32_InlineSites { RDI_U32 v; } RDI_U32_InlineSites;
|
||||
typedef struct RDI_U32_Locals { RDI_U32 v; } RDI_U32_Locals;
|
||||
typedef struct RDI_U32_LocationBlocks { RDI_U32 v; } RDI_U32_LocationBlocks;
|
||||
typedef struct RDI_U32_LocationData { RDI_U32 v; } RDI_U32_LocationData;
|
||||
typedef struct RDI_U32_NameMaps { RDI_U32 v; } RDI_U32_NameMaps;
|
||||
typedef struct RDI_U32_NameMapBuckets { RDI_U32 v; } RDI_U32_NameMapBuckets;
|
||||
typedef struct RDI_U32_NameMapNodes { RDI_U32 v; } RDI_U32_NameMapNodes;
|
||||
#else
|
||||
typedef struct RDI_U32_Table { RDI_U32 v; } RDI_U32_Table;
|
||||
typedef struct RDI_U64_Table { RDI_U64 v; } RDI_U64_Table;
|
||||
typedef RDI_U32_Table RDI_U32_StringTable;
|
||||
typedef RDI_U32_Table RDI_U32_IndexRuns;
|
||||
typedef RDI_U32_Table RDI_U32_BinarySections;
|
||||
typedef RDI_U32_Table RDI_U32_FilePathNodes;
|
||||
typedef RDI_U32_Table RDI_U32_SourceFiles;
|
||||
typedef RDI_U32_Table RDI_U32_LineTables;
|
||||
typedef RDI_U32_Table RDI_U32_LineInfoVOffs;
|
||||
typedef RDI_U32_Table RDI_U32_LineInfoLines;
|
||||
typedef RDI_U32_Table RDI_U32_LineInfoColumns;
|
||||
typedef RDI_U32_Table RDI_U32_SourceLineMaps;
|
||||
typedef RDI_U32_Table RDI_U32_SourceLineMapNumbers;
|
||||
typedef RDI_U32_Table RDI_U32_SourceLineMapRanges;
|
||||
typedef RDI_U32_Table RDI_U32_SourceLineMapVOffs;
|
||||
typedef RDI_U32_Table RDI_U32_Units;
|
||||
typedef RDI_U32_Table RDI_U32_TypeNodes;
|
||||
typedef RDI_U32_Table RDI_U32_UDTs;
|
||||
typedef RDI_U32_Table RDI_U32_Members;
|
||||
typedef RDI_U32_Table RDI_U32_EnumMembers;
|
||||
typedef RDI_U32_Table RDI_U32_GlobalVariables;
|
||||
typedef RDI_U32_Table RDI_U32_ThreadVariables;
|
||||
typedef RDI_U32_Table RDI_U32_Procedures;
|
||||
typedef RDI_U32_Table RDI_U32_Scopes;
|
||||
typedef RDI_U32_Table RDI_U32_ScopeVOffData;
|
||||
typedef RDI_U32_Table RDI_U32_InlineSites;
|
||||
typedef RDI_U32_Table RDI_U32_Locals;
|
||||
typedef RDI_U32_Table RDI_U32_LocationBlocks;
|
||||
typedef RDI_U32_Table RDI_U32_LocationData;
|
||||
typedef RDI_U32_Table RDI_U32_NameMaps;
|
||||
typedef RDI_U32_Table RDI_U32_NameMapBuckets;
|
||||
typedef RDI_U32_Table RDI_U32_NameMapNodes;
|
||||
#endif
|
||||
|
||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 4) | ((pushN) << 6))
|
||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0xf)
|
||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0x3)
|
||||
@@ -912,11 +984,11 @@ RDI_U32 data_section_off;
|
||||
RDI_U32 data_section_count;
|
||||
};
|
||||
|
||||
typedef struct RDI_DataSection RDI_DataSection;
|
||||
struct RDI_DataSection
|
||||
typedef struct RDI_Section RDI_Section;
|
||||
struct RDI_Section
|
||||
{
|
||||
RDI_DataSectionTag tag;
|
||||
RDI_DataSectionEncoding encoding;
|
||||
RDI_SectionEncoding encoding;
|
||||
RDI_U32 pad;
|
||||
RDI_U64 off;
|
||||
RDI_U64 encoded_size;
|
||||
RDI_U64 unpacked_size;
|
||||
@@ -1034,13 +1106,15 @@ RDI_U32 byte_size;
|
||||
{
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 count;
|
||||
union{
|
||||
union
|
||||
{
|
||||
// when kind is 'Function' or 'Method'
|
||||
RDI_U32 param_idx_run_first;
|
||||
// when kind is 'MemberPtr'
|
||||
RDI_U32 owner_type_idx;
|
||||
};
|
||||
} constructed;
|
||||
}
|
||||
constructed;
|
||||
|
||||
// kind is 'user defined'
|
||||
struct
|
||||
@@ -1048,7 +1122,8 @@ RDI_U32 byte_size;
|
||||
RDI_U32 name_string_idx;
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 udt_idx;
|
||||
} user_defined;
|
||||
}
|
||||
user_defined;
|
||||
|
||||
// (kind = Bitfield)
|
||||
struct
|
||||
@@ -1056,7 +1131,8 @@ RDI_U32 byte_size;
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 off;
|
||||
RDI_U32 size;
|
||||
} bitfield;
|
||||
}
|
||||
bitfield;
|
||||
}
|
||||
;
|
||||
};
|
||||
@@ -1193,8 +1269,10 @@ typedef struct RDI_NameMap RDI_NameMap;
|
||||
struct RDI_NameMap
|
||||
{
|
||||
RDI_NameMapKind kind;
|
||||
RDI_U32 bucket_data_idx;
|
||||
RDI_U32 node_data_idx;
|
||||
RDI_U32 bucket_base_idx;
|
||||
RDI_U32 node_base_idx;
|
||||
RDI_U32 bucket_count;
|
||||
RDI_U32 node_count;
|
||||
};
|
||||
|
||||
typedef struct RDI_NameMapBucket RDI_NameMapBucket;
|
||||
@@ -1212,6 +1290,43 @@ RDI_U32 match_count;
|
||||
RDI_U32 match_idx_or_idx_run_first;
|
||||
};
|
||||
|
||||
typedef RDI_U8 RDI_SectionElementType_NULL;
|
||||
typedef RDI_TopLevelInfo RDI_SectionElementType_TopLevelInfo;
|
||||
typedef RDI_U8 RDI_SectionElementType_StringData;
|
||||
typedef RDI_U32 RDI_SectionElementType_StringTable;
|
||||
typedef RDI_U32 RDI_SectionElementType_IndexRuns;
|
||||
typedef RDI_BinarySection RDI_SectionElementType_BinarySections;
|
||||
typedef RDI_FilePathNode RDI_SectionElementType_FilePathNodes;
|
||||
typedef RDI_SourceFile RDI_SectionElementType_SourceFiles;
|
||||
typedef RDI_LineTable RDI_SectionElementType_LineTables;
|
||||
typedef RDI_U64 RDI_SectionElementType_LineInfoVOffs;
|
||||
typedef RDI_Line RDI_SectionElementType_LineInfoLines;
|
||||
typedef RDI_Column RDI_SectionElementType_LineInfoColumns;
|
||||
typedef RDI_SourceLineMap RDI_SectionElementType_SourceLineMaps;
|
||||
typedef RDI_U32 RDI_SectionElementType_SourceLineMapNumbers;
|
||||
typedef RDI_U32 RDI_SectionElementType_SourceLineMapRanges;
|
||||
typedef RDI_U64 RDI_SectionElementType_SourceLineMapVOffs;
|
||||
typedef RDI_Unit RDI_SectionElementType_Units;
|
||||
typedef RDI_VMapEntry RDI_SectionElementType_UnitVMap;
|
||||
typedef RDI_TypeNode RDI_SectionElementType_TypeNodes;
|
||||
typedef RDI_UDT RDI_SectionElementType_UDTs;
|
||||
typedef RDI_Member RDI_SectionElementType_Members;
|
||||
typedef RDI_EnumMember RDI_SectionElementType_EnumMembers;
|
||||
typedef RDI_GlobalVariable RDI_SectionElementType_GlobalVariables;
|
||||
typedef RDI_VMapEntry RDI_SectionElementType_GlobalVMap;
|
||||
typedef RDI_ThreadVariable RDI_SectionElementType_ThreadVariables;
|
||||
typedef RDI_Procedure RDI_SectionElementType_Procedures;
|
||||
typedef RDI_Scope RDI_SectionElementType_Scopes;
|
||||
typedef RDI_U64 RDI_SectionElementType_ScopeVOffData;
|
||||
typedef RDI_VMapEntry RDI_SectionElementType_ScopeVMap;
|
||||
typedef RDI_InlineSite RDI_SectionElementType_InlineSites;
|
||||
typedef RDI_Local RDI_SectionElementType_Locals;
|
||||
typedef RDI_LocationBlock RDI_SectionElementType_LocationBlocks;
|
||||
typedef RDI_U8 RDI_SectionElementType_LocationData;
|
||||
typedef RDI_NameMap RDI_SectionElementType_NameMaps;
|
||||
typedef RDI_NameMapBucket RDI_SectionElementType_NameMapBuckets;
|
||||
typedef RDI_NameMapNode RDI_SectionElementType_NameMapNodes;
|
||||
|
||||
RDI_PROC RDI_U64 rdi_hash(RDI_U8 *ptr, RDI_U64 size);
|
||||
RDI_PROC RDI_U32 rdi_size_from_basic_type_kind(RDI_TypeKind kind);
|
||||
RDI_PROC RDI_U32 rdi_addr_size_from_arch(RDI_Arch arch);
|
||||
@@ -1219,6 +1334,8 @@ RDI_PROC RDI_EvalConversionKind rdi_eval_conversion_kind_from_typegroups(RDI_Eva
|
||||
RDI_PROC RDI_S32 rdi_eval_op_typegroup_are_compatible(RDI_EvalOp op, RDI_EvalTypeGroup group);
|
||||
RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConversionKind kind, RDI_U64 *size_out);
|
||||
|
||||
extern RDI_U16 rdi_section_element_size_table[37];
|
||||
extern RDI_U8 rdi_section_is_required_table[37];
|
||||
extern RDI_U8 rdi_eval_op_ctrlbits_table[45];
|
||||
|
||||
#endif // RDI_FORMAT_H
|
||||
|
||||
@@ -34,14 +34,14 @@ rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out)
|
||||
//////////////////////////////
|
||||
//- rjf: extract data sections
|
||||
//
|
||||
RDI_DataSection *dsecs = 0;
|
||||
RDI_Section *dsecs = 0;
|
||||
RDI_U32 dsec_count = 0;
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
RDI_U64 opl = (RDI_U64)hdr->data_section_off + (RDI_U64)hdr->data_section_count*sizeof(*dsecs);
|
||||
if(opl <= size)
|
||||
{
|
||||
dsecs = (RDI_DataSection*)(data + hdr->data_section_off);
|
||||
dsecs = (RDI_Section*)(data + hdr->data_section_off);
|
||||
dsec_count = hdr->data_section_count;
|
||||
}
|
||||
if(dsecs == 0)
|
||||
@@ -51,211 +51,146 @@ rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out)
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: extract primary data section indexes
|
||||
//
|
||||
RDI_U32 dsec_idx[RDI_DataSectionTag_PRIMARY_COUNT] = {0};
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
RDI_DataSection *sec_ptr = dsecs;
|
||||
for(RDI_U32 i = 0; i < dsec_count; i += 1, sec_ptr += 1)
|
||||
{
|
||||
if(sec_ptr->tag < RDI_DataSectionTag_PRIMARY_COUNT)
|
||||
{
|
||||
dsec_idx[sec_ptr->tag] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: fill out raw data info
|
||||
//- rjf: fill result
|
||||
//
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
out->raw_data = data;
|
||||
out->raw_data_size = size;
|
||||
out->dsecs = dsecs;
|
||||
out->dsec_count = dsec_count;
|
||||
for(RDI_U32 i = 0; i < RDI_DataSectionTag_PRIMARY_COUNT; i += 1)
|
||||
{
|
||||
out->dsec_idx[i] = dsec_idx[i];
|
||||
}
|
||||
out->sections = dsecs;
|
||||
out->sections_count = dsec_count;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: extract string table info
|
||||
//
|
||||
RDI_U8 *string_data = 0;
|
||||
RDI_U64 string_opl = 0;
|
||||
RDI_U32 *string_offs = 0;
|
||||
RDI_U64 string_count = 0;
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
RDI_U64 table_entry_count = 0;
|
||||
rdi_parse__extract_primary(out, string_offs, &table_entry_count, RDI_DataSectionTag_StringTable);
|
||||
rdi_parse__extract_primary(out, string_data, &string_opl, RDI_DataSectionTag_StringData);
|
||||
if(table_entry_count > 0)
|
||||
{
|
||||
string_count = table_entry_count - 1;
|
||||
}
|
||||
if(string_data == 0)
|
||||
{
|
||||
result = RDI_ParseStatus_MissingStringDataSection;
|
||||
}
|
||||
else if (string_offs == 0)
|
||||
{
|
||||
result = RDI_ParseStatus_MissingStringTableSection;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: extract index run table info
|
||||
//
|
||||
RDI_U32 *idx_run_data = 0;
|
||||
RDI_U64 idx_run_count = 0;
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
rdi_parse__extract_primary(out, idx_run_data, &idx_run_count, RDI_DataSectionTag_IndexRuns);
|
||||
if(idx_run_data == 0)
|
||||
{
|
||||
result = RDI_ParseStatus_MissingIndexRunSection;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: extract info tables
|
||||
//- rjf: validate results
|
||||
//
|
||||
if(result == RDI_ParseStatus_Good)
|
||||
{
|
||||
out->string_data = string_data;
|
||||
out->string_offs = string_offs;
|
||||
out->string_data_size = string_opl;
|
||||
out->string_count = string_count;
|
||||
out->idx_run_data = idx_run_data;
|
||||
out->idx_run_count = idx_run_count;
|
||||
for(RDI_SectionKind k = (RDI_SectionKind)(RDI_SectionKind_NULL+1); k < RDI_SectionKind_COUNT; k = (RDI_SectionKind)(k+1))
|
||||
{
|
||||
RDI_TopLevelInfo *tli = 0;
|
||||
RDI_U64 dummy = 0;
|
||||
rdi_parse__extract_primary(out, tli, &dummy, RDI_DataSectionTag_TopLevelInfo);
|
||||
if (dummy != 1){
|
||||
tli = 0;
|
||||
}
|
||||
out->top_level_info = tli;
|
||||
}
|
||||
rdi_parse__extract_primary(out, out->binary_sections, &out->binary_sections_count, RDI_DataSectionTag_BinarySections);
|
||||
rdi_parse__extract_primary(out, out->file_paths, &out->file_paths_count, RDI_DataSectionTag_FilePathNodes);
|
||||
rdi_parse__extract_primary(out, out->source_files, &out->source_files_count, RDI_DataSectionTag_SourceFiles);
|
||||
rdi_parse__extract_primary(out, out->line_tables, &out->line_tables_count, RDI_DataSectionTag_LineTables);
|
||||
rdi_parse__extract_primary(out, out->source_line_maps, &out->source_line_maps_count, RDI_DataSectionTag_SourceLineMaps);
|
||||
rdi_parse__extract_primary(out, out->line_info_voffs, &out->line_info_voffs_count, RDI_DataSectionTag_LineInfoVoffs);
|
||||
rdi_parse__extract_primary(out, out->line_info_lines, &out->line_info_lines_count, RDI_DataSectionTag_LineInfoLines);
|
||||
rdi_parse__extract_primary(out, out->line_info_columns, &out->line_info_columns_count, RDI_DataSectionTag_LineInfoColumns);
|
||||
rdi_parse__extract_primary(out, out->units, &out->units_count, RDI_DataSectionTag_Units);
|
||||
rdi_parse__extract_primary(out, out->unit_vmap, &out->unit_vmap_count, RDI_DataSectionTag_UnitVmap);
|
||||
rdi_parse__extract_primary(out, out->unit_vmap, &out->unit_vmap_count, RDI_DataSectionTag_UnitVmap);
|
||||
rdi_parse__extract_primary(out, out->type_nodes, &out->type_nodes_count, RDI_DataSectionTag_TypeNodes);
|
||||
rdi_parse__extract_primary(out, out->udts, &out->udts_count, RDI_DataSectionTag_UDTs);
|
||||
rdi_parse__extract_primary(out, out->members, &out->members_count, RDI_DataSectionTag_Members);
|
||||
rdi_parse__extract_primary(out, out->enum_members, &out->enum_members_count, RDI_DataSectionTag_EnumMembers);
|
||||
rdi_parse__extract_primary(out, out->global_variables, &out->global_variables_count, RDI_DataSectionTag_GlobalVariables);
|
||||
rdi_parse__extract_primary(out, out->global_vmap, &out->global_vmap_count, RDI_DataSectionTag_GlobalVmap);
|
||||
rdi_parse__extract_primary(out, out->thread_variables, &out->thread_variables_count, RDI_DataSectionTag_ThreadVariables);
|
||||
rdi_parse__extract_primary(out, out->procedures, &out->procedures_count, RDI_DataSectionTag_Procedures);
|
||||
rdi_parse__extract_primary(out, out->scopes, &out->scopes_count, RDI_DataSectionTag_Scopes);
|
||||
rdi_parse__extract_primary(out, out->scope_voffs, &out->scope_voffs_count, RDI_DataSectionTag_ScopeVoffData);
|
||||
rdi_parse__extract_primary(out, out->scope_vmap, &out->scope_vmap_count, RDI_DataSectionTag_ScopeVmap);
|
||||
rdi_parse__extract_primary(out, out->locals, &out->locals_count, RDI_DataSectionTag_Locals);
|
||||
rdi_parse__extract_primary(out, out->location_blocks, &out->location_blocks_count, RDI_DataSectionTag_LocationBlocks);
|
||||
rdi_parse__extract_primary(out, out->location_data, &out->location_data_size, RDI_DataSectionTag_LocationData);
|
||||
rdi_parse__extract_primary(out, out->name_maps, &out->name_maps_count, RDI_DataSectionTag_NameMaps);
|
||||
{
|
||||
RDI_NameMap *name_map_ptr = out->name_maps;
|
||||
RDI_NameMap *name_map_opl = out->name_maps + out->name_maps_count;
|
||||
for (; name_map_ptr < name_map_opl; name_map_ptr += 1){
|
||||
if (out->name_maps_by_kind[name_map_ptr->kind] == 0){
|
||||
out->name_maps_by_kind[name_map_ptr->kind] = name_map_ptr;
|
||||
if(rdi_section_is_required_table[k])
|
||||
{
|
||||
RDI_U64 data_size = 0;
|
||||
RDI_SectionEncoding encoding = 0;
|
||||
void *data = rdi_section_raw_data_from_kind(out, k, &encoding, &data_size);
|
||||
if(data == 0 || data == &rdi_nil_element_union || data_size == 0)
|
||||
{
|
||||
result = RDI_ParseStatus_MissingRequiredSection;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: fill any missing tables with nil elements
|
||||
//
|
||||
#if !defined(RDI_DISABLE_NILS)
|
||||
if(out->top_level_info == 0) { out->top_level_info = &rdi_top_level_info_nil; }
|
||||
if(out->binary_sections == 0) { out->binary_sections = &rdi_binary_section_nil; out->binary_sections_count = 1; }
|
||||
if(out->file_paths == 0) { out->file_paths = &rdi_file_path_node_nil; out->file_paths_count = 1; }
|
||||
if(out->source_files == 0) { out->source_files = &rdi_source_file_nil; out->source_files_count = 1; }
|
||||
if(out->line_tables == 0) { out->line_tables = &rdi_line_table_nil; out->line_tables_count = 1; }
|
||||
if(out->source_line_maps == 0) { out->source_line_maps = &rdi_source_line_map_nil; out->source_line_maps_count = 1; }
|
||||
if(out->units == 0) { out->units = &rdi_unit_nil; out->units_count = 1; }
|
||||
if(out->unit_vmap == 0) { out->unit_vmap = &rdi_vmap_entry_nil; out->unit_vmap_count = 1; }
|
||||
if(out->type_nodes == 0) { out->type_nodes = &rdi_type_node_nil; out->type_nodes_count = 1; }
|
||||
if(out->udts == 0) { out->udts = &rdi_udt_nil; out->udts_count = 1; }
|
||||
if(out->members == 0) { out->members = &rdi_member_nil; out->members_count = 1; }
|
||||
if(out->enum_members == 0) { out->enum_members = &rdi_enum_member_nil; out->enum_members_count = 1; }
|
||||
if(out->global_variables == 0) { out->global_variables = &rdi_global_variable_nil; out->global_variables_count = 1; }
|
||||
if(out->global_vmap == 0) { out->global_vmap = &rdi_vmap_entry_nil; out->global_vmap_count = 1; }
|
||||
if(out->thread_variables == 0) { out->thread_variables = &rdi_thread_variable_nil; out->thread_variables_count = 1; }
|
||||
if(out->procedures == 0) { out->procedures = &rdi_procedure_nil; out->procedures_count = 1; }
|
||||
if(out->scopes == 0) { out->scopes = &rdi_scope_nil; out->scopes_count = 1; }
|
||||
if(out->scope_voffs == 0) { out->scope_voffs = &rdi_voff_nil; out->scope_voffs_count = 1; }
|
||||
if(out->scope_vmap == 0) { out->scope_vmap = &rdi_vmap_entry_nil; out->scope_vmap_count = 1; }
|
||||
if(out->locals == 0) { out->locals = &rdi_local_nil; out->locals_count = 1; }
|
||||
if(out->location_blocks == 0) { out->location_blocks = &rdi_location_block_nil; out->location_blocks_count = 1; }
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Parsed Info Extraction Helpers
|
||||
//~ Base Parsed Info Extraction Helpers
|
||||
|
||||
//- top-level info
|
||||
//- section table/element raw data extraction
|
||||
|
||||
RDI_PROC void *
|
||||
rdi_section_raw_data_from_kind(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_SectionEncoding *encoding_out, RDI_U64 *size_out)
|
||||
{
|
||||
void *result = 0;
|
||||
#if !defined(RDI_DISABLE_NILS)
|
||||
result = &rdi_nil_element_union;
|
||||
*size_out = rdi_section_element_size_table[kind];
|
||||
#endif
|
||||
if(0 <= kind && kind < rdi->sections_count)
|
||||
{
|
||||
result = rdi->raw_data+rdi->sections[kind].off;
|
||||
*size_out = rdi->sections[kind].encoded_size;
|
||||
*encoding_out = rdi->sections[kind].encoding;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC void *
|
||||
rdi_section_raw_table_from_kind(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_U64 *count_out)
|
||||
{
|
||||
void *result = 0;
|
||||
RDI_U64 all_elements_size = 0;
|
||||
RDI_SectionEncoding all_elements_encoding = 0;
|
||||
void *all_elements = rdi_section_raw_data_from_kind(rdi, kind, &all_elements_encoding, &all_elements_size);
|
||||
if(all_elements_encoding == RDI_SectionEncoding_Unpacked)
|
||||
{
|
||||
RDI_U64 element_size = (RDI_U64)rdi_section_element_size_table[kind];
|
||||
RDI_U64 all_elements_count = all_elements_size/element_size;
|
||||
result = all_elements;
|
||||
*count_out = all_elements_count;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC void *
|
||||
rdi_section_raw_element_from_kind_idx(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_U64 idx)
|
||||
{
|
||||
RDI_U64 count = 0;
|
||||
void *table = rdi_section_raw_table_from_kind(rdi, kind, &count);
|
||||
void *result = table;
|
||||
if(idx < count)
|
||||
{
|
||||
RDI_U64 element_size = (RDI_U64)rdi_section_element_size_table[kind];
|
||||
result = (RDI_U8 *)table + element_size*idx;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//- info about whole parse
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdi_decompressed_size_from_parsed(RDI_Parsed *rdi)
|
||||
{
|
||||
RDI_U64 decompressed_size = rdi->raw_data_size;
|
||||
for(RDI_U64 dsec_idx = 0; dsec_idx < rdi->dsec_count; dsec_idx += 1)
|
||||
for(RDI_U64 section_idx = 0; section_idx < rdi->sections_count; section_idx += 1)
|
||||
{
|
||||
decompressed_size += (rdi->dsecs[dsec_idx].unpacked_size - rdi->dsecs[dsec_idx].encoded_size);
|
||||
decompressed_size += (rdi->sections[section_idx].unpacked_size - rdi->sections[section_idx].encoded_size);
|
||||
}
|
||||
return decompressed_size;
|
||||
}
|
||||
|
||||
//- strings
|
||||
|
||||
RDI_PROC RDI_U8*
|
||||
rdi_string_from_idx(RDI_Parsed *parsed, RDI_U32 idx, RDI_U64 *len_out)
|
||||
RDI_PROC RDI_U8 *
|
||||
rdi_string_from_idx(RDI_Parsed *rdi, RDI_U32 idx, RDI_U64 *len_out)
|
||||
{
|
||||
RDI_U8 *result = 0;
|
||||
RDI_U64 len_result = 0;
|
||||
if(idx < parsed->string_count)
|
||||
RDI_U8 *result_base = 0;
|
||||
RDI_U64 result_size = 0;
|
||||
{
|
||||
RDI_U32 off_raw = parsed->string_offs[idx];
|
||||
RDI_U32 opl_raw = parsed->string_offs[idx + 1];
|
||||
RDI_U32 opl = rdi_parse__min(opl_raw, parsed->string_data_size);
|
||||
RDI_U32 off = rdi_parse__min(off_raw, opl);
|
||||
result = parsed->string_data + off;
|
||||
len_result = opl - off;
|
||||
RDI_U64 string_offs_count = 0;
|
||||
RDI_U32 *string_offs = rdi_table_from_name(rdi, StringTable, &string_offs_count);
|
||||
if(idx < string_offs_count)
|
||||
{
|
||||
RDI_U64 string_data_size = 0;
|
||||
RDI_U8 *string_data = rdi_table_from_name(rdi, StringData, &string_data_size);
|
||||
RDI_U32 off_raw = string_offs[idx];
|
||||
RDI_U32 opl_raw = string_offs[idx + 1];
|
||||
RDI_U32 opl = rdi_parse__min(opl_raw, string_data_size);
|
||||
RDI_U32 off = rdi_parse__min(off_raw, opl);
|
||||
result_base = string_data + off;
|
||||
result_size = opl - off;
|
||||
}
|
||||
}
|
||||
*len_out = len_result;
|
||||
return result;
|
||||
*len_out = result_size;
|
||||
return result_base;
|
||||
}
|
||||
|
||||
//- index runs
|
||||
|
||||
RDI_PROC RDI_U32*
|
||||
rdi_idx_run_from_first_count(RDI_Parsed *parsed, RDI_U32 raw_first, RDI_U32 raw_count, RDI_U32 *n_out)
|
||||
rdi_idx_run_from_first_count(RDI_Parsed *rdi, RDI_U32 raw_first, RDI_U32 raw_count, RDI_U32 *n_out)
|
||||
{
|
||||
RDI_U64 idx_run_count = 0;
|
||||
RDI_U32 *idx_run_data = rdi_table_from_name(rdi, IndexRuns, &idx_run_count);
|
||||
RDI_U32 raw_opl = raw_first + raw_count;
|
||||
RDI_U32 opl = rdi_parse__min(raw_opl, parsed->idx_run_count);
|
||||
RDI_U32 opl = rdi_parse__min(raw_opl, idx_run_count);
|
||||
RDI_U32 first = rdi_parse__min(raw_first, opl);
|
||||
RDI_U32 *result = 0;
|
||||
if(first < parsed->idx_run_count)
|
||||
if(first < idx_run_count)
|
||||
{
|
||||
result = parsed->idx_run_data + first;
|
||||
result = idx_run_data + first;
|
||||
}
|
||||
*n_out = opl - first;
|
||||
return result;
|
||||
@@ -264,17 +199,17 @@ rdi_idx_run_from_first_count(RDI_Parsed *parsed, RDI_U32 raw_first, RDI_U32 raw_
|
||||
//- line info
|
||||
|
||||
RDI_PROC void
|
||||
rdi_parsed_from_line_table(RDI_Parsed *p, RDI_LineTable *line_table, RDI_ParsedLineTable *out)
|
||||
rdi_parsed_from_line_table(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_ParsedLineTable *out)
|
||||
{
|
||||
//- rjf: extract top-level line info tables
|
||||
RDI_U64 all_voffs_count = 0;
|
||||
RDI_U64 *all_voffs = (RDI_U64 *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_LineInfoVoffs], sizeof(RDI_U64), RDI_DataSectionTag_LineInfoVoffs, &all_voffs_count);
|
||||
RDI_U64 *all_voffs = rdi_table_from_name(rdi, LineInfoVOffs, &all_voffs_count);
|
||||
RDI_U64 *all_voffs_opl = all_voffs + all_voffs_count;
|
||||
RDI_U64 all_lines_count = 0;
|
||||
RDI_Line *all_lines = (RDI_Line *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_LineInfoLines], sizeof(RDI_Line), RDI_DataSectionTag_LineInfoLines, &all_lines_count);
|
||||
RDI_Line *all_lines = rdi_table_from_name(rdi, LineInfoLines, &all_lines_count);
|
||||
RDI_Line *all_lines_opl = all_lines + all_lines_count;
|
||||
RDI_U64 all_cols_count = 0;
|
||||
RDI_Column *all_cols = (RDI_Column *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_LineInfoColumns], sizeof(RDI_Column), RDI_DataSectionTag_LineInfoColumns, &all_cols_count);
|
||||
RDI_Column *all_cols = rdi_table_from_name(rdi, LineInfoColumns, &all_cols_count);
|
||||
RDI_Column *all_cols_opl = all_cols + all_cols_count;
|
||||
|
||||
//- rjf: extract ranges of top-level tables belonging to this line table
|
||||
@@ -332,17 +267,17 @@ rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff)
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdi_parsed_from_source_line_map(RDI_Parsed *p, RDI_SourceLineMap *map, RDI_ParsedSourceLineMap *out)
|
||||
rdi_parsed_from_source_line_map(RDI_Parsed *rdi, RDI_SourceLineMap *map, RDI_ParsedSourceLineMap *out)
|
||||
{
|
||||
//- rjf: extract top-level line info tables
|
||||
RDI_U64 all_nums_count = 0;
|
||||
RDI_U32 *all_nums = (RDI_U32 *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_SourceLineMapNumbers], sizeof(RDI_U32), RDI_DataSectionTag_SourceLineMapNumbers, &all_nums_count);
|
||||
RDI_U32 *all_nums = rdi_table_from_name(rdi, SourceLineMapNumbers, &all_nums_count);
|
||||
RDI_U32 *all_nums_opl = all_nums + all_nums_count;
|
||||
RDI_U64 all_rngs_count = 0;
|
||||
RDI_U32 *all_rngs = (RDI_U32 *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_SourceLineMapRanges], sizeof(RDI_U32), RDI_DataSectionTag_SourceLineMapRanges, &all_rngs_count);
|
||||
RDI_U32 *all_rngs = rdi_table_from_name(rdi, SourceLineMapRanges, &all_rngs_count);
|
||||
RDI_U32 *all_rngs_opl = all_rngs + all_rngs_count;
|
||||
RDI_U64 all_voffs_count = 0;
|
||||
RDI_U64 *all_voffs = (RDI_U64 *)rdi_data_from_dsec(p, p->dsec_idx[RDI_DataSectionTag_SourceLineMapVOffs], sizeof(RDI_U64), RDI_DataSectionTag_SourceLineMapVOffs, &all_voffs_count);
|
||||
RDI_U64 *all_voffs = rdi_table_from_name(rdi, SourceLineMapVOffs, &all_voffs_count);
|
||||
RDI_U64 *all_voffs_opl = all_voffs + all_voffs_count;
|
||||
|
||||
//- rjf: extract ranges of top-level tables belonging to this line map
|
||||
@@ -363,7 +298,7 @@ rdi_parsed_from_source_line_map(RDI_Parsed *p, RDI_SourceLineMap *map, RDI_Parse
|
||||
out->voff_count = voffs_count;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64*
|
||||
RDI_PROC RDI_U64 *
|
||||
rdi_line_voffs_from_num(RDI_ParsedSourceLineMap *map, RDI_U32 linenum, RDI_U32 *n_out)
|
||||
{
|
||||
RDI_U64 *result = 0;
|
||||
@@ -424,7 +359,7 @@ rdi_line_voffs_from_num(RDI_ParsedSourceLineMap *map, RDI_U32 linenum, RDI_U32 *
|
||||
//- vmap lookups
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdi_vmap_idx_from_voff(RDI_VMapEntry *vmap, RDI_U32 vmap_count, RDI_U64 voff)
|
||||
rdi_vmap_idx_from_voff(RDI_VMapEntry *vmap, RDI_U64 vmap_count, RDI_U64 voff)
|
||||
{
|
||||
RDI_U64 result = 0;
|
||||
if(vmap_count > 0 && vmap[0].voff <= voff && voff < vmap[vmap_count - 1].voff)
|
||||
@@ -459,27 +394,42 @@ rdi_vmap_idx_from_voff(RDI_VMapEntry *vmap, RDI_U32 vmap_count, RDI_U64 voff)
|
||||
return result;
|
||||
}
|
||||
|
||||
//- name maps
|
||||
|
||||
RDI_PROC RDI_NameMap*
|
||||
rdi_name_map_from_kind(RDI_Parsed *p, RDI_NameMapKind kind){
|
||||
RDI_NameMap *result = 0;
|
||||
if(0 < kind && kind < RDI_NameMapKind_COUNT)
|
||||
{
|
||||
result = p->name_maps_by_kind[kind];
|
||||
}
|
||||
RDI_PROC RDI_U64
|
||||
rdi_vmap_idx_from_section_kind_voff(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_U64 voff)
|
||||
{
|
||||
RDI_U64 vmaps_count = 0;
|
||||
RDI_VMapEntry *vmaps = rdi_section_raw_table_from_kind(rdi, kind, &vmaps_count);
|
||||
RDI_U64 result = rdi_vmap_idx_from_voff(vmaps, vmaps_count, voff);
|
||||
return result;
|
||||
}
|
||||
|
||||
//- name maps
|
||||
|
||||
RDI_PROC void
|
||||
rdi_name_map_parse(RDI_Parsed *p, RDI_NameMap *mapptr, RDI_ParsedNameMap *out)
|
||||
rdi_parsed_from_name_map(RDI_Parsed *rdi, RDI_NameMap *mapptr, RDI_ParsedNameMap *out)
|
||||
{
|
||||
out->buckets = 0;
|
||||
out->bucket_count = 0;
|
||||
if(mapptr != 0)
|
||||
{
|
||||
out->buckets = (RDI_NameMapBucket*)rdi_data_from_dsec(p, mapptr->bucket_data_idx, sizeof(RDI_NameMapBucket), RDI_DataSectionTag_NameMapBuckets, &out->bucket_count);
|
||||
out->nodes = (RDI_NameMapNode*)rdi_data_from_dsec(p, mapptr->node_data_idx, sizeof(RDI_NameMapNode), RDI_DataSectionTag_NameMapNodes, &out->node_count);
|
||||
RDI_U64 all_buckets_count = 0;
|
||||
RDI_NameMapBucket *all_buckets = rdi_table_from_name(rdi, NameMapBuckets, &all_buckets_count);
|
||||
RDI_U64 all_nodes_count = 0;
|
||||
RDI_NameMapNode *all_nodes = rdi_table_from_name(rdi, NameMapNodes, &all_nodes_count);
|
||||
out->buckets = all_buckets+mapptr->bucket_base_idx;
|
||||
out->nodes = all_nodes+mapptr->node_base_idx;
|
||||
out->bucket_count = mapptr->bucket_count;
|
||||
out->node_count = mapptr->node_count;
|
||||
if(mapptr->bucket_base_idx > all_buckets_count)
|
||||
{
|
||||
out->buckets = 0;
|
||||
out->bucket_count = 0;
|
||||
}
|
||||
if(mapptr->node_base_idx > all_nodes_count)
|
||||
{
|
||||
out->nodes = 0;
|
||||
out->node_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,49 +495,20 @@ rdi_matches_from_map_node(RDI_Parsed *p, RDI_NameMapNode *node, RDI_U32 *n_out)
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ High-Level Composite Lookup Functions
|
||||
|
||||
//- procedures
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdi_first_voff_from_proc(RDI_Parsed *p, RDI_U32 proc_id)
|
||||
rdi_first_voff_from_proc_idx(RDI_Parsed *rdi, RDI_U32 proc_idx)
|
||||
{
|
||||
RDI_U64 result = 0;
|
||||
if(0 < proc_id && proc_id < p->procedures_count)
|
||||
{
|
||||
RDI_Procedure *proc = p->procedures + proc_id;
|
||||
RDI_U32 scope_id = proc->root_scope_idx;
|
||||
if(0 < scope_id && scope_id < p->scopes_count)
|
||||
{
|
||||
RDI_Scope *scope = p->scopes + scope_id;
|
||||
if(scope->voff_range_first < scope->voff_range_opl && scope->voff_range_first < p->scope_voffs_count)
|
||||
{
|
||||
result = p->scope_voffs[scope->voff_range_first];
|
||||
}
|
||||
}
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
|
||||
RDI_U64 *voffs = rdi_element_from_name_idx(rdi, ScopeVOffData, scope->voff_range_first);
|
||||
result = *voffs;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Parser Helpers
|
||||
|
||||
RDI_PROC void*
|
||||
rdi_data_from_dsec(RDI_Parsed *parsed, RDI_U32 idx, RDI_U32 item_size, RDI_DataSectionTag expected_tag, RDI_U64 *count_out)
|
||||
{
|
||||
void *result = 0;
|
||||
RDI_U32 count_result = 0;
|
||||
if(0 < idx && idx < parsed->dsec_count)
|
||||
{
|
||||
RDI_DataSection *ds = parsed->dsecs + idx;
|
||||
if(ds->tag == expected_tag)
|
||||
{
|
||||
RDI_U64 encoded_opl = ds->off + ds->encoded_size;
|
||||
if(encoded_opl <= parsed->raw_data_size)
|
||||
{
|
||||
count_result = ds->unpacked_size/item_size;
|
||||
result = (parsed->raw_data + ds->off);
|
||||
}
|
||||
}
|
||||
}
|
||||
*count_out = count_result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,83 +19,17 @@ typedef enum RDI_ParseStatus
|
||||
RDI_ParseStatus_HeaderDoesNotMatch = 1,
|
||||
RDI_ParseStatus_UnsupportedVersionNumber = 2,
|
||||
RDI_ParseStatus_InvalidDataSecionLayout = 3,
|
||||
RDI_ParseStatus_MissingStringDataSection = 4,
|
||||
RDI_ParseStatus_MissingStringTableSection = 5,
|
||||
RDI_ParseStatus_MissingIndexRunSection = 6,
|
||||
RDI_ParseStatus_MissingRequiredSection = 4,
|
||||
}
|
||||
RDI_ParseStatus;
|
||||
|
||||
typedef struct RDI_Parsed RDI_Parsed;
|
||||
struct RDI_Parsed
|
||||
{
|
||||
// raw data & primary data sections
|
||||
RDI_U8 *raw_data;
|
||||
RDI_U64 raw_data_size;
|
||||
RDI_DataSection *dsecs;
|
||||
RDI_U64 dsec_count;
|
||||
RDI_U32 dsec_idx[RDI_DataSectionTag_PRIMARY_COUNT];
|
||||
|
||||
// parsed universal data structures (strings, index runs)
|
||||
RDI_U8* string_data;
|
||||
RDI_U64 string_data_size;
|
||||
RDI_U32* string_offs;
|
||||
RDI_U64 string_count;
|
||||
RDI_U32* idx_run_data;
|
||||
RDI_U32 idx_run_count;
|
||||
|
||||
// extracted info & tables (any of these may be empty or null, even with a successful parse)
|
||||
RDI_TopLevelInfo* top_level_info;
|
||||
RDI_BinarySection* binary_sections;
|
||||
RDI_U64 binary_sections_count;
|
||||
RDI_FilePathNode* file_paths;
|
||||
RDI_U64 file_paths_count;
|
||||
RDI_SourceFile* source_files;
|
||||
RDI_U64 source_files_count;
|
||||
RDI_LineTable* line_tables;
|
||||
RDI_U64 line_tables_count;
|
||||
RDI_SourceLineMap* source_line_maps;
|
||||
RDI_U64 source_line_maps_count;
|
||||
RDI_U64* line_info_voffs;
|
||||
RDI_U64 line_info_voffs_count;
|
||||
RDI_Line* line_info_lines;
|
||||
RDI_U64 line_info_lines_count;
|
||||
RDI_Column* line_info_columns;
|
||||
RDI_U64 line_info_columns_count;
|
||||
RDI_Unit* units;
|
||||
RDI_U64 units_count;
|
||||
RDI_VMapEntry* unit_vmap;
|
||||
RDI_U64 unit_vmap_count;
|
||||
RDI_TypeNode* type_nodes;
|
||||
RDI_U64 type_nodes_count;
|
||||
RDI_UDT* udts;
|
||||
RDI_U64 udts_count;
|
||||
RDI_Member* members;
|
||||
RDI_U64 members_count;
|
||||
RDI_EnumMember* enum_members;
|
||||
RDI_U64 enum_members_count;
|
||||
RDI_GlobalVariable* global_variables;
|
||||
RDI_U64 global_variables_count;
|
||||
RDI_VMapEntry* global_vmap;
|
||||
RDI_U64 global_vmap_count;
|
||||
RDI_ThreadVariable* thread_variables;
|
||||
RDI_U64 thread_variables_count;
|
||||
RDI_Procedure* procedures;
|
||||
RDI_U64 procedures_count;
|
||||
RDI_Scope* scopes;
|
||||
RDI_U64 scopes_count;
|
||||
RDI_U64* scope_voffs;
|
||||
RDI_U64 scope_voffs_count;
|
||||
RDI_VMapEntry* scope_vmap;
|
||||
RDI_U64 scope_vmap_count;
|
||||
RDI_Local* locals;
|
||||
RDI_U64 locals_count;
|
||||
RDI_LocationBlock* location_blocks;
|
||||
RDI_U64 location_blocks_count;
|
||||
RDI_U8* location_data;
|
||||
RDI_U64 location_data_size;
|
||||
RDI_NameMap* name_maps;
|
||||
RDI_U64 name_maps_count;
|
||||
RDI_NameMap* name_maps_by_kind[RDI_NameMapKind_COUNT];
|
||||
RDI_Section *sections;
|
||||
RDI_U64 sections_count;
|
||||
};
|
||||
|
||||
typedef struct RDI_ParsedLineTable RDI_ParsedLineTable;
|
||||
@@ -142,29 +76,31 @@ struct RDI_ParsedNameMap
|
||||
////////////////////////////////
|
||||
//~ Global Nils
|
||||
|
||||
#if !defined(RDI_DISABLE_NILS)
|
||||
static RDI_TopLevelInfo rdi_top_level_info_nil = {0};
|
||||
static RDI_BinarySection rdi_binary_section_nil = {0};
|
||||
static RDI_FilePathNode rdi_file_path_node_nil = {0};
|
||||
static RDI_SourceFile rdi_source_file_nil = {0};
|
||||
static RDI_LineTable rdi_line_table_nil = {0};
|
||||
static RDI_SourceLineMap rdi_source_line_map_nil = {0};
|
||||
static RDI_Line rdi_line_nil = {0};
|
||||
static RDI_Column rdi_column_nil = {0};
|
||||
static RDI_Unit rdi_unit_nil = {0};
|
||||
static RDI_VMapEntry rdi_vmap_entry_nil = {0};
|
||||
static RDI_TypeNode rdi_type_node_nil = {0};
|
||||
static RDI_UDT rdi_udt_nil = {0};
|
||||
static RDI_Member rdi_member_nil = {0};
|
||||
static RDI_EnumMember rdi_enum_member_nil = {0};
|
||||
static RDI_GlobalVariable rdi_global_variable_nil = {0};
|
||||
static RDI_ThreadVariable rdi_thread_variable_nil = {0};
|
||||
static RDI_Procedure rdi_procedure_nil = {0};
|
||||
static RDI_Scope rdi_scope_nil = {0};
|
||||
static RDI_U64 rdi_voff_nil = 0;
|
||||
static RDI_LocationBlock rdi_location_block_nil = {0};
|
||||
static RDI_Local rdi_local_nil = {0};
|
||||
#endif
|
||||
static union
|
||||
{
|
||||
RDI_TopLevelInfo top_level_info;
|
||||
RDI_BinarySection binary_section;
|
||||
RDI_FilePathNode file_path_node;
|
||||
RDI_SourceFile source_file;
|
||||
RDI_LineTable line_table;
|
||||
RDI_SourceLineMap source_line_map;
|
||||
RDI_Line line;
|
||||
RDI_Column column;
|
||||
RDI_Unit unit;
|
||||
RDI_VMapEntry vmap_entry;
|
||||
RDI_TypeNode type_node;
|
||||
RDI_UDT udt;
|
||||
RDI_Member member;
|
||||
RDI_EnumMember enum_member;
|
||||
RDI_GlobalVariable global_variable;
|
||||
RDI_ThreadVariable thread_variable;
|
||||
RDI_Procedure procedure;
|
||||
RDI_Scope scope;
|
||||
RDI_U64 voff;
|
||||
RDI_LocationBlock location_block;
|
||||
RDI_Local local;
|
||||
}
|
||||
rdi_nil_element_union = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Top-Level Parsing API
|
||||
@@ -172,28 +108,32 @@ static RDI_Local rdi_local_nil = {0};
|
||||
RDI_PROC RDI_ParseStatus rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Parsed Info Extraction Helpers
|
||||
//~ Base Parsed Info Extraction Helpers
|
||||
|
||||
//- element extractor
|
||||
#define rdi_element_from_idx(parsed, name, idx) ((0 <= (idx) && (idx) < (parsed)->name##_count) ? &(parsed)->name[idx] : (parsed)->name ? &(parsed)->name[0] : 0)
|
||||
//- section table/element raw data extraction
|
||||
RDI_PROC void *rdi_section_raw_data_from_kind(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_SectionEncoding *encoding_out, RDI_U64 *size_out);
|
||||
RDI_PROC void *rdi_section_raw_table_from_kind(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_U64 *count_out);
|
||||
RDI_PROC void *rdi_section_raw_element_from_kind_idx(RDI_Parsed *rdi, RDI_SectionKind kind, RDI_U64 idx);
|
||||
#define rdi_table_from_name(rdi, name, count_out) (RDI_SectionElementType_##name *)rdi_section_raw_table_from_kind((rdi), RDI_SectionKind_##name, (count_out))
|
||||
#define rdi_element_from_name_idx(rdi, name, idx) (RDI_SectionElementType_##name *)rdi_section_raw_element_from_kind_idx((rdi), RDI_SectionKind_##name, (idx))
|
||||
|
||||
//- top-level info
|
||||
//- info about whole parse
|
||||
RDI_PROC RDI_U64 rdi_decompressed_size_from_parsed(RDI_Parsed *rdi);
|
||||
|
||||
//- strings
|
||||
RDI_PROC RDI_U8 *rdi_string_from_idx(RDI_Parsed *parsed, RDI_U32 idx, RDI_U64 *len_out);
|
||||
RDI_PROC RDI_U8 *rdi_string_from_idx(RDI_Parsed *rdi, RDI_U32 idx, RDI_U64 *len_out);
|
||||
|
||||
//- index runs
|
||||
RDI_PROC RDI_U32 *rdi_idx_run_from_first_count(RDI_Parsed *parsed, RDI_U32 first, RDI_U32 raw_count, RDI_U32 *n_out);
|
||||
RDI_PROC RDI_U32 *rdi_idx_run_from_first_count(RDI_Parsed *rdi, RDI_U32 raw_first, RDI_U32 raw_count, RDI_U32 *n_out);
|
||||
|
||||
//- line info
|
||||
RDI_PROC void rdi_parsed_from_line_table(RDI_Parsed *p, RDI_LineTable *line_table, RDI_ParsedLineTable *out);
|
||||
RDI_PROC void rdi_parsed_from_line_table(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_ParsedLineTable *out);
|
||||
RDI_PROC RDI_U64 rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff);
|
||||
RDI_PROC void rdi_parsed_from_source_line_map(RDI_Parsed *p, RDI_SourceLineMap *map, RDI_ParsedSourceLineMap *out);
|
||||
RDI_PROC void rdi_parsed_from_source_line_map(RDI_Parsed *rdi, RDI_SourceLineMap *map, RDI_ParsedSourceLineMap *out);
|
||||
RDI_PROC RDI_U64 *rdi_line_voffs_from_num(RDI_ParsedSourceLineMap *map, RDI_U32 linenum, RDI_U32 *n_out);
|
||||
|
||||
//- vmap lookups
|
||||
RDI_PROC RDI_U64 rdi_vmap_idx_from_voff(RDI_VMapEntry *vmap, RDI_U32 vmap_count, RDI_U64 voff);
|
||||
RDI_PROC RDI_U64 rdi_vmap_idx_from_voff(RDI_VMapEntry *vmap, RDI_U64 vmap_count, RDI_U64 voff);
|
||||
|
||||
//- name maps
|
||||
RDI_PROC RDI_NameMap *rdi_name_map_from_kind(RDI_Parsed *p, RDI_NameMapKind kind);
|
||||
@@ -201,16 +141,15 @@ RDI_PROC void rdi_name_map_parse(RDI_Parsed* p, RDI_NameMap *mapptr, RDI_ParsedN
|
||||
RDI_PROC RDI_NameMapNode *rdi_name_map_lookup(RDI_Parsed *p, RDI_ParsedNameMap *map, RDI_U8 *str, RDI_U64 len);
|
||||
RDI_PROC RDI_U32 *rdi_matches_from_map_node(RDI_Parsed *p, RDI_NameMapNode *node, RDI_U32 *n_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ High-Level Composite Lookup Functions
|
||||
|
||||
//- procedures
|
||||
RDI_PROC RDI_U64 rdi_first_voff_from_proc(RDI_Parsed *p, RDI_U32 proc_id);
|
||||
RDI_PROC RDI_U64 rdi_first_voff_from_proc_idx(RDI_Parsed *rdi, RDI_U32 proc_idx);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Parser Helpers
|
||||
|
||||
#define rdi_parse__min(a,b) (((a)<(b))?(a):(b))
|
||||
#define rdi_parse__extract_primary(p,outptr,outn,pritag) \
|
||||
( (*(void**)&(outptr)) = \
|
||||
rdi_data_from_dsec((p),(p)->dsec_idx[pritag],sizeof(*(outptr)),(pritag),(outn)) )
|
||||
RDI_PROC void *rdi_data_from_dsec(RDI_Parsed *p, RDI_U32 idx, RDI_U32 item_size, RDI_DataSectionTag expected_tag, RDI_U64 *n_out);
|
||||
|
||||
#endif // RDI_FORMAT_PARSE_H
|
||||
|
||||
+65
-113
@@ -480,7 +480,7 @@ rdim_idx_from_src_file(RDIM_SrcFile *src_file)
|
||||
RDI_U64 idx = 0;
|
||||
if(src_file != 0 && src_file->chunk != 0)
|
||||
{
|
||||
idx = src_file->chunk->base_idx + (src_file - src_file->chunk->v) + 1;
|
||||
idx = (src_file->chunk->base_idx + (src_file - src_file->chunk->v) + 1);
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
@@ -1109,48 +1109,6 @@ rdim_location_set_push_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM
|
||||
scopes->location_count +=1;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked File Layout Calculations
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_bake_section_count_from_params(RDIM_BakeParams *params)
|
||||
{
|
||||
RDI_U64 section_count = 0;
|
||||
{
|
||||
section_count += RDI_DataSectionTag_PRIMARY_COUNT;
|
||||
section_count += RDI_NameMapKind_COUNT-1; // PER-NAME-MAP buckets section
|
||||
section_count += RDI_NameMapKind_COUNT-1; // PER-NAME-MAP nodes section
|
||||
}
|
||||
return section_count;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
rdim_bake_section_idx_from_params_tag_idx(RDIM_BakeParams *params, RDI_DataSectionTag tag, RDI_U64 idx)
|
||||
{
|
||||
RDI_U64 result = 0;
|
||||
if(tag < RDI_DataSectionTag_PRIMARY_COUNT)
|
||||
{
|
||||
result = (RDI_U64)tag;
|
||||
}
|
||||
else switch(tag)
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
//- rjf: per-name-map sections
|
||||
case (RDI_U32)RDI_DataSectionTag_NameMapBuckets:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 0*(RDI_NameMapKind_COUNT-1) + (idx-1)%(RDI_NameMapKind_COUNT-1);
|
||||
}break;
|
||||
case (RDI_U32)RDI_DataSectionTag_NameMapNodes:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 1*(RDI_NameMapKind_COUNT-1) + (idx-1)%(RDI_NameMapKind_COUNT-1);
|
||||
}break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
@@ -1520,10 +1478,10 @@ rdim_bake_string_map_tight_from_loose(RDIM_Arena *arena, RDIM_BakeStringMapTopol
|
||||
return m;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64
|
||||
RDI_PROC RDI_U32
|
||||
rdim_bake_idx_from_string(RDIM_BakeStringMapTight *map, RDIM_String8 string)
|
||||
{
|
||||
RDI_U64 idx = 0;
|
||||
RDI_U32 idx = 0;
|
||||
if(string.RDIM_String8_SizeMember != 0)
|
||||
{
|
||||
RDI_U64 hash = rdi_hash(string.RDIM_String8_BaseMember, string.RDIM_String8_SizeMember);
|
||||
@@ -1696,7 +1654,12 @@ RDI_PROC RDI_U32
|
||||
rdim_bake_path_node_idx_from_string(RDIM_BakePathTree *tree, RDIM_String8 string)
|
||||
{
|
||||
RDIM_BakePathNode *path_node = rdim_bake_path_node_from_string(tree, string);
|
||||
return path_node ? path_node->idx : 0;
|
||||
RDI_U32 result = 0;
|
||||
if(path_node != 0)
|
||||
{
|
||||
result = path_node->idx;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_BakePathNode *
|
||||
@@ -1833,11 +1796,11 @@ rdim_bake_section_list_push(RDIM_Arena *arena, RDIM_BakeSectionList *list)
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_BakeSection *
|
||||
rdim_bake_section_list_push_new_unpacked(RDIM_Arena *arena, RDIM_BakeSectionList *list, void *data, RDI_U64 size, RDI_DataSectionTag tag, RDI_U64 tag_idx)
|
||||
rdim_bake_section_list_push_new_unpacked(RDIM_Arena *arena, RDIM_BakeSectionList *list, void *data, RDI_U64 size, RDI_SectionKind tag, RDI_U64 tag_idx)
|
||||
{
|
||||
RDIM_BakeSection *section = rdim_bake_section_list_push(arena, list);
|
||||
section->data = data;
|
||||
section->encoding = RDI_DataSectionEncoding_Unpacked;
|
||||
section->encoding = RDI_SectionEncoding_Unpacked;
|
||||
section->encoded_size = size;
|
||||
section->unpacked_size = size;
|
||||
section->tag = tag;
|
||||
@@ -2101,8 +2064,8 @@ rdim_bake_name_map_from_kind_params(RDIM_Arena *arena, RDI_NameMapKind kind, RDI
|
||||
{
|
||||
for(RDI_U64 idx = 0; idx < n->count; idx += 1)
|
||||
{
|
||||
RDI_U32 src_file_idx = (RDI_U32)rdim_idx_from_src_file(&n->v[idx]); // TODO(rjf): @u64_to_u32
|
||||
rdim_bake_name_map_push(arena, map, n->v[idx].normal_full_path, src_file_idx);
|
||||
RDI_U64 src_file_idx = rdim_idx_from_src_file(&n->v[idx]);
|
||||
rdim_bake_name_map_push(arena, map, n->v[idx].normal_full_path, (RDI_U32)src_file_idx); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
}break;
|
||||
@@ -2229,11 +2192,11 @@ rdim_bake_top_level_info_section_list_from_params(RDIM_Arena *arena, RDIM_BakeSt
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
RDI_TopLevelInfo *dst_tli = rdim_push_array(arena, RDI_TopLevelInfo, 1);
|
||||
RDIM_TopLevelInfo *src_tli = ¶ms->top_level_info;
|
||||
dst_tli->arch = src_tli->arch;
|
||||
dst_tli->exe_name_string_idx = rdim_bake_idx_from_string(strings, src_tli->exe_name);
|
||||
dst_tli->exe_hash = src_tli->exe_hash;
|
||||
dst_tli->voff_max = src_tli->voff_max;
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_tli, sizeof(*dst_tli), RDI_DataSectionTag_TopLevelInfo, 0);
|
||||
dst_tli->arch = src_tli->arch;
|
||||
dst_tli->exe_name_string_idx = rdim_bake_idx_from_string(strings, src_tli->exe_name);
|
||||
dst_tli->exe_hash = src_tli->exe_hash;
|
||||
dst_tli->voff_max = src_tli->voff_max;
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_tli, sizeof(*dst_tli), RDI_SectionKind_TopLevelInfo, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2257,7 +2220,7 @@ rdim_bake_binary_section_section_list_from_params(RDIM_Arena *arena, RDIM_BakeSt
|
||||
dst->foff_first = src->foff_first;
|
||||
dst->foff_opl = src->foff_opl;
|
||||
}
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_base, sizeof(*dst_base)*dst_idx, RDI_DataSectionTag_BinarySections, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_base, sizeof(*dst_base)*dst_idx, RDI_SectionKind_BinarySections, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2275,8 +2238,8 @@ rdim_bake_unit_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTig
|
||||
{
|
||||
RDIM_Unit *src = &src_n->v[src_chunk_idx];
|
||||
RDI_Unit *dst = &dst_base[dst_idx];
|
||||
dst->unit_name_string_idx = (RDI_U32)rdim_bake_idx_from_string(strings, src->unit_name); // TODO(rjf): @u64_to_u32
|
||||
dst->compiler_name_string_idx = (RDI_U32)rdim_bake_idx_from_string(strings, src->compiler_name); // TODO(rjf): @u64_to_u32
|
||||
dst->unit_name_string_idx = rdim_bake_idx_from_string(strings, src->unit_name);
|
||||
dst->compiler_name_string_idx = rdim_bake_idx_from_string(strings, src->compiler_name);
|
||||
dst->source_file_path_node = rdim_bake_path_node_idx_from_string(path_tree, src->source_file);
|
||||
dst->object_file_path_node = rdim_bake_path_node_idx_from_string(path_tree, src->object_file);
|
||||
dst->archive_file_path_node = rdim_bake_path_node_idx_from_string(path_tree, src->archive_file);
|
||||
@@ -2285,7 +2248,7 @@ rdim_bake_unit_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTig
|
||||
dst->line_table_idx = (RDI_U32)rdim_idx_from_line_table(src->line_table); // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
}
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_base, sizeof(*dst_base)*dst_idx, RDI_DataSectionTag_Units, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_base, sizeof(*dst_base)*dst_idx, RDI_SectionKind_Units, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2360,7 +2323,7 @@ rdim_bake_unit_vmap_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams
|
||||
//- rjf: build section
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
RDI_U64 unit_vmap_size = sizeof(unit_vmap.vmap[0])*(unit_vmap.count+1);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_vmap.vmap, unit_vmap_size, RDI_DataSectionTag_UnitVmap, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_vmap.vmap, unit_vmap_size, RDI_SectionKind_UnitVMap, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2612,11 +2575,11 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
////////////////////////////
|
||||
//- rjf: build sections
|
||||
//
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_files, sizeof(RDI_SourceFile)*dst_files_count, RDI_DataSectionTag_SourceFiles, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_maps, sizeof(RDI_SourceLineMap)*dst_maps_count, RDI_DataSectionTag_SourceLineMaps, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_nums, sizeof(RDI_U32)*dst_nums_idx, RDI_DataSectionTag_SourceLineMapNumbers, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_rngs, sizeof(RDI_U32)*dst_rngs_idx, RDI_DataSectionTag_SourceLineMapRanges, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_voffs,sizeof(RDI_U64)*dst_voffs_idx, RDI_DataSectionTag_SourceLineMapVOffs, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_files, sizeof(RDI_SourceFile)*dst_files_count, RDI_SectionKind_SourceFiles, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_maps, sizeof(RDI_SourceLineMap)*dst_maps_count, RDI_SectionKind_SourceLineMaps, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_nums, sizeof(RDI_U32)*dst_nums_idx, RDI_SectionKind_SourceLineMapNumbers, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_rngs, sizeof(RDI_U32)*dst_rngs_idx, RDI_SectionKind_SourceLineMapRanges, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, source_line_map_voffs,sizeof(RDI_U64)*dst_voffs_idx, RDI_SectionKind_SourceLineMapVOffs, 0);
|
||||
|
||||
rdim_scratch_end(scratch);
|
||||
return sections;
|
||||
@@ -2749,10 +2712,10 @@ rdim_bake_line_table_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams
|
||||
//- rjf: produce sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
{
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_line_tables, sizeof(RDI_LineTable)*params->line_tables.total_count, RDI_DataSectionTag_LineTables, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_line_voffs, sizeof(RDI_U64) * (params->line_tables.total_line_count + params->line_tables.total_seq_count), RDI_DataSectionTag_LineInfoVoffs, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_lines, sizeof(RDI_Line) * (params->line_tables.total_line_count + params->line_tables.total_seq_count), RDI_DataSectionTag_LineInfoLines, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_cols, sizeof(RDI_Column) * params->line_tables.total_col_count, RDI_DataSectionTag_LineInfoColumns, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_line_tables, sizeof(RDI_LineTable)*params->line_tables.total_count, RDI_SectionKind_LineTables, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_line_voffs, sizeof(RDI_U64) * (params->line_tables.total_line_count + params->line_tables.total_seq_count), RDI_SectionKind_LineInfoVOffs, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_lines, sizeof(RDI_Line) * (params->line_tables.total_line_count + params->line_tables.total_seq_count), RDI_SectionKind_LineInfoLines, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_cols, sizeof(RDI_Column) * params->line_tables.total_col_count, RDI_SectionKind_LineInfoColumns, 0);
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
@@ -2828,7 +2791,7 @@ rdim_bake_type_node_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringM
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, type_nodes, sizeof(RDI_TypeNode)*(params->types.total_count+1), RDI_DataSectionTag_TypeNodes, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, type_nodes, sizeof(RDI_TypeNode)*(params->types.total_count+1), RDI_SectionKind_TypeNodes, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2896,9 +2859,9 @@ rdim_bake_udt_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTigh
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, udts, sizeof(RDI_UDT) * (params->udts.total_count+1), RDI_DataSectionTag_UDTs, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, members , sizeof(RDI_Member) * (params->udts.total_member_count+1), RDI_DataSectionTag_Members, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, enum_members, sizeof(RDI_EnumMember) * (params->udts.total_enum_val_count+1), RDI_DataSectionTag_EnumMembers, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, udts, sizeof(RDI_UDT) * (params->udts.total_count+1), RDI_SectionKind_UDTs, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, members , sizeof(RDI_Member) * (params->udts.total_member_count+1), RDI_SectionKind_Members, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, enum_members, sizeof(RDI_EnumMember) * (params->udts.total_enum_val_count+1), RDI_SectionKind_EnumMembers, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2940,7 +2903,7 @@ rdim_bake_global_variable_section_list_from_params(RDIM_Arena *arena, RDIM_BakeS
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, global_variables, sizeof(RDI_GlobalVariable)*(params->global_variables.total_count+1), RDI_DataSectionTag_GlobalVariables, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, global_variables, sizeof(RDI_GlobalVariable)*(params->global_variables.total_count+1), RDI_SectionKind_GlobalVariables, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3020,7 +2983,7 @@ rdim_bake_global_vmap_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParam
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, global_vmap.vmap, sizeof(RDI_VMapEntry)*(global_vmap.count+1), RDI_DataSectionTag_GlobalVmap, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, global_vmap.vmap, sizeof(RDI_VMapEntry)*(global_vmap.count+1), RDI_SectionKind_GlobalVMap, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3062,7 +3025,7 @@ rdim_bake_thread_variable_section_list_from_params(RDIM_Arena *arena, RDIM_BakeS
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, thread_variables, sizeof(RDI_ThreadVariable)*(params->thread_variables.total_count+1), RDI_DataSectionTag_ThreadVariables, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, thread_variables, sizeof(RDI_ThreadVariable)*(params->thread_variables.total_count+1), RDI_SectionKind_ThreadVariables, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3105,7 +3068,7 @@ rdim_bake_procedure_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringM
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, procedures, sizeof(RDI_Procedure)*(params->procedures.total_count+1), RDI_DataSectionTag_Procedures, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, procedures, sizeof(RDI_Procedure)*(params->procedures.total_count+1), RDI_SectionKind_Procedures, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3272,11 +3235,11 @@ rdim_bake_scope_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTi
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
RDIM_ProfScope("push all symbol info sections")
|
||||
{
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scopes, sizeof(RDI_Scope) * (params->scopes.total_count+1), RDI_DataSectionTag_Scopes, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scope_voffs, sizeof(RDI_U64) * (params->scopes.scope_voff_count+1), RDI_DataSectionTag_ScopeVoffData, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, locals, sizeof(RDI_Local) * (params->scopes.local_count+1), RDI_DataSectionTag_Locals, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, location_blocks, sizeof(RDI_LocationBlock) * (params->scopes.location_count+1), RDI_DataSectionTag_LocationBlocks, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, location_data_blob.str, location_data_blob.size, RDI_DataSectionTag_LocationData, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scopes, sizeof(RDI_Scope) * (params->scopes.total_count+1), RDI_SectionKind_Scopes, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scope_voffs, sizeof(RDI_U64) * (params->scopes.scope_voff_count+1), RDI_SectionKind_ScopeVOffData, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, locals, sizeof(RDI_Local) * (params->scopes.local_count+1), RDI_SectionKind_Locals, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, location_blocks, sizeof(RDI_LocationBlock) * (params->scopes.location_count+1), RDI_SectionKind_LocationBlocks, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, location_data_blob.str, location_data_blob.size, RDI_SectionKind_LocationData, 0);
|
||||
}
|
||||
rdim_scratch_end(scratch);
|
||||
return sections;
|
||||
@@ -3334,7 +3297,7 @@ rdim_bake_scope_vmap_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams
|
||||
|
||||
//- rjf: build sections
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scope_vmap.vmap, sizeof(RDI_VMapEntry)*(scope_vmap.count+1), RDI_DataSectionTag_ScopeVmap, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, scope_vmap.vmap, sizeof(RDI_VMapEntry)*(scope_vmap.count+1), RDI_SectionKind_ScopeVMap, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3345,22 +3308,12 @@ rdim_bake_top_level_name_map_section_list_from_params_maps(RDIM_Arena *arena, RD
|
||||
{
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
|
||||
//- rjf: count the # of name maps we have with any content
|
||||
RDI_U32 name_map_count = 0;
|
||||
for(RDI_NameMapKind k = (RDI_NameMapKind)(RDI_NameMapKind_NULL+1);
|
||||
k < RDI_NameMapKind_COUNT;
|
||||
k = (RDI_NameMapKind)(k+1))
|
||||
{
|
||||
if(name_maps[k] != 0 && name_maps[k]->name_count != 0)
|
||||
{
|
||||
name_map_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: allocate & fill baked name maps
|
||||
RDI_NameMap *dst_maps = rdim_push_array(arena, RDI_NameMap, name_map_count);
|
||||
RDI_NameMap *dst_maps = rdim_push_array(arena, RDI_NameMap, RDI_NameMapKind_COUNT);
|
||||
{
|
||||
RDI_U64 dst_map_idx = 0;
|
||||
RDI_U64 dst_map_bucket_idx = 0;
|
||||
RDI_U64 dst_map_node_idx = 0;
|
||||
for(RDI_NameMapKind k = (RDI_NameMapKind)(RDI_NameMapKind_NULL+1);
|
||||
k < RDI_NameMapKind_COUNT;
|
||||
k = (RDI_NameMapKind)(k+1))
|
||||
@@ -3369,14 +3322,16 @@ rdim_bake_top_level_name_map_section_list_from_params_maps(RDIM_Arena *arena, RD
|
||||
RDIM_BakeNameMap *src_map = name_maps[k];
|
||||
if(src_map == 0 || src_map->name_count == 0) { continue; }
|
||||
dst_map->kind = k;
|
||||
dst_map->bucket_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_NameMapBuckets, (RDI_U64)k); // TODO(rjf): @u64_to_u32
|
||||
dst_map->node_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_NameMapNodes, (RDI_U64)k); // TODO(rjf): @u64_to_u32
|
||||
dst_map->bucket_base_idx = (RDI_U32)dst_map_bucket_idx; // TODO(rjf): @u64_to_u32
|
||||
dst_map->node_base_idx = (RDI_U32)dst_map_node_idx; // TODO(rjf): @u64_to_u32
|
||||
dst_map->bucket_count = (RDI_U32)src_map->name_count; // TODO(rjf): @u64_to_u32
|
||||
dst_map->node_count = (RDI_U32)src_map->name_count; // TODO(rjf): @u64_to_u32
|
||||
dst_map_idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: push section for all name maps
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_maps, sizeof(RDI_NameMap)*name_map_count, RDI_DataSectionTag_NameMaps, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_maps, sizeof(RDI_NameMap)*RDI_NameMapKind_COUNT, RDI_SectionKind_NameMaps, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3478,8 +3433,8 @@ rdim_bake_name_map_section_list_from_params_kind_map(RDIM_Arena *arena, RDIM_Bak
|
||||
}
|
||||
|
||||
// rjf: sections for buckets/nodes
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, baked_buckets, sizeof(RDI_NameMapBucket)* baked_buckets_count, RDI_DataSectionTag_NameMapBuckets, (RDI_U64)k);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, baked_nodes, sizeof(RDI_NameMapNode) * baked_nodes_count, RDI_DataSectionTag_NameMapNodes, (RDI_U64)k);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, baked_buckets, sizeof(RDI_NameMapBucket)* baked_buckets_count, RDI_SectionKind_NameMapBuckets, (RDI_U64)k);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, baked_nodes, sizeof(RDI_NameMapNode) * baked_nodes_count, RDI_SectionKind_NameMapNodes, (RDI_U64)k);
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
@@ -3515,7 +3470,7 @@ rdim_bake_file_path_section_list_from_path_tree(RDIM_Arena *arena, RDIM_BakeStri
|
||||
}
|
||||
}
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_nodes, sizeof(RDI_FilePathNode)*dst_nodes_count, RDI_DataSectionTag_FilePathNodes, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_nodes, sizeof(RDI_FilePathNode)*dst_nodes_count, RDI_SectionKind_FilePathNodes, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3561,8 +3516,8 @@ rdim_bake_string_section_list_from_string_map(RDIM_Arena *arena, RDIM_BakeString
|
||||
}
|
||||
}
|
||||
}
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, str_offs, sizeof(RDI_U32)*(strings->total_count+1), RDI_DataSectionTag_StringTable, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, buf, off_cursor, RDI_DataSectionTag_StringData, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, str_offs, sizeof(RDI_U32)*(strings->total_count+1), RDI_SectionKind_StringTable, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, buf, off_cursor, RDI_SectionKind_StringData, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3584,7 +3539,7 @@ rdim_bake_idx_run_section_list_from_idx_run_map(RDIM_Arena *arena, RDIM_BakeIdxR
|
||||
out_ptr += node->count;
|
||||
}
|
||||
}
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, idx_data, sizeof(RDI_U32)*idx_runs->idx_count, RDI_DataSectionTag_IndexRuns, 0);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, idx_data, sizeof(RDI_U32)*idx_runs->idx_count, RDI_SectionKind_IndexRuns, 0);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -3599,15 +3554,13 @@ rdim_serialized_strings_from_params_bake_section_list(RDIM_Arena *arena, RDIM_Ba
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: calculate total possible section count, given these params
|
||||
RDI_U64 section_count = rdim_bake_section_count_from_params(params);
|
||||
|
||||
//- rjf: make table for actually laid out sections
|
||||
RDI_U64 section_count = RDI_SectionKind_COUNT;
|
||||
RDIM_BakeSection **bake_sections = rdim_push_array(scratch.arena, RDIM_BakeSection *, section_count);
|
||||
for(RDIM_BakeSectionNode *n = sections->first; n != 0; n = n->next)
|
||||
{
|
||||
RDIM_BakeSection *bake_section = &n->v;
|
||||
RDI_U64 idx = rdim_bake_section_idx_from_params_tag_idx(params, bake_section->tag, bake_section->tag_idx);
|
||||
RDI_U64 idx = (RDI_U64)bake_section->tag;
|
||||
if(0 <= idx && idx < section_count)
|
||||
{
|
||||
if(bake_sections[idx] != 0)
|
||||
@@ -3623,11 +3576,11 @@ rdim_serialized_strings_from_params_bake_section_list(RDIM_Arena *arena, RDIM_Ba
|
||||
|
||||
//- rjf: push empty header & data section table
|
||||
RDI_Header *rdi_header = rdim_push_array(arena, RDI_Header, 1);
|
||||
RDI_DataSection *rdi_sections = rdim_push_array(arena, RDI_DataSection, section_count);
|
||||
RDI_Section *rdi_sections = rdim_push_array(arena, RDI_Section, section_count);
|
||||
rdim_str8_list_push(arena, &strings, rdim_str8_struct(rdi_header));
|
||||
rdim_str8_list_push_align(arena, &strings, 8);
|
||||
U32 data_section_off = (U32)strings.total_size;
|
||||
rdim_str8_list_push(arena, &strings, rdim_str8((RDI_U8 *)rdi_sections, sizeof(RDI_DataSection)*section_count));
|
||||
rdim_str8_list_push(arena, &strings, rdim_str8((RDI_U8 *)rdi_sections, sizeof(RDI_Section)*section_count));
|
||||
|
||||
// rjf: fill baked header
|
||||
{
|
||||
@@ -3643,7 +3596,7 @@ rdim_serialized_strings_from_params_bake_section_list(RDIM_Arena *arena, RDIM_Ba
|
||||
{
|
||||
RDIM_BakeSection *src = bake_sections[src_idx];
|
||||
if(src == 0) { continue; }
|
||||
RDI_DataSection *dst = rdi_sections+dst_idx;
|
||||
RDI_Section *dst = rdi_sections+dst_idx;
|
||||
U64 data_section_off = 0;
|
||||
if(src->encoded_size != 0)
|
||||
{
|
||||
@@ -3651,7 +3604,6 @@ rdim_serialized_strings_from_params_bake_section_list(RDIM_Arena *arena, RDIM_Ba
|
||||
data_section_off = strings.total_size;
|
||||
rdim_str8_list_push(arena, &strings, rdim_str8((RDI_U8 *)src->data, src->encoded_size));
|
||||
}
|
||||
dst->tag = src->tag;
|
||||
dst->encoding = src->encoding;
|
||||
dst->off = data_section_off;
|
||||
dst->encoded_size = src->encoded_size;
|
||||
|
||||
@@ -878,10 +878,10 @@ typedef struct RDIM_BakeSection RDIM_BakeSection;
|
||||
struct RDIM_BakeSection
|
||||
{
|
||||
void *data;
|
||||
RDI_DataSectionEncoding encoding;
|
||||
RDI_SectionEncoding encoding;
|
||||
RDI_U64 encoded_size;
|
||||
RDI_U64 unpacked_size;
|
||||
RDI_DataSectionTag tag;
|
||||
RDI_SectionKind tag;
|
||||
RDI_U64 tag_idx;
|
||||
};
|
||||
|
||||
@@ -1190,12 +1190,6 @@ RDI_PROC RDIM_Location *rdim_push_location_val_reg(RDIM_Arena *arena, RDI_U8 reg
|
||||
//- rjf: location sets
|
||||
RDI_PROC void rdim_location_set_push_case(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_LocationSet *locset, RDIM_Rng1U64 voff_range, RDIM_Location *location);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked File Layout Calculations
|
||||
|
||||
RDI_PROC RDI_U64 rdim_bake_section_count_from_params(RDIM_BakeParams *params);
|
||||
RDI_PROC RDI_U64 rdim_bake_section_idx_from_params_tag_idx(RDIM_BakeParams *params, RDI_DataSectionTag tag, RDI_U64 idx);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: [Baking Helpers] Baked VMap Building
|
||||
|
||||
@@ -1217,7 +1211,7 @@ RDI_PROC RDIM_BakeStringMapBaseIndices rdim_bake_string_map_base_indices_from_ma
|
||||
|
||||
//- rjf: finalized bake string map
|
||||
RDI_PROC RDIM_BakeStringMapTight rdim_bake_string_map_tight_from_loose(RDIM_Arena *arena, RDIM_BakeStringMapTopology *map_topology, RDIM_BakeStringMapBaseIndices *map_base_indices, RDIM_BakeStringMapLoose *map);
|
||||
RDI_PROC RDI_U64 rdim_bake_idx_from_string(RDIM_BakeStringMapTight *map, RDIM_String8 string);
|
||||
RDI_PROC RDI_U32 rdim_bake_idx_from_string(RDIM_BakeStringMapTight *map, RDIM_String8 string);
|
||||
|
||||
//- rjf: bake idx run map reading/writing
|
||||
RDI_PROC RDI_U64 rdim_hash_from_idx_run(RDI_U32 *idx_run, RDI_U32 count);
|
||||
@@ -1236,7 +1230,7 @@ RDI_PROC void rdim_bake_name_map_push(RDIM_Arena *arena, RDIM_BakeNameMap *map,
|
||||
//~ rjf: [Baking Helpers] Data Section List Building Helpers
|
||||
|
||||
RDI_PROC RDIM_BakeSection *rdim_bake_section_list_push(RDIM_Arena *arena, RDIM_BakeSectionList *list);
|
||||
RDI_PROC RDIM_BakeSection *rdim_bake_section_list_push_new_unpacked(RDIM_Arena *arena, RDIM_BakeSectionList *list, void *data, RDI_U64 size, RDI_DataSectionTag tag, RDI_U64 tag_idx);
|
||||
RDI_PROC RDIM_BakeSection *rdim_bake_section_list_push_new_unpacked(RDIM_Arena *arena, RDIM_BakeSectionList *list, void *data, RDI_U64 size, RDI_SectionKind tag, RDI_U64 tag_idx);
|
||||
RDI_PROC void rdim_bake_section_list_concat_in_place(RDIM_BakeSectionList *dst, RDIM_BakeSectionList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -77,7 +77,7 @@ internal TS_TASK_FUNCTION_DEF(p2b_bake_unit_vmap_task__entry_point)
|
||||
switch(n->v.tag)
|
||||
{
|
||||
default:{}break;
|
||||
case RDI_DataSectionTag_UnitVmap:{vmap_section = &n->v;}break;
|
||||
case RDI_SectionKind_UnitVmap:{vmap_section = &n->v;}break;
|
||||
}
|
||||
}
|
||||
if(vmap_section != 0)
|
||||
@@ -116,8 +116,8 @@ internal TS_TASK_FUNCTION_DEF(p2b_bake_unit_task__entry_point)
|
||||
switch(n->v.tag)
|
||||
{
|
||||
default:{}break;
|
||||
case RDI_DataSectionTag_LineInfoVoffs:{voffs_section = &n->v;}break;
|
||||
case RDI_DataSectionTag_LineInfoData: {lines_section = &n->v;}break;
|
||||
case RDI_SectionKind_LineInfoVoffs:{voffs_section = &n->v;}break;
|
||||
case RDI_SectionKind_LineInfoData: {lines_section = &n->v;}break;
|
||||
}
|
||||
}
|
||||
if(voffs_section != 0 && lines_section != 0)
|
||||
|
||||
+44
-44
@@ -5,14 +5,14 @@
|
||||
//~ rjf: RDI Enum -> String Functions
|
||||
|
||||
internal String8
|
||||
rdi_string_from_data_section_tag(RDI_DataSectionTag v)
|
||||
rdi_string_from_data_section_kind(RDI_SectionKind v)
|
||||
{
|
||||
String8 result = str8_lit("<invalid RDI_DataSectionTag>");
|
||||
String8 result = str8_lit("<invalid RDI_SectionKind>");
|
||||
switch(v)
|
||||
{
|
||||
default:{}break;
|
||||
#define X(name) case RDI_DataSectionTag_##name:{result = str8_lit(#name);}break;
|
||||
RDI_DataSectionTag_XList
|
||||
#define X(name, lower, type) case RDI_SectionKind_##name:{result = str8_lit(#name);}break;
|
||||
RDI_SectionKind_XList
|
||||
#undef X
|
||||
}
|
||||
return result;
|
||||
@@ -134,35 +134,35 @@ rdi_stringize_link_flags(Arena *arena, String8List *out, RDI_LinkFlags flags)
|
||||
global char rdi_stringize_spaces[] = " ";
|
||||
|
||||
internal void
|
||||
rdi_stringize_data_sections(Arena *arena, String8List *out, RDI_Parsed *parsed, U32 indent_level)
|
||||
rdi_stringize_data_sections(Arena *arena, String8List *out, RDI_Parsed *rdi, U32 indent_level)
|
||||
{
|
||||
U64 data_section_count = parsed->dsec_count;
|
||||
RDI_DataSection *ptr = parsed->dsecs;
|
||||
for(U64 i = 0; i < data_section_count; i += 1, ptr += 1)
|
||||
for(U64 idx = 0; idx < rdi->sections_count; idx += 1)
|
||||
{
|
||||
String8 tag_str = rdi_string_from_data_section_tag(ptr->tag);
|
||||
str8_list_pushf(arena, out, "%.*sdata_section[%5u] = {0x%08llx, %7u, %7u} %.*s\n",
|
||||
RDI_SectionKind kind = (RDI_SectionKind)idx;
|
||||
RDI_Section *section = &rdi->sections[idx];
|
||||
String8 kind_str = rdi_string_from_data_section_kind(kind);
|
||||
str8_list_pushf(arena, out, "%.*sdata_section[%5I64u] = {0x%08llx, %7u, %7u} %S\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
i, ptr->off, ptr->encoded_size, ptr->unpacked_size, str8_varg(tag_str));
|
||||
idx, section->off, section->encoded_size, section->unpacked_size, kind_str);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_top_level_info(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_TopLevelInfo *tli, U32 indent_level)
|
||||
rdi_stringize_top_level_info(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_TopLevelInfo *tli, U32 indent_level)
|
||||
{
|
||||
String8 arch_str = rdi_string_from_arch(tli->arch);
|
||||
String8 exe_name = {0};
|
||||
exe_name.str = rdi_string_from_idx(parsed, tli->exe_name_string_idx, &exe_name.size);
|
||||
exe_name.str = rdi_string_from_idx(rdi, tli->exe_name_string_idx, &exe_name.size);
|
||||
str8_list_pushf(arena, out, "%.*sarch=%.*s\n", indent_level, rdi_stringize_spaces, str8_varg(arch_str));
|
||||
str8_list_pushf(arena, out, "%.*sexe_name='%.*s'\n", indent_level, rdi_stringize_spaces, str8_varg(exe_name));
|
||||
str8_list_pushf(arena, out, "%.*svoff_max=0x%08llx\n", indent_level, rdi_stringize_spaces, tli->voff_max);
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_BinarySection *bin_section, U32 indent_level)
|
||||
rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_BinarySection *bin_section, U32 indent_level)
|
||||
{
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, bin_section->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, bin_section->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*sname='%.*s'\n", indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
|
||||
str8_list_pushf(arena, out, "%.*sflags=", indent_level, rdi_stringize_spaces);
|
||||
@@ -176,10 +176,10 @@ rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_FilePathBundle *bundle, RDI_FilePathNode *file_path, U32 indent_level)
|
||||
rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_FilePathBundle *bundle, RDI_FilePathNode *file_path, U32 indent_level)
|
||||
{
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, file_path->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, file_path->name_string_idx, &name.size);
|
||||
U32 this_idx = (U32)(file_path - bundle->file_paths);
|
||||
if(file_path->source_file_idx == 0)
|
||||
{
|
||||
@@ -206,7 +206,7 @@ rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_
|
||||
}
|
||||
|
||||
// stringize child
|
||||
rdi_stringize_file_path(arena, out, parsed, bundle, child_node, indent_level + 1);
|
||||
rdi_stringize_file_path(arena, out, rdi, bundle, child_node, indent_level + 1);
|
||||
|
||||
// increment iterator
|
||||
child = child_node->next_sibling;
|
||||
@@ -214,11 +214,11 @@ rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_source_file(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_SourceFile *source_file, U32 indent_level)
|
||||
rdi_stringize_source_file(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_SourceFile *source_file, U32 indent_level)
|
||||
{
|
||||
// normal source path
|
||||
String8 path = {0};
|
||||
path.str = rdi_string_from_idx(parsed, source_file->normal_full_path_string_idx, &path.size);
|
||||
path.str = rdi_string_from_idx(rdi, source_file->normal_full_path_string_idx, &path.size);
|
||||
str8_list_pushf(arena, out, "%.*spath: \"%S\"\n", indent_level, rdi_stringize_spaces, path);
|
||||
|
||||
// rjf: source line map idx
|
||||
@@ -226,11 +226,11 @@ rdi_stringize_source_file(Arena *arena, String8List *out, RDI_Parsed *parsed, RD
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_LineTable *line_table, U32 indent_level)
|
||||
rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_LineTable *line_table, U32 indent_level)
|
||||
{
|
||||
// rjf: parse line table
|
||||
RDI_ParsedLineTable parsed_line_table = {0};
|
||||
rdi_parsed_from_line_table(parsed, line_table, &parsed_line_table);
|
||||
rdi_parsed_from_line_table(rdi, line_table, &parsed_line_table);
|
||||
|
||||
// rjf: stringize lines
|
||||
str8_list_pushf(arena, out, "%.*slines:\n", indent_level, rdi_stringize_spaces);
|
||||
@@ -261,10 +261,10 @@ rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_SourceLineMap *map, U32 indent_level)
|
||||
rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_SourceLineMap *map, U32 indent_level)
|
||||
{
|
||||
RDI_ParsedSourceLineMap line_map = {0};
|
||||
rdi_parsed_from_source_line_map(parsed, map, &line_map);
|
||||
rdi_parsed_from_source_line_map(rdi, map, &line_map);
|
||||
str8_list_pushf(arena, out, "%.*slines:\n", indent_level, rdi_stringize_spaces);
|
||||
|
||||
for(U32 i = 0; i < line_map.count; i += 1)
|
||||
@@ -307,12 +307,12 @@ rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *parsed
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_Unit *unit, U32 indent_level)
|
||||
rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_Unit *unit, U32 indent_level)
|
||||
{
|
||||
String8 unit_name = {0};
|
||||
unit_name.str = rdi_string_from_idx(parsed, unit->unit_name_string_idx, &unit_name.size);
|
||||
unit_name.str = rdi_string_from_idx(rdi, unit->unit_name_string_idx, &unit_name.size);
|
||||
String8 compiler_name = {0};
|
||||
compiler_name.str = rdi_string_from_idx(parsed, unit->compiler_name_string_idx, &compiler_name.size);
|
||||
compiler_name.str = rdi_string_from_idx(rdi, unit->compiler_name_string_idx, &compiler_name.size);
|
||||
|
||||
str8_list_pushf(arena, out, "%.*sunit_name='%.*s'\n", indent_level, rdi_stringize_spaces, str8_varg(unit_name));
|
||||
str8_list_pushf(arena, out, "%.*scompiler_name='%.*s'\n", indent_level, rdi_stringize_spaces, str8_varg(compiler_name));
|
||||
@@ -329,7 +329,7 @@ rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_Unit
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_TypeNode *type, U32 indent_level){
|
||||
RDI_TypeKind kind = type->kind;
|
||||
String8 type_kind_str = rdi_string_from_type_kind(kind);
|
||||
@@ -360,7 +360,7 @@ rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
if (RDI_TypeKind_FirstBuiltIn <= kind &&
|
||||
kind <= RDI_TypeKind_LastBuiltIn){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, type->built_in.name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, type->built_in.name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*sbuilt_in.name='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
}
|
||||
@@ -381,7 +381,7 @@ rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
U32 run_count_raw = type->constructed.count;
|
||||
|
||||
U32 run_count = 0;
|
||||
U32 *run = rdi_idx_run_from_first_count(parsed, run_first, run_count_raw, &run_count);
|
||||
U32 *run = rdi_idx_run_from_first_count(rdi, run_first, run_count_raw, &run_count);
|
||||
|
||||
U32 this_type_idx = 0;
|
||||
if (run_count > 0 && type->kind == RDI_TypeKind_Method){
|
||||
@@ -413,7 +413,7 @@ rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
else if (RDI_TypeKind_FirstUserDefined <= kind &&
|
||||
kind <= RDI_TypeKind_LastUserDefined){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, type->user_defined.name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, type->user_defined.name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*suser_defined.name='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
str8_list_pushf(arena, out, "%.*suser_defined.direct_type=%u\n",
|
||||
@@ -433,7 +433,7 @@ rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_UDTMemberBundle *member_bundle, RDI_UDT *udt,
|
||||
U32 indent_level){
|
||||
str8_list_pushf(arena, out, "%.*sself_type=%u\n",
|
||||
@@ -461,7 +461,7 @@ rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
RDI_EnumMember *enum_member = member_bundle->enum_members + first;
|
||||
for (U32 i = first; i < opl; i += 1, enum_member += 1){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, enum_member->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, enum_member->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*s '%.*s' %llu\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
str8_varg(name), enum_member->val);
|
||||
@@ -489,7 +489,7 @@ rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
|
||||
if (member->name_string_idx != 0){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, member->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, member->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*s name='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
}
|
||||
@@ -507,10 +507,10 @@ rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_global_variable(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_global_variable(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_GlobalVariable *global_variable, U32 indent_level){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, global_variable->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, global_variable->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*sname='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
|
||||
@@ -529,11 +529,11 @@ rdi_stringize_global_variable(Arena *arena, String8List *out, RDI_Parsed *parsed
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_thread_variable(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_thread_variable(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_ThreadVariable *thread_var,
|
||||
U32 indent_level){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, thread_var->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, thread_var->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*sname='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
|
||||
@@ -552,15 +552,15 @@ rdi_stringize_thread_variable(Arena *arena, String8List *out, RDI_Parsed *parsed
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_procedure(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_procedure(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_Procedure *proc, U32 indent_level){
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, proc->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, proc->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*sname='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
|
||||
String8 link_name = {0};
|
||||
link_name.str = rdi_string_from_idx(parsed, proc->link_name_string_idx, &link_name.size);
|
||||
link_name.str = rdi_string_from_idx(rdi, proc->link_name_string_idx, &link_name.size);
|
||||
str8_list_pushf(arena, out, "%.*slink_name='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(link_name));
|
||||
|
||||
@@ -579,7 +579,7 @@ rdi_stringize_procedure(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *rdi,
|
||||
RDI_ScopeBundle *bundle, RDI_Scope *scope, U32 indent_level){
|
||||
|
||||
U32 this_idx = (U32)(scope - bundle->scopes);
|
||||
@@ -638,7 +638,7 @@ rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
indent_level, rdi_stringize_spaces, str8_varg(local_kind_str));
|
||||
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(parsed, local_ptr->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, local_ptr->name_string_idx, &name.size);
|
||||
str8_list_pushf(arena, out, "%.*s name='%.*s'\n",
|
||||
indent_level, rdi_stringize_spaces, str8_varg(name));
|
||||
|
||||
@@ -756,7 +756,7 @@ rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *parsed,
|
||||
}
|
||||
|
||||
// stringize child
|
||||
rdi_stringize_scope(arena, out, parsed, bundle, child_scope, indent_level + 1);
|
||||
rdi_stringize_scope(arena, out, rdi, bundle, child_scope, indent_level + 1);
|
||||
|
||||
// increment iterator
|
||||
child = child_scope->next_sibling_scope_idx;
|
||||
|
||||
+16
-16
@@ -11,7 +11,7 @@ typedef struct RDI_FilePathBundle RDI_FilePathBundle;
|
||||
struct RDI_FilePathBundle
|
||||
{
|
||||
RDI_FilePathNode *file_paths;
|
||||
U32 file_path_count;
|
||||
U64 file_path_count;
|
||||
};
|
||||
|
||||
typedef struct RDI_UDTMemberBundle RDI_UDTMemberBundle;
|
||||
@@ -41,7 +41,7 @@ struct RDI_ScopeBundle
|
||||
////////////////////////////////
|
||||
//~ rjf: RDI Enum -> String Functions
|
||||
|
||||
internal String8 rdi_string_from_data_section_tag(RDI_DataSectionTag v);
|
||||
internal String8 rdi_string_from_data_section_kind(RDI_SectionKind v);
|
||||
internal String8 rdi_string_from_arch(RDI_Arch v);
|
||||
internal String8 rdi_string_from_language(RDI_Language v);
|
||||
internal String8 rdi_string_from_type_kind(RDI_TypeKind v);
|
||||
@@ -59,19 +59,19 @@ internal void rdi_stringize_link_flags(Arena *arena, String8List *out, RDI_LinkF
|
||||
////////////////////////////////
|
||||
//~ rjf: RDI Compound Stringize Functions
|
||||
|
||||
internal void rdi_stringize_data_sections(Arena *arena, String8List *out, RDI_Parsed *parsed, U32 indent_level);
|
||||
internal void rdi_stringize_top_level_info(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_TopLevelInfo *tli, U32 indent_level);
|
||||
internal void rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_BinarySection *bin_section, U32 indent_level);
|
||||
internal void rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_FilePathBundle *bundle, RDI_FilePathNode *file_path, U32 indent_level);
|
||||
internal void rdi_stringize_source_file(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_SourceFile *source_file, U32 indent_level);
|
||||
internal void rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_LineTable *line_table, U32 indent_level);
|
||||
internal void rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_SourceLineMap *map, U32 indent_level);
|
||||
internal void rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_Unit *unit, U32 indent_level);
|
||||
internal void rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_TypeNode *type, U32 indent_level);
|
||||
internal void rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_UDTMemberBundle *bundle, RDI_UDT *udt, U32 indent_level);
|
||||
internal void rdi_stringize_global_variable(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_GlobalVariable *global_variable, U32 indent_level);
|
||||
internal void rdi_stringize_thread_variable(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_ThreadVariable *thread_var, U32 indent_level);
|
||||
internal void rdi_stringize_procedure(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_Procedure *proc, U32 indent_level);
|
||||
internal void rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_ScopeBundle *bundle, RDI_Scope *scope, U32 indent_level);
|
||||
internal void rdi_stringize_data_sections(Arena *arena, String8List *out, RDI_Parsed *rdi, U32 indent_level);
|
||||
internal void rdi_stringize_top_level_info(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_TopLevelInfo *tli, U32 indent_level);
|
||||
internal void rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_BinarySection *bin_section, U32 indent_level);
|
||||
internal void rdi_stringize_file_path(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_FilePathBundle *bundle, RDI_FilePathNode *file_path, U32 indent_level);
|
||||
internal void rdi_stringize_source_file(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_SourceFile *source_file, U32 indent_level);
|
||||
internal void rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_LineTable *line_table, U32 indent_level);
|
||||
internal void rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_SourceLineMap *map, U32 indent_level);
|
||||
internal void rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_Unit *unit, U32 indent_level);
|
||||
internal void rdi_stringize_type_node(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_TypeNode *type, U32 indent_level);
|
||||
internal void rdi_stringize_udt(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_UDTMemberBundle *bundle, RDI_UDT *udt, U32 indent_level);
|
||||
internal void rdi_stringize_global_variable(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_GlobalVariable *global_variable, U32 indent_level);
|
||||
internal void rdi_stringize_thread_variable(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_ThreadVariable *thread_var, U32 indent_level);
|
||||
internal void rdi_stringize_procedure(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_Procedure *proc, U32 indent_level);
|
||||
internal void rdi_stringize_scope(Arena *arena, String8List *out, RDI_Parsed *rdi, RDI_ScopeBundle *bundle, RDI_Scope *scope, U32 indent_level);
|
||||
|
||||
#endif // RDI_DUMP_H
|
||||
|
||||
+108
-81
@@ -174,7 +174,8 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_TopLevelInfo)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# TOP LEVEL INFO:\n");
|
||||
rdi_stringize_top_level_info(arena, &dump, rdi, rdi->top_level_info, 1);
|
||||
RDI_TopLevelInfo *tli = rdi_element_from_name_idx(rdi, TopLevelInfo, 0);
|
||||
rdi_stringize_top_level_info(arena, &dump, rdi, tli, 1);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
|
||||
@@ -182,11 +183,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_BinarySections)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# BINARY SECTIONS:\n");
|
||||
RDI_BinarySection *ptr = rdi->binary_sections;
|
||||
for(U32 i = 0; i < rdi->binary_sections_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_BinarySection *v = rdi_table_from_name(rdi, BinarySections, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " section[%u]:\n", i);
|
||||
rdi_stringize_binary_section(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " section[%I64u]:\n", idx);
|
||||
rdi_stringize_binary_section(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -195,13 +197,10 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_FilePaths)
|
||||
{
|
||||
RDI_FilePathBundle file_path_bundle = {0};
|
||||
{
|
||||
file_path_bundle.file_paths = rdi->file_paths;
|
||||
file_path_bundle.file_path_count = rdi->file_paths_count;
|
||||
}
|
||||
file_path_bundle.file_paths = rdi_table_from_name(rdi, FilePathNodes, &file_path_bundle.file_path_count);
|
||||
str8_list_pushf(arena, &dump, "# FILE PATHS\n");
|
||||
RDI_FilePathNode *ptr = rdi->file_paths;
|
||||
for(U32 i = 0; i < rdi->file_paths_count; i += 1, ptr += 1)
|
||||
RDI_FilePathNode *ptr = file_path_bundle.file_paths;
|
||||
for(U32 i = 0; i < file_path_bundle.file_path_count; i += 1, ptr += 1)
|
||||
{
|
||||
if(ptr->parent_path_node == 0)
|
||||
{
|
||||
@@ -215,11 +214,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_SourceFiles)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# SOURCE FILES\n");
|
||||
RDI_SourceFile *ptr = rdi->source_files;
|
||||
for(U32 i = 0; i < rdi->source_files_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_SourceFile *v = rdi_table_from_name(rdi, SourceFiles, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " source_file[%u]:\n", i);
|
||||
rdi_stringize_source_file(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " source_file[%I64u]:\n", idx);
|
||||
rdi_stringize_source_file(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -228,11 +228,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_LineTables)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# LINE TABLES\n");
|
||||
RDI_LineTable *ptr = rdi->line_tables;
|
||||
for(U32 i = 0; i < rdi->line_tables_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_LineTable *v = rdi_table_from_name(rdi, LineTables, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " line_table[%u]:\n", i);
|
||||
rdi_stringize_line_table(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " line_table[%I64u]:\n", idx);
|
||||
rdi_stringize_line_table(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -241,11 +242,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_SourceLineMaps)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# SOURCE LINE MAPS\n");
|
||||
RDI_SourceLineMap *ptr = rdi->source_line_maps;
|
||||
for(U32 i = 0; i < rdi->source_line_maps_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_SourceLineMap *v = rdi_table_from_name(rdi, SourceLineMaps, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " source_line_map[%u]:\n", i);
|
||||
rdi_stringize_source_line_map(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " source_line_map[%I64u]:\n", idx);
|
||||
rdi_stringize_source_line_map(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -254,11 +256,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Units)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# UNITS\n");
|
||||
RDI_Unit *ptr = rdi->units;
|
||||
for (U32 i = 0; i < rdi->units_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_Unit *v = rdi_table_from_name(rdi, Units, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " unit[%u]:\n", i);
|
||||
rdi_stringize_unit(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " unit[%I64u]:\n", idx);
|
||||
rdi_stringize_unit(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -267,10 +270,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_UnitVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# UNIT VMAP\n");
|
||||
RDI_VMapEntry *ptr = rdi->unit_vmap;
|
||||
for(U32 i = 0; i < rdi->unit_vmap_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_VMapEntry *v = rdi_table_from_name(rdi, UnitVMap, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", v[idx].voff, v[idx].idx);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -279,11 +283,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_TypeNodes)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# TYPE NODES:\n");
|
||||
RDI_TypeNode *ptr = rdi->type_nodes;
|
||||
for(U32 i = 0; i < rdi->type_nodes_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_TypeNode *v = rdi_table_from_name(rdi, TypeNodes, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " type[%u]:\n", i);
|
||||
rdi_stringize_type_node(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " type[%I64u]:\n", idx);
|
||||
rdi_stringize_type_node(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -291,19 +296,24 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: UDT DATA
|
||||
if(dump_flags & DumpFlag_UDTs)
|
||||
{
|
||||
U64 all_members_count = 0;
|
||||
RDI_Member *all_members = rdi_table_from_name(rdi, Members, &all_members_count);
|
||||
U64 all_enum_members_count = 0;
|
||||
RDI_EnumMember *all_enum_members = rdi_table_from_name(rdi, EnumMembers, &all_enum_members_count);
|
||||
U64 all_udts_count = 0;
|
||||
RDI_UDT *all_udts = rdi_table_from_name(rdi, UDTs, &all_udts_count);
|
||||
RDI_UDTMemberBundle member_bundle = {0};
|
||||
{
|
||||
member_bundle.members = rdi->members;
|
||||
member_bundle.enum_members = rdi->enum_members;
|
||||
member_bundle.member_count = rdi->members_count;
|
||||
member_bundle.enum_member_count = rdi->enum_members_count;
|
||||
member_bundle.members = all_members;
|
||||
member_bundle.enum_members = all_enum_members;
|
||||
member_bundle.member_count = (RDI_U32)all_members_count;
|
||||
member_bundle.enum_member_count = (RDI_U32)all_enum_members_count;
|
||||
}
|
||||
str8_list_pushf(arena, &dump, "# UDTS:\n");
|
||||
RDI_UDT *ptr = rdi->udts;
|
||||
for(U32 i = 0; i < rdi->udts_count; i += 1, ptr += 1)
|
||||
for(U64 idx = 0; idx < all_udts_count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " udt[%u]:\n", i);
|
||||
rdi_stringize_udt(arena, &dump, rdi, &member_bundle, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " udt[%I64u]:\n", idx);
|
||||
rdi_stringize_udt(arena, &dump, rdi, &member_bundle, &all_udts[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -312,11 +322,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_GlobalVariables)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# GLOBAL VARIABLES:\n");
|
||||
RDI_GlobalVariable *ptr = rdi->global_variables;
|
||||
for(U32 i = 0; i < rdi->global_variables_count; i += 1, ptr += 1)
|
||||
RDI_U64 count = 0;
|
||||
RDI_GlobalVariable *v = rdi_table_from_name(rdi, GlobalVariables, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " global_variable[%u]:\n", i);
|
||||
rdi_stringize_global_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " global_variable[%I64u]:\n", idx);
|
||||
rdi_stringize_global_variable(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -325,10 +336,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_GlobalVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# GLOBAL VMAP:\n");
|
||||
RDI_VMapEntry *ptr = rdi->global_vmap;
|
||||
for(U32 i = 0; i < rdi->global_vmap_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_VMapEntry *v = rdi_table_from_name(rdi, GlobalVMap, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", v[idx].voff, v[idx].idx);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -337,11 +349,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_ThreadVariables)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# THREAD VARIABLES:\n");
|
||||
RDI_ThreadVariable *ptr = rdi->thread_variables;
|
||||
for(U32 i = 0; i < rdi->thread_variables_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_ThreadVariable *v = rdi_table_from_name(rdi, ThreadVariables, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " thread_variable[%u]:\n", i);
|
||||
rdi_stringize_thread_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " thread_variable[%I64u]:\n", idx);
|
||||
rdi_stringize_thread_variable(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -350,11 +363,12 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Procedures)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# PROCEDURES:\n");
|
||||
RDI_Procedure *ptr = rdi->procedures;
|
||||
for(U32 i = 0; i < rdi->procedures_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_Procedure *v = rdi_table_from_name(rdi, Procedures, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " procedure[%u]:\n", i);
|
||||
rdi_stringize_procedure(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_pushf(arena, &dump, " procedure[%I64u]:\n", idx);
|
||||
rdi_stringize_procedure(arena, &dump, rdi, &v[idx], 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -362,26 +376,35 @@ entry_point(CmdLine *cmd_line)
|
||||
//- rjf: SCOPES
|
||||
if(dump_flags & DumpFlag_Scopes)
|
||||
{
|
||||
U64 scopes_count = 0;
|
||||
RDI_Scope *scopes = rdi_table_from_name(rdi, Scopes, &scopes_count);
|
||||
U64 scopes_voffs_count = 0;
|
||||
U64 *scopes_voffs = rdi_table_from_name(rdi, ScopeVOffData, &scopes_voffs_count);
|
||||
U64 locals_count = 0;
|
||||
RDI_Local *locals = rdi_table_from_name(rdi, Locals, &locals_count);
|
||||
U64 location_block_count = 0;
|
||||
RDI_LocationBlock *location_blocks = rdi_table_from_name(rdi, LocationBlocks, &location_block_count);
|
||||
U64 location_data_size = 0;
|
||||
RDI_U8 *location_data = rdi_table_from_name(rdi, LocationData, &location_data_size);
|
||||
RDI_ScopeBundle scope_bundle = {0};
|
||||
{
|
||||
scope_bundle.scopes = rdi->scopes;
|
||||
scope_bundle.scope_count = rdi->scopes_count;
|
||||
scope_bundle.scope_voffs = rdi->scope_voffs;
|
||||
scope_bundle.scope_voff_count = rdi->scope_voffs_count;
|
||||
scope_bundle.locals = rdi->locals;
|
||||
scope_bundle.local_count = rdi->locals_count;
|
||||
scope_bundle.location_blocks = rdi->location_blocks;
|
||||
scope_bundle.location_block_count = rdi->location_blocks_count;
|
||||
scope_bundle.location_data = rdi->location_data;
|
||||
scope_bundle.location_data_size = rdi->location_data_size;
|
||||
scope_bundle.scopes = scopes;
|
||||
scope_bundle.scope_count = scopes_count;
|
||||
scope_bundle.scope_voffs = scopes_voffs;
|
||||
scope_bundle.scope_voff_count = scopes_voffs_count;
|
||||
scope_bundle.locals = locals;
|
||||
scope_bundle.local_count = locals_count;
|
||||
scope_bundle.location_blocks = location_blocks;
|
||||
scope_bundle.location_block_count = location_block_count;
|
||||
scope_bundle.location_data = location_data;
|
||||
scope_bundle.location_data_size = location_data_size;
|
||||
}
|
||||
str8_list_pushf(arena, &dump, "# SCOPES:\n");
|
||||
RDI_Scope *ptr = rdi->scopes;
|
||||
for(U32 i = 0; i < rdi->scopes_count; i += 1, ptr += 1)
|
||||
for(U64 idx = 0; idx < scopes_count; idx += 1)
|
||||
{
|
||||
if(ptr->parent_scope_idx == 0)
|
||||
if(scopes[idx].parent_scope_idx == 0)
|
||||
{
|
||||
rdi_stringize_scope(arena, &dump, rdi, &scope_bundle, ptr, 1);
|
||||
rdi_stringize_scope(arena, &dump, rdi, &scope_bundle, &scopes[idx], 1);
|
||||
}
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
@@ -391,10 +414,11 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_ScopeVMap)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# SCOPE VMAP:\n");
|
||||
RDI_VMapEntry *ptr = rdi->scope_vmap;
|
||||
for(U32 i = 0; i < rdi->scope_vmap_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_VMapEntry *v = rdi_table_from_name(rdi, ScopeVMap, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", ptr->voff, ptr->idx);
|
||||
str8_list_pushf(arena, &dump, " 0x%08x: %llu\n", v[idx].voff, v[idx].idx);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -403,12 +427,13 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_NameMaps)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# NAME MAP:\n");
|
||||
RDI_NameMap *ptr = rdi->name_maps;
|
||||
for(U32 i = 0; i < rdi->name_maps_count; i += 1, ptr += 1)
|
||||
U64 count = 0;
|
||||
RDI_NameMap *v = rdi_table_from_name(rdi, NameMaps, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
RDI_ParsedNameMap name_map = {0};
|
||||
rdi_name_map_parse(rdi, ptr, &name_map);
|
||||
str8_list_pushf(arena, &dump, " name_map[%u]:\n", i);
|
||||
rdi_parsed_from_name_map(rdi, &v[idx], &name_map);
|
||||
str8_list_pushf(arena, &dump, " name_map[%I64u]:\n", idx);
|
||||
RDI_NameMapBucket *bucket = name_map.buckets;
|
||||
for(U32 j = 0; j < name_map.bucket_count; j += 1, bucket += 1)
|
||||
{
|
||||
@@ -455,11 +480,13 @@ entry_point(CmdLine *cmd_line)
|
||||
if(dump_flags & DumpFlag_Strings)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, "# STRINGS:\n");
|
||||
for(U64 string_idx = 0; string_idx < rdi->string_count; string_idx += 1)
|
||||
U64 count = 0;
|
||||
U32 *v = rdi_table_from_name(rdi, StringTable, &count);
|
||||
for(U64 idx = 0; idx < count; idx += 1)
|
||||
{
|
||||
String8 string = {0};
|
||||
string.str = rdi_string_from_idx(rdi, string_idx, &string.size);
|
||||
str8_list_pushf(arena, &dump, " string[%I64u]: \"%S\"\n", string_idx, string);
|
||||
string.str = rdi_string_from_idx(rdi, (RDI_U32)idx, &string.size);
|
||||
str8_list_pushf(arena, &dump, " string[%I64u]: \"%S\"\n", idx, string);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
|
||||
+194
-154
@@ -51,11 +51,18 @@
|
||||
"#endif";
|
||||
"";
|
||||
"////////////////////////////////////////////////////////////////";
|
||||
"//~ Overridable Enabling/Disabling Of Table Index Typechecking";
|
||||
"";
|
||||
"#if !defined(RDI_DISABLE_TABLE_INDEX_TYPECHECKING)";
|
||||
"# define RDI_DISABLE_TABLE_INDEX_TYPECHECKING 0";
|
||||
"#endif";
|
||||
"";
|
||||
"////////////////////////////////////////////////////////////////";
|
||||
"//~ Format Constants";
|
||||
"";
|
||||
"// \"raddbg\0\0\"";
|
||||
"#define RDI_MAGIC_CONSTANT 0x0000676264646172";
|
||||
"#define RDI_ENCODING_VERSION 3";
|
||||
"#define RDI_ENCODING_VERSION 4";
|
||||
"";
|
||||
"////////////////////////////////////////////////////////////////";
|
||||
"//~ Format Types & Functions";
|
||||
@@ -108,96 +115,123 @@ RDI_HeaderMemberTable:
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Format Data Section Tables
|
||||
//~ rjf: Format Section Tables
|
||||
|
||||
@table(name value desc)
|
||||
RDI_DataSectionTable:
|
||||
@table(name name_lower element_type value is_required index_base_type desc)
|
||||
RDI_SectionTable:
|
||||
{
|
||||
{NULL 0x0000 ""}
|
||||
{TopLevelInfo 0x0001 ""}
|
||||
{StringData 0x0002 ""}
|
||||
{StringTable 0x0003 ""}
|
||||
{IndexRuns 0x0004 ""}
|
||||
{BinarySections 0x0005 ""}
|
||||
{FilePathNodes 0x0006 ""}
|
||||
{SourceFiles 0x0007 ""}
|
||||
{LineTables 0x0008 ""}
|
||||
{LineInfoVoffs 0x0009 ""}
|
||||
{LineInfoLines 0x000A ""}
|
||||
{LineInfoColumns 0x000B ""}
|
||||
{SourceLineMaps 0x000C ""}
|
||||
{SourceLineMapNumbers 0x000D ""}
|
||||
{SourceLineMapRanges 0x000E ""}
|
||||
{SourceLineMapVOffs 0x000F ""}
|
||||
{Units 0x0010 ""}
|
||||
{UnitVmap 0x0011 ""}
|
||||
{TypeNodes 0x0012 ""}
|
||||
{UDTs 0x0013 ""}
|
||||
{Members 0x0014 ""}
|
||||
{EnumMembers 0x0015 ""}
|
||||
{GlobalVariables 0x0016 ""}
|
||||
{GlobalVmap 0x0017 ""}
|
||||
{ThreadVariables 0x0018 ""}
|
||||
{Procedures 0x0019 ""}
|
||||
{Scopes 0x001A ""}
|
||||
{ScopeVoffData 0x001B ""}
|
||||
{ScopeVmap 0x001C ""}
|
||||
{InlineSites 0x001D ""}
|
||||
{Locals 0x001E ""}
|
||||
{LocationBlocks 0x001F ""}
|
||||
{LocationData 0x0020 ""}
|
||||
{NameMaps 0x0021 ""}
|
||||
{PRIMARY_COUNT 0x0022 ""}
|
||||
{SECONDARY 0x80000000 ""}
|
||||
{NameMapBuckets `RDI_DataSectionTag_SECONDARY|0x0001` ""}
|
||||
{NameMapNodes `RDI_DataSectionTag_SECONDARY|0x0002` ""}
|
||||
{NULL null RDI_U8 0x0000 - - ""}
|
||||
{TopLevelInfo top_level_info RDI_TopLevelInfo 0x0001 - - ""}
|
||||
{StringData string_data RDI_U8 0x0002 x - ""}
|
||||
{StringTable string_table RDI_U32 0x0003 x U32 ""}
|
||||
{IndexRuns index_runs RDI_U32 0x0004 x U32 ""}
|
||||
{BinarySections binary_sections RDI_BinarySection 0x0005 - U32 ""}
|
||||
{FilePathNodes file_path_nodes RDI_FilePathNode 0x0006 - U32 ""}
|
||||
{SourceFiles source_files RDI_SourceFile 0x0007 - U32 ""}
|
||||
{LineTables line_tables RDI_LineTable 0x0008 - U32 ""}
|
||||
{LineInfoVOffs line_info_voffs RDI_U64 0x0009 - U32 ""}
|
||||
{LineInfoLines line_info_lines RDI_Line 0x000A - U32 ""}
|
||||
{LineInfoColumns line_info_columns RDI_Column 0x000B - U32 ""}
|
||||
{SourceLineMaps source_line_maps RDI_SourceLineMap 0x000C - U32 ""}
|
||||
{SourceLineMapNumbers source_line_map_numbers RDI_U32 0x000D - U32 ""}
|
||||
{SourceLineMapRanges source_line_map_ranges RDI_U32 0x000E - U32 ""}
|
||||
{SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F - U32 ""}
|
||||
{Units units RDI_Unit 0x0010 - U32 ""}
|
||||
{UnitVMap unit_vmap RDI_VMapEntry 0x0011 - - ""}
|
||||
{TypeNodes type_nodes RDI_TypeNode 0x0012 - U32 ""}
|
||||
{UDTs udts RDI_UDT 0x0013 - U32 ""}
|
||||
{Members members RDI_Member 0x0014 - U32 ""}
|
||||
{EnumMembers enum_members RDI_EnumMember 0x0015 - U32 ""}
|
||||
{GlobalVariables global_variables RDI_GlobalVariable 0x0016 - U32 ""}
|
||||
{GlobalVMap global_vmap RDI_VMapEntry 0x0017 - - ""}
|
||||
{ThreadVariables thread_variables RDI_ThreadVariable 0x0018 - U32 ""}
|
||||
{Procedures procedures RDI_Procedure 0x0019 - U32 ""}
|
||||
{Scopes scopes RDI_Scope 0x001A - U32 ""}
|
||||
{ScopeVOffData scope_voff_data RDI_U64 0x001B - U32 ""}
|
||||
{ScopeVMap scope_vmap RDI_VMapEntry 0x001C - - ""}
|
||||
{InlineSites inline_sites RDI_InlineSite 0x001D - U32 ""}
|
||||
{Locals locals RDI_Local 0x001E - U32 ""}
|
||||
{LocationBlocks location_blocks RDI_LocationBlock 0x001F - U32 ""}
|
||||
{LocationData location_data RDI_U8 0x0020 - U32 ""}
|
||||
{NameMaps name_maps RDI_NameMap 0x0021 - U32 ""}
|
||||
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0022 - U32 ""}
|
||||
{NameMapNodes name_map_nodes RDI_NameMapNode 0x0023 - U32 ""}
|
||||
{COUNT count RDI_U8 0x0024 - - ""}
|
||||
}
|
||||
|
||||
@table(name value)
|
||||
RDI_DataSectionEncodingTable:
|
||||
RDI_SectionEncodingTable:
|
||||
{
|
||||
{Unpacked 0}
|
||||
{LZB 1}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_DataSectionMemberTable:
|
||||
RDI_SectionMemberTable:
|
||||
{
|
||||
{tag RDI_DataSectionTag ""}
|
||||
{encoding RDI_DataSectionEncoding ""}
|
||||
{encoding RDI_SectionEncoding ""}
|
||||
{pad RDI_U32 ""}
|
||||
{off RDI_U64 ""}
|
||||
{encoded_size RDI_U64 ""}
|
||||
{unpacked_size RDI_U64 ""}
|
||||
}
|
||||
|
||||
@enum(RDI_U32) RDI_DataSectionTag:
|
||||
@enum(RDI_U32) RDI_SectionKind:
|
||||
{
|
||||
@expand(RDI_DataSectionTable a) `$(a.name .. =>20) = $(a.value)`,
|
||||
@expand(RDI_SectionTable a) `$(a.name .. =>20) = $(a.value)`,
|
||||
}
|
||||
|
||||
@enum(RDI_U32) RDI_DataSectionEncoding:
|
||||
@enum(RDI_U32) RDI_SectionEncoding:
|
||||
{
|
||||
@expand(RDI_DataSectionEncodingTable a) `$(a.name .. =>10) = $(a.value)`,
|
||||
@expand(RDI_SectionEncodingTable a) `$(a.name .. =>10) = $(a.value)`,
|
||||
}
|
||||
|
||||
@xlist RDI_DataSectionTag_XList:
|
||||
@xlist RDI_SectionKind_XList:
|
||||
{
|
||||
@expand(RDI_DataSectionTable a) `$(a.name)`;
|
||||
@expand(RDI_SectionTable a) `$(a.name != COUNT -> a.name .. ', ' .. a.name_lower .. ', ' .. a.element_type)`;
|
||||
}
|
||||
|
||||
@xlist RDI_DataSectionEncoding_XList:
|
||||
@xlist RDI_SectionEncoding_XList:
|
||||
{
|
||||
@expand(RDI_DataSectionEncodingTable a) `$(a.name)`;
|
||||
@expand(RDI_SectionEncodingTable a) `$(a.name)`;
|
||||
}
|
||||
|
||||
@xlist RDI_DataSection_XList:
|
||||
@xlist RDI_Section_XList:
|
||||
{
|
||||
@expand(RDI_DataSectionMemberTable a) `$(a.type), $(a.name)`
|
||||
@expand(RDI_SectionMemberTable a) `$(a.type), $(a.name)`
|
||||
}
|
||||
|
||||
@struct RDI_DataSection:
|
||||
@struct RDI_Section:
|
||||
{
|
||||
@expand(RDI_DataSectionMemberTable a) `$(a.type) $(a.name)`
|
||||
@expand(RDI_SectionMemberTable a) `$(a.type) $(a.name)`
|
||||
}
|
||||
|
||||
@gen(enums)
|
||||
{
|
||||
`#if !RDI_DISABLE_TABLE_INDEX_TYPECHECKING`;
|
||||
@expand(RDI_SectionTable a) `$(a.index_base_type != '-' -> "typedef struct RDI_" .. a.index_base_type .. "_" .. a.name .. =>50 .. " { RDI_" .. a.index_base_type .. " v; }".. " RDI_" .. a.index_base_type .. "_" .. a.name .. ";")`;
|
||||
`#else`;
|
||||
`typedef struct RDI_U32_Table { RDI_U32 v; } RDI_U32_Table;`;
|
||||
`typedef struct RDI_U64_Table { RDI_U64 v; } RDI_U64_Table;`;
|
||||
@expand(RDI_SectionTable a) `$(a.index_base_type != '-' -> "typedef RDI_" .. a.index_base_type .. "_Table RDI_" .. a.index_base_type .. "_" .. a.name .. ";")`;
|
||||
`#endif`;
|
||||
``;
|
||||
}
|
||||
|
||||
@gen(catchall)
|
||||
{
|
||||
@expand(RDI_SectionTable a) `$(a.name != COUNT -> "typedef " .. a.element_type .. " RDI_SectionElementType_" .. a.name .. ";")`;
|
||||
``;
|
||||
}
|
||||
|
||||
@data(RDI_U16) rdi_section_element_size_table:
|
||||
{
|
||||
@expand(RDI_SectionTable a) `sizeof($(a.element_type))`;
|
||||
}
|
||||
|
||||
@data(RDI_U8) rdi_section_is_required_table:
|
||||
{
|
||||
@expand(RDI_SectionTable a) `$(a.is_required == 'x' -> 1)$(a.is_required != 'x' -> 0)`;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -407,10 +441,10 @@ RDI_RegCodeX64Table:
|
||||
@table(name type desc)
|
||||
RDI_TopLevelInfoMemberTable:
|
||||
{
|
||||
{arch RDI_Arch ""}
|
||||
{exe_name_string_idx RDI_U32 ""}
|
||||
{exe_hash RDI_U64 ""}
|
||||
{voff_max RDI_U64 ""}
|
||||
{arch RDI_Arch ""}
|
||||
{exe_name_string_idx RDI_U32 ""}
|
||||
{exe_hash RDI_U64 ""}
|
||||
{voff_max RDI_U64 ""}
|
||||
}
|
||||
|
||||
@xlist RDI_TopLevelInfo_XList:
|
||||
@@ -471,23 +505,23 @@ RDI_BinarySectionMemberTable:
|
||||
@table(name type desc)
|
||||
RDI_FilePathNodeMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{parent_path_node RDI_U32 ""}
|
||||
{first_child RDI_U32 ""}
|
||||
{next_sibling RDI_U32 ""}
|
||||
{source_file_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{parent_path_node RDI_U32 ""}
|
||||
{first_child RDI_U32 ""}
|
||||
{next_sibling RDI_U32 ""}
|
||||
{source_file_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_SourceFileMemberTable:
|
||||
{
|
||||
{file_path_node_idx RDI_U32 ""}
|
||||
{normal_full_path_string_idx RDI_U32 ""}
|
||||
{file_path_node_idx RDI_U32 ""}
|
||||
{normal_full_path_string_idx RDI_U32 ""}
|
||||
// usage of line map to go from a line number to an array of voffs
|
||||
// (line_map_nums * line_number) -> (nil | index)
|
||||
// (line_map_data * index) -> (range)
|
||||
// (line_map_voff_data * range) -> (array(voff))
|
||||
{source_line_map_idx RDI_U32 ""}
|
||||
{source_line_map_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@xlist RDI_FilePathNode_XList:
|
||||
@@ -516,14 +550,14 @@ RDI_SourceFileMemberTable:
|
||||
@table(name type desc)
|
||||
RDI_UnitMemberTable:
|
||||
{
|
||||
{unit_name_string_idx RDI_U32 ""}
|
||||
{compiler_name_string_idx RDI_U32 ""}
|
||||
{source_file_path_node RDI_U32 ""}
|
||||
{object_file_path_node RDI_U32 ""}
|
||||
{archive_file_path_node RDI_U32 ""}
|
||||
{build_path_node RDI_U32 ""}
|
||||
{language RDI_Language ""}
|
||||
{line_table_idx RDI_U32 ""}
|
||||
{unit_name_string_idx RDI_U32 ""}
|
||||
{compiler_name_string_idx RDI_U32 ""}
|
||||
{source_file_path_node RDI_U32 ""}
|
||||
{object_file_path_node RDI_U32 ""}
|
||||
{archive_file_path_node RDI_U32 ""}
|
||||
{build_path_node RDI_U32 ""}
|
||||
{language RDI_Language ""}
|
||||
{line_table_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@xlist RDI_Unit_XList:
|
||||
@@ -545,18 +579,18 @@ RDI_LineTableMemberTable:
|
||||
// usage of line info to go from voff to file & line number:
|
||||
// (line_info_voffs * voff) -> (nil + index)
|
||||
// (line_info_data * index) -> (RDI_Line = (file_idx * line_number))
|
||||
{voffs_base_idx RDI_U32 ""} // U64[lines_count+1] (sorted ranges)
|
||||
{lines_base_idx RDI_U32 ""} // RDI_Line[lines_count]
|
||||
{cols_base_idx RDI_U32 ""} // RDI_Column[cols_count]
|
||||
{lines_count RDI_U32 ""}
|
||||
{cols_count RDI_U32 ""}
|
||||
{voffs_base_idx RDI_U32 ""} // U64[lines_count+1] (sorted ranges)
|
||||
{lines_base_idx RDI_U32 ""} // RDI_Line[lines_count]
|
||||
{cols_base_idx RDI_U32 ""} // RDI_Column[cols_count]
|
||||
{lines_count RDI_U32 ""}
|
||||
{cols_count RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_LineMemberTable:
|
||||
{
|
||||
{file_idx RDI_U32 ""}
|
||||
{line_num RDI_U32 ""}
|
||||
{file_idx RDI_U32 ""}
|
||||
{line_num RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
@@ -573,11 +607,11 @@ RDI_SourceLineMapMemberTable:
|
||||
// (line_map_nums * line_number) -> (nil | index)
|
||||
// (line_map_data * index) -> (range)
|
||||
// (line_map_voff_data * range) -> (array(voff))
|
||||
{line_count RDI_U32 ""}
|
||||
{voff_count RDI_U32 ""}
|
||||
{line_map_nums_base_idx RDI_U32 ""} // U32[line_count] (sorted - not closed ranges)
|
||||
{line_map_range_base_idx RDI_U32 ""} // U32[line_count + 1] (pairs form ranges)
|
||||
{line_map_voff_base_idx RDI_U32 ""} // U64[voff_count] (idx by line_map_range_data)
|
||||
{line_count RDI_U32 ""}
|
||||
{voff_count RDI_U32 ""}
|
||||
{line_map_nums_base_idx RDI_U32 ""} // U32[line_count] (sorted - not closed ranges)
|
||||
{line_map_range_base_idx RDI_U32 ""} // U32[line_count + 1] (pairs form ranges)
|
||||
{line_map_voff_base_idx RDI_U32 ""} // U64[voff_count] (idx by line_map_range_data)
|
||||
}
|
||||
|
||||
@xlist RDI_LineTable_XList:
|
||||
@@ -732,13 +766,13 @@ RDI_UDTFlagTable:
|
||||
@table(name type desc)
|
||||
RDI_UDTMemberTable:
|
||||
{
|
||||
{self_type_idx RDI_U32 ""}
|
||||
{flags RDI_UDTFlags ""}
|
||||
{member_first RDI_U32 ""}
|
||||
{member_count RDI_U32 ""}
|
||||
{file_idx RDI_U32 ""}
|
||||
{line RDI_U32 ""}
|
||||
{col RDI_U32 ""}
|
||||
{self_type_idx RDI_U32 ""}
|
||||
{flags RDI_UDTFlags ""}
|
||||
{member_first RDI_U32 ""}
|
||||
{member_count RDI_U32 ""}
|
||||
{file_idx RDI_U32 ""}
|
||||
{line RDI_U32 ""}
|
||||
{col RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name value)
|
||||
@@ -759,19 +793,19 @@ RDI_MemberKindTable:
|
||||
@table(name type desc)
|
||||
RDI_MemberMemberTable:
|
||||
{
|
||||
{kind RDI_MemberKind ""}
|
||||
{pad RDI_U16 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{off RDI_U32 ""}
|
||||
{kind RDI_MemberKind ""}
|
||||
{pad RDI_U16 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{off RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_EnumMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{pad RDI_U32 ""}
|
||||
{val RDI_U64 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{pad RDI_U32 ""}
|
||||
{val RDI_U64 ""}
|
||||
}
|
||||
|
||||
@enum(RDI_U16) RDI_TypeKind:
|
||||
@@ -818,13 +852,15 @@ RDI_EnumMemberTable:
|
||||
{
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 count;
|
||||
union{
|
||||
union
|
||||
{
|
||||
// when kind is 'Function' or 'Method'
|
||||
RDI_U32 param_idx_run_first;
|
||||
// when kind is 'MemberPtr'
|
||||
RDI_U32 owner_type_idx;
|
||||
};
|
||||
} constructed;
|
||||
}
|
||||
constructed;
|
||||
|
||||
// kind is 'user defined'
|
||||
struct
|
||||
@@ -832,7 +868,8 @@ RDI_EnumMemberTable:
|
||||
RDI_U32 name_string_idx;
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 udt_idx;
|
||||
} user_defined;
|
||||
}
|
||||
user_defined;
|
||||
|
||||
// (kind = Bitfield)
|
||||
struct
|
||||
@@ -840,7 +877,8 @@ RDI_EnumMemberTable:
|
||||
RDI_U32 direct_type_idx;
|
||||
RDI_U32 off;
|
||||
RDI_U32 size;
|
||||
} bitfield;
|
||||
}
|
||||
bitfield;
|
||||
}
|
||||
```
|
||||
}
|
||||
@@ -930,44 +968,44 @@ RDI_LocationKindTable:
|
||||
@table(name type desc)
|
||||
RDI_GlobalVariableMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{voff RDI_U64 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{voff RDI_U64 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_ThreadVariableMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{tls_off RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{tls_off RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_ProcedureMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{root_scope_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{link_name_string_idx RDI_U32 ""}
|
||||
{link_flags RDI_LinkFlags ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{root_scope_idx RDI_U32 ""}
|
||||
{container_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_ScopeMemberTable:
|
||||
{
|
||||
{proc_idx RDI_U32 ""}
|
||||
{parent_scope_idx RDI_U32 ""}
|
||||
{first_child_scope_idx RDI_U32 ""}
|
||||
{next_sibling_scope_idx RDI_U32 ""}
|
||||
{voff_range_first RDI_U32 ""}
|
||||
{voff_range_opl RDI_U32 ""}
|
||||
{local_first RDI_U32 ""}
|
||||
{proc_idx RDI_U32 ""}
|
||||
{parent_scope_idx RDI_U32 ""}
|
||||
{first_child_scope_idx RDI_U32 ""}
|
||||
{next_sibling_scope_idx RDI_U32 ""}
|
||||
{voff_range_first RDI_U32 ""}
|
||||
{voff_range_opl RDI_U32 ""}
|
||||
{local_first RDI_U32 ""}
|
||||
{local_count RDI_U32 ""}
|
||||
{static_local_idx_run_first RDI_U32 ""}
|
||||
{static_local_count RDI_U32 ""}
|
||||
@@ -976,32 +1014,32 @@ RDI_ScopeMemberTable:
|
||||
@table(name type desc)
|
||||
RDI_InlineSiteMemberTable:
|
||||
{
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{call_src_file_idx RDI_U32 ""}
|
||||
{call_line_num RDI_U32 ""}
|
||||
{call_col_num RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{owner_type_idx RDI_U32 ""}
|
||||
{line_table_idx RDI_U32 ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{call_src_file_idx RDI_U32 ""}
|
||||
{call_line_num RDI_U32 ""}
|
||||
{call_col_num RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{owner_type_idx RDI_U32 ""}
|
||||
{line_table_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_LocalMemberTable:
|
||||
{
|
||||
{kind RDI_LocalKind ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{pad RDI_U32 ""}
|
||||
{location_first RDI_U32 ""}
|
||||
{location_opl RDI_U32 ""}
|
||||
{kind RDI_LocalKind ""}
|
||||
{name_string_idx RDI_U32 ""}
|
||||
{type_idx RDI_U32 ""}
|
||||
{pad RDI_U32 ""}
|
||||
{location_first RDI_U32 ""}
|
||||
{location_opl RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_LocationBlockMemberTable:
|
||||
{
|
||||
{scope_off_first RDI_U32}
|
||||
{scope_off_opl RDI_U32}
|
||||
{location_data_off RDI_U32}
|
||||
{scope_off_first RDI_U32 }
|
||||
{scope_off_opl RDI_U32 }
|
||||
{location_data_off RDI_U32 }
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
@@ -1314,9 +1352,11 @@ RDI_NameMapKindTable:
|
||||
@table(name type desc)
|
||||
RDI_NameMapMemberTable:
|
||||
{
|
||||
{kind RDI_NameMapKind ""}
|
||||
{bucket_data_idx RDI_U32 ""}
|
||||
{node_data_idx RDI_U32 ""}
|
||||
{kind RDI_NameMapKind ""}
|
||||
{bucket_base_idx RDI_U32 ""}
|
||||
{node_base_idx RDI_U32 ""}
|
||||
{bucket_count RDI_U32 ""}
|
||||
{node_count RDI_U32 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
@@ -1329,11 +1369,11 @@ RDI_NameMapBucketMemberTable:
|
||||
@table(name type desc)
|
||||
RDI_NameMapNodeMemberTable:
|
||||
{
|
||||
{string_idx RDI_U32 ""}
|
||||
{match_count RDI_U32 ""}
|
||||
{string_idx RDI_U32 ""}
|
||||
{match_count RDI_U32 ""}
|
||||
// NOTE: if (match_count == 1) then this is the index of the matching item
|
||||
// if (match_count > 1) then this is the first for an index run of all the matches
|
||||
{match_idx_or_idx_run_first RDI_U32 ""}
|
||||
{match_idx_or_idx_run_first RDI_U32 ""}
|
||||
}
|
||||
|
||||
@enum(RDI_U32) RDI_NameMapKind:
|
||||
|
||||
@@ -15,16 +15,16 @@ rdi_decompress_parsed(U8 *decompressed_data, U64 decompressed_size, RDI_Parsed *
|
||||
}
|
||||
|
||||
// rjf: copy & adjust sections for decompressed version
|
||||
if(og_rdi->dsec_count != 0)
|
||||
if(og_rdi->sections_count != 0)
|
||||
{
|
||||
RDI_DataSection *dsec_base = (RDI_DataSection *)(decompressed_data + dst_header->data_section_off);
|
||||
MemoryCopy(dsec_base, (U8 *)og_rdi->raw_data + src_header->data_section_off, sizeof(RDI_DataSection) * og_rdi->dsec_count);
|
||||
U64 off = dst_header->data_section_off + sizeof(RDI_DataSection) * og_rdi->dsec_count;
|
||||
RDI_Section *dsec_base = (RDI_Section *)(decompressed_data + dst_header->data_section_off);
|
||||
MemoryCopy(dsec_base, (U8 *)og_rdi->raw_data + src_header->data_section_off, sizeof(RDI_Section) * og_rdi->sections_count);
|
||||
U64 off = dst_header->data_section_off + sizeof(RDI_Section) * og_rdi->sections_count;
|
||||
off += 7;
|
||||
off -= off%8;
|
||||
for(U64 idx = 0; idx < og_rdi->dsec_count; idx += 1)
|
||||
for(U64 idx = 0; idx < og_rdi->sections_count; idx += 1)
|
||||
{
|
||||
dsec_base[idx].encoding = RDI_DataSectionEncoding_Unpacked;
|
||||
dsec_base[idx].encoding = RDI_SectionEncoding_Unpacked;
|
||||
dsec_base[idx].off = off;
|
||||
dsec_base[idx].encoded_size = dsec_base[idx].unpacked_size;
|
||||
off += dsec_base[idx].unpacked_size;
|
||||
@@ -34,13 +34,13 @@ rdi_decompress_parsed(U8 *decompressed_data, U64 decompressed_size, RDI_Parsed *
|
||||
}
|
||||
|
||||
// rjf: decompress sections into new decompressed file buffer
|
||||
if(og_rdi->dsec_count != 0)
|
||||
if(og_rdi->sections_count != 0)
|
||||
{
|
||||
RDI_DataSection *src_first = og_rdi->dsecs;
|
||||
RDI_DataSection *dst_first = (RDI_DataSection *)(decompressed_data + dst_header->data_section_off);
|
||||
RDI_DataSection *src_opl = src_first + og_rdi->dsec_count;
|
||||
RDI_DataSection *dst_opl = dst_first + og_rdi->dsec_count;
|
||||
for(RDI_DataSection *src = src_first, *dst = dst_first;
|
||||
RDI_Section *src_first = og_rdi->sections;
|
||||
RDI_Section *dst_first = (RDI_Section *)(decompressed_data + dst_header->data_section_off);
|
||||
RDI_Section *src_opl = src_first + og_rdi->sections_count;
|
||||
RDI_Section *dst_opl = dst_first + og_rdi->sections_count;
|
||||
for(RDI_Section *src = src_first, *dst = dst_first;
|
||||
src < src_opl && dst < dst_opl;
|
||||
src += 1, dst += 1)
|
||||
{
|
||||
|
||||
@@ -4302,7 +4302,7 @@ p2r_compress(Arena *arena, P2R_Bake2Serialize *in)
|
||||
|
||||
// rjf: unpack uncompressed section info
|
||||
void *data = src->data;
|
||||
RDI_DataSectionEncoding encoding = src->encoding;
|
||||
RDI_SectionEncoding encoding = src->encoding;
|
||||
RDI_U64 encoded_size = src->encoded_size;
|
||||
RDI_U64 unpacked_size = src->unpacked_size;
|
||||
|
||||
@@ -4316,7 +4316,7 @@ p2r_compress(Arena *arena, P2R_Bake2Serialize *in)
|
||||
void *raw_data = data;
|
||||
data = push_array_no_zero(arena, U8, unpacked_size);
|
||||
encoded_size = rr_lzb_simple_encode_veryfast(&ctx, raw_data, unpacked_size, data);
|
||||
encoding = RDI_DataSectionEncoding_LZB;
|
||||
encoding = RDI_SectionEncoding_LZB;
|
||||
}
|
||||
|
||||
// rjf: fill
|
||||
|
||||
+24
-33
@@ -336,9 +336,9 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
case TG_KeyKind_Ext:
|
||||
{
|
||||
U64 type_node_idx = key.u64[0];
|
||||
if(0 <= type_node_idx && type_node_idx < rdi->type_nodes_count)
|
||||
RDI_TypeNode *rdi_type = rdi_element_from_name_idx(rdi, TypeNodes, type_node_idx);
|
||||
if(rdi_type->kind != RDI_TypeKind_NULL)
|
||||
{
|
||||
RDI_TypeNode *rdi_type = &rdi->type_nodes[type_node_idx];
|
||||
TG_Kind kind = tg_kind_from_rdi_type_kind(rdi_type->kind);
|
||||
|
||||
//- rjf: record types => unpack name * members & produce
|
||||
@@ -349,7 +349,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
name.str = rdi_string_from_idx(rdi, rdi_type->user_defined.name_string_idx, &name.size);
|
||||
|
||||
// rjf: unpack UDT info
|
||||
RDI_UDT *udt = rdi_element_from_idx(rdi, udts, rdi_type->user_defined.udt_idx);
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, rdi_type->user_defined.udt_idx);
|
||||
|
||||
// rjf: unpack members
|
||||
TG_Member *members = 0;
|
||||
@@ -357,19 +357,16 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
{
|
||||
members_count = udt->member_count;
|
||||
members = push_array(arena, TG_Member, members_count);
|
||||
if(members_count != 0 && 0 <= udt->member_first && udt->member_first+udt->member_count <= rdi->members_count)
|
||||
if(members_count != 0)
|
||||
{
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
RDI_Member *src = &rdi->members[member_idx];
|
||||
RDI_Member *src = rdi_element_from_name_idx(rdi, Members, member_idx);
|
||||
TG_Kind member_type_kind = TG_Kind_Null;
|
||||
if(src->type_idx < rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *member_type = &rdi->type_nodes[src->type_idx];
|
||||
member_type_kind = tg_kind_from_rdi_type_kind(member_type->kind);
|
||||
}
|
||||
RDI_TypeNode *member_type = rdi_element_from_name_idx(rdi, TypeNodes, src->type_idx);
|
||||
member_type_kind = tg_kind_from_rdi_type_kind(member_type->kind);
|
||||
TG_Member *dst = &members[member_idx-udt->member_first];
|
||||
dst->kind = tg_member_kind_from_rdi_member_kind(src->kind);
|
||||
dst->type_key = tg_key_ext(member_type_kind, (U64)src->type_idx);
|
||||
@@ -399,7 +396,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
TG_Key direct_type_key = zero_struct;
|
||||
if(rdi_type->user_defined.direct_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *direct_type_node = &rdi->type_nodes[rdi_type->user_defined.direct_type_idx];
|
||||
RDI_TypeNode *direct_type_node = rdi_element_from_name_idx(rdi, TypeNodes, rdi_type->user_defined.direct_type_idx);
|
||||
TG_Kind direct_type_kind = tg_kind_from_rdi_type_kind(direct_type_node->kind);
|
||||
direct_type_key = tg_key_ext(direct_type_kind, (U64)rdi_type->user_defined.direct_type_idx);
|
||||
}
|
||||
@@ -409,23 +406,17 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U32 enum_vals_count = 0;
|
||||
{
|
||||
U32 udt_idx = rdi_type->user_defined.udt_idx;
|
||||
if(0 <= udt_idx && udt_idx < rdi->udts_count)
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, udt_idx);
|
||||
enum_vals_count = udt->member_count;
|
||||
enum_vals = push_array(arena, TG_EnumVal, enum_vals_count);
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
RDI_UDT *udt = &rdi->udts[udt_idx];
|
||||
enum_vals_count = udt->member_count;
|
||||
enum_vals = push_array(arena, TG_EnumVal, enum_vals_count);
|
||||
if(0 <= udt->member_first && udt->member_first+udt->member_count < rdi->enum_members_count)
|
||||
{
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
RDI_EnumMember *src = &rdi->enum_members[member_idx];
|
||||
TG_EnumVal *dst = &enum_vals[member_idx-udt->member_first];
|
||||
dst->name.str = rdi_string_from_idx(rdi, src->name_string_idx, &dst->name.size);
|
||||
dst->val = src->val;
|
||||
}
|
||||
}
|
||||
RDI_EnumMember *src = rdi_element_from_name_idx(rdi, EnumMembers, member_idx);
|
||||
TG_EnumVal *dst = &enum_vals[member_idx-udt->member_first];
|
||||
dst->name.str = rdi_string_from_idx(rdi, src->name_string_idx, &dst->name.size);
|
||||
dst->val = src->val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +439,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U64 direct_type_byte_size = 0;
|
||||
if(rdi_type->constructed.direct_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *direct_type_node = &rdi->type_nodes[rdi_type->constructed.direct_type_idx];
|
||||
RDI_TypeNode *direct_type_node = rdi_element_from_name_idx(rdi, TypeNodes, rdi_type->constructed.direct_type_idx);
|
||||
TG_Kind direct_type_kind = tg_kind_from_rdi_type_kind(direct_type_node->kind);
|
||||
direct_type_key = tg_key_ext(direct_type_kind, (U64)rdi_type->constructed.direct_type_idx);
|
||||
direct_type_is_good = 1;
|
||||
@@ -512,7 +503,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U32 param_type_idx = idx_run[idx];
|
||||
if(param_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *param_type_node = &rdi->type_nodes[param_type_idx];
|
||||
RDI_TypeNode *param_type_node = rdi_element_from_name_idx(rdi, TypeNodes, param_type_idx);
|
||||
TG_Kind param_kind = tg_kind_from_rdi_type_kind(param_type_node->kind);
|
||||
type->param_type_keys[idx] = tg_key_ext(param_kind, (U64)param_type_idx);
|
||||
}
|
||||
@@ -545,7 +536,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U32 param_type_idx = idx_run[idx];
|
||||
if(param_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *param_type_node = &rdi->type_nodes[param_type_idx];
|
||||
RDI_TypeNode *param_type_node = rdi_element_from_name_idx(rdi, TypeNodes, param_type_idx);
|
||||
TG_Kind param_kind = tg_kind_from_rdi_type_kind(param_type_node->kind);
|
||||
type->param_type_keys[idx] = tg_key_ext(param_kind, (U64)param_type_idx);
|
||||
}
|
||||
@@ -568,7 +559,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
TG_Key owner_type_key = zero_struct;
|
||||
if(rdi_type->constructed.owner_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *owner_type_node = &rdi->type_nodes[rdi_type->constructed.owner_type_idx];
|
||||
RDI_TypeNode *owner_type_node = rdi_element_from_name_idx(rdi, TypeNodes, rdi_type->constructed.owner_type_idx);
|
||||
TG_Kind owner_type_kind = tg_kind_from_rdi_type_kind(owner_type_node->kind);
|
||||
owner_type_key = tg_key_ext(owner_type_kind, (U64)rdi_type->constructed.owner_type_idx);
|
||||
}
|
||||
@@ -593,7 +584,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U64 direct_type_byte_size = 0;
|
||||
if(rdi_type->user_defined.direct_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *direct_type_node = &rdi->type_nodes[rdi_type->user_defined.direct_type_idx];
|
||||
RDI_TypeNode *direct_type_node = rdi_element_from_name_idx(rdi, TypeNodes, rdi_type->user_defined.direct_type_idx);
|
||||
TG_Kind direct_type_kind = tg_kind_from_rdi_type_kind(direct_type_node->kind);
|
||||
direct_type_key = tg_key_ext(direct_type_kind, (U64)rdi_type->user_defined.direct_type_idx);
|
||||
direct_type_byte_size = direct_type_node->byte_size;
|
||||
@@ -615,7 +606,7 @@ tg_type_from_graph_rdi_key(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, TG_Ke
|
||||
U64 direct_type_byte_size = 0;
|
||||
if(rdi_type->bitfield.direct_type_idx < type_node_idx)
|
||||
{
|
||||
RDI_TypeNode *direct_type_node = &rdi->type_nodes[rdi_type->bitfield.direct_type_idx];
|
||||
RDI_TypeNode *direct_type_node = rdi_element_from_name_idx(rdi, TypeNodes, rdi_type->bitfield.direct_type_idx);
|
||||
TG_Kind direct_type_kind = tg_kind_from_rdi_type_kind(direct_type_node->kind);
|
||||
direct_type_key = tg_key_ext(direct_type_kind, (U64)rdi_type->bitfield.direct_type_idx);
|
||||
direct_type_byte_size = direct_type_node->byte_size;
|
||||
|
||||
Reference in New Issue
Block a user