mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 08:32:22 -07:00
move per-source-file line maps to top-level sections, and move source line -> voff maps to separate top-level info table
This commit is contained in:
@@ -2965,8 +2965,9 @@ 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_ParsedLineMap line_map = {0};
|
||||
rdi_line_map_from_source_file(rdi, src, &line_map);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, 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;
|
||||
U64 *voffs = rdi_line_voffs_from_num(&line_map, pt.line, &voff_count);
|
||||
for(U32 i = 0; i < voff_count; i += 1)
|
||||
|
||||
@@ -210,6 +210,7 @@ global RDI_Parsed di_rdi_parsed_nil =
|
||||
&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,
|
||||
|
||||
@@ -3262,8 +3262,9 @@ df_text_line_src2dasm_info_list_array_from_src_line_range(Arena *arena, DF_Entit
|
||||
if(good_src_id)
|
||||
{
|
||||
RDI_SourceFile *src = rdi->source_files+src_id;
|
||||
RDI_ParsedLineMap line_map = {0};
|
||||
rdi_line_map_from_source_file(rdi, src, &line_map);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, 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;
|
||||
for(S64 line_num = line_num_range.min;
|
||||
line_num <= line_num_range.max;
|
||||
@@ -3950,8 +3951,9 @@ df_eval_parse_ctx_from_src_loc(DI_Scope *scope, DF_Entity *file, TxtPt pt)
|
||||
if(good_src_id)
|
||||
{
|
||||
RDI_SourceFile *src = rdi->source_files+src_id;
|
||||
RDI_ParsedLineMap line_map = {0};
|
||||
rdi_line_map_from_source_file(rdi, src, &line_map);
|
||||
RDI_SourceLineMap *src_line_map = rdi_element_from_idx(rdi, source_line_maps, 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;
|
||||
U64 *voffs = rdi_line_voffs_from_num(&line_map, (U32)pt.line, &voff_count);
|
||||
for(U64 idx = 0; idx < voff_count; idx += 1)
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef int64_t RDI_S64;
|
||||
|
||||
// \"raddbg\0\0\"
|
||||
#define RDI_MAGIC_CONSTANT 0x0000676264646172
|
||||
#define RDI_ENCODING_VERSION 2
|
||||
#define RDI_ENCODING_VERSION 3
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//~ Format Types & Functions
|
||||
@@ -65,31 +65,32 @@ RDI_DataSectionTag_LineTables = 0x0008,
|
||||
RDI_DataSectionTag_LineInfoVoffs = 0x0009,
|
||||
RDI_DataSectionTag_LineInfoLines = 0x000A,
|
||||
RDI_DataSectionTag_LineInfoColumns = 0x000B,
|
||||
RDI_DataSectionTag_Units = 0x000C,
|
||||
RDI_DataSectionTag_UnitVmap = 0x000D,
|
||||
RDI_DataSectionTag_TypeNodes = 0x000E,
|
||||
RDI_DataSectionTag_UDTs = 0x000F,
|
||||
RDI_DataSectionTag_Members = 0x0010,
|
||||
RDI_DataSectionTag_EnumMembers = 0x0011,
|
||||
RDI_DataSectionTag_GlobalVariables = 0x0012,
|
||||
RDI_DataSectionTag_GlobalVmap = 0x0013,
|
||||
RDI_DataSectionTag_ThreadVariables = 0x0014,
|
||||
RDI_DataSectionTag_Procedures = 0x0015,
|
||||
RDI_DataSectionTag_Scopes = 0x0016,
|
||||
RDI_DataSectionTag_ScopeVoffData = 0x0017,
|
||||
RDI_DataSectionTag_ScopeVmap = 0x0018,
|
||||
RDI_DataSectionTag_InlineSites = 0x0019,
|
||||
RDI_DataSectionTag_Locals = 0x001A,
|
||||
RDI_DataSectionTag_LocationBlocks = 0x001B,
|
||||
RDI_DataSectionTag_LocationData = 0x001C,
|
||||
RDI_DataSectionTag_NameMaps = 0x001D,
|
||||
RDI_DataSectionTag_PRIMARY_COUNT = 0x001E,
|
||||
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_LineMapNumbers = RDI_DataSectionTag_SECONDARY|0x0001,
|
||||
RDI_DataSectionTag_LineMapRanges = RDI_DataSectionTag_SECONDARY|0x0002,
|
||||
RDI_DataSectionTag_LineMapVoffs = RDI_DataSectionTag_SECONDARY|0x0003,
|
||||
RDI_DataSectionTag_NameMapBuckets = RDI_DataSectionTag_SECONDARY|0x0004,
|
||||
RDI_DataSectionTag_NameMapNodes = RDI_DataSectionTag_SECONDARY|0x0005,
|
||||
RDI_DataSectionTag_NameMapBuckets = RDI_DataSectionTag_SECONDARY|0x0001,
|
||||
RDI_DataSectionTag_NameMapNodes = RDI_DataSectionTag_SECONDARY|0x0002,
|
||||
} RDI_DataSectionTagEnum;
|
||||
|
||||
typedef RDI_U32 RDI_DataSectionEncoding;
|
||||
@@ -506,6 +507,10 @@ X(LineTables)\
|
||||
X(LineInfoVoffs)\
|
||||
X(LineInfoLines)\
|
||||
X(LineInfoColumns)\
|
||||
X(SourceLineMaps)\
|
||||
X(SourceLineMapNumbers)\
|
||||
X(SourceLineMapRanges)\
|
||||
X(SourceLineMapVOffs)\
|
||||
X(Units)\
|
||||
X(UnitVmap)\
|
||||
X(TypeNodes)\
|
||||
@@ -526,9 +531,6 @@ X(LocationData)\
|
||||
X(NameMaps)\
|
||||
X(PRIMARY_COUNT)\
|
||||
X(SECONDARY)\
|
||||
X(LineMapNumbers)\
|
||||
X(LineMapRanges)\
|
||||
X(LineMapVoffs)\
|
||||
X(NameMapBuckets)\
|
||||
X(NameMapNodes)\
|
||||
|
||||
@@ -581,10 +583,7 @@ X(RDI_U32, source_file_idx)\
|
||||
#define RDI_SourceFile_XList \
|
||||
X(RDI_U32, file_path_node_idx)\
|
||||
X(RDI_U32, normal_full_path_string_idx)\
|
||||
X(RDI_U32, line_map_count)\
|
||||
X(RDI_U32, line_map_nums_data_idx)\
|
||||
X(RDI_U32, line_map_range_data_idx)\
|
||||
X(RDI_U32, line_map_voff_data_idx)\
|
||||
X(RDI_U32, source_line_map_idx)\
|
||||
|
||||
#define RDI_Unit_XList \
|
||||
X(RDI_U32, unit_name_string_idx)\
|
||||
@@ -611,6 +610,13 @@ X(RDI_U32, line_num)\
|
||||
X(RDI_U16, col_first)\
|
||||
X(RDI_U16, col_opl)\
|
||||
|
||||
#define RDI_SourceLineMapMemberTable \
|
||||
X(RDI_U32, line_count)\
|
||||
X(RDI_U32, voff_count)\
|
||||
X(RDI_U32, line_map_nums_base_idx)\
|
||||
X(RDI_U32, line_map_range_base_idx)\
|
||||
X(RDI_U32, line_map_voff_base_idx)\
|
||||
|
||||
#define RDI_Language_XList \
|
||||
X(NULL)\
|
||||
X(C)\
|
||||
@@ -958,10 +964,7 @@ struct RDI_SourceFile
|
||||
{
|
||||
RDI_U32 file_path_node_idx;
|
||||
RDI_U32 normal_full_path_string_idx;
|
||||
RDI_U32 line_map_count;
|
||||
RDI_U32 line_map_nums_data_idx;
|
||||
RDI_U32 line_map_range_data_idx;
|
||||
RDI_U32 line_map_voff_data_idx;
|
||||
RDI_U32 source_line_map_idx;
|
||||
};
|
||||
|
||||
typedef struct RDI_Unit RDI_Unit;
|
||||
@@ -1001,6 +1004,16 @@ RDI_U16 col_first;
|
||||
RDI_U16 col_opl;
|
||||
};
|
||||
|
||||
typedef struct RDI_SourceLineMap RDI_SourceLineMap;
|
||||
struct RDI_SourceLineMap
|
||||
{
|
||||
RDI_U32 line_count;
|
||||
RDI_U32 voff_count;
|
||||
RDI_U32 line_map_nums_base_idx;
|
||||
RDI_U32 line_map_range_base_idx;
|
||||
RDI_U32 line_map_voff_base_idx;
|
||||
};
|
||||
|
||||
typedef struct RDI_TypeNode RDI_TypeNode;
|
||||
struct RDI_TypeNode
|
||||
{
|
||||
|
||||
@@ -145,6 +145,7 @@ rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out)
|
||||
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);
|
||||
@@ -185,6 +186,8 @@ rdi_parse(RDI_U8 *data, RDI_U64 size, RDI_Parsed *out)
|
||||
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; }
|
||||
@@ -329,36 +332,39 @@ rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff)
|
||||
}
|
||||
|
||||
RDI_PROC void
|
||||
rdi_line_map_from_source_file(RDI_Parsed *p, RDI_SourceFile *srcfile, RDI_ParsedLineMap *out)
|
||||
rdi_parsed_from_source_line_map(RDI_Parsed *p, RDI_SourceLineMap *map, RDI_ParsedSourceLineMap *out)
|
||||
{
|
||||
RDI_U64 num_count = 0;
|
||||
RDI_U32 *nums = (RDI_U32*)rdi_data_from_dsec(p, srcfile->line_map_nums_data_idx, sizeof(RDI_U32),
|
||||
RDI_DataSectionTag_LineMapNumbers,
|
||||
&num_count);
|
||||
//- 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_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_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_opl = all_voffs + all_voffs_count;
|
||||
|
||||
RDI_U64 range_count = 0;
|
||||
RDI_U32 *ranges = (RDI_U32*)rdi_data_from_dsec(p, srcfile->line_map_range_data_idx, sizeof(RDI_U32),
|
||||
RDI_DataSectionTag_LineMapRanges,
|
||||
&range_count);
|
||||
//- rjf: extract ranges of top-level tables belonging to this line map
|
||||
RDI_U32 *map_nums = all_nums + map->line_map_nums_base_idx;
|
||||
RDI_U32 *map_rngs = all_rngs + map->line_map_range_base_idx;
|
||||
RDI_U64 *map_voffs= all_voffs+ map->line_map_voff_base_idx;
|
||||
RDI_U64 lines_count = (RDI_U64)map->line_count;
|
||||
RDI_U64 voffs_count = (RDI_U64)map->voff_count;
|
||||
if(map_nums >= all_nums_opl) {map_nums = all_nums; lines_count = 0;}
|
||||
if(map_rngs >= all_rngs_opl) {map_rngs = all_rngs; lines_count = 0;}
|
||||
if(map_voffs>= all_voffs_opl){map_voffs= all_voffs;voffs_count = 0;}
|
||||
|
||||
RDI_U64 voff_count = 0;
|
||||
RDI_U64 *voffs = (RDI_U64*)rdi_data_from_dsec(p, srcfile->line_map_voff_data_idx, sizeof(RDI_U64),
|
||||
RDI_DataSectionTag_LineMapVoffs,
|
||||
&voff_count);
|
||||
|
||||
RDI_U32 count_a = (range_count > 0)?(range_count - 1):0;
|
||||
RDI_U32 count_b = rdi_parse__min(count_a, num_count);
|
||||
RDI_U32 count = rdi_parse__min(count_b, srcfile->line_map_count);
|
||||
|
||||
out->nums = nums;
|
||||
out->ranges = ranges;
|
||||
out->voffs = voffs;
|
||||
out->count = count;
|
||||
out->voff_count = voff_count;
|
||||
//- rjf: fill result
|
||||
out->nums = map_nums;
|
||||
out->ranges = map_rngs;
|
||||
out->voffs = map_voffs;
|
||||
out->count = lines_count;
|
||||
out->voff_count = voffs_count;
|
||||
}
|
||||
|
||||
RDI_PROC RDI_U64*
|
||||
rdi_line_voffs_from_num(RDI_ParsedLineMap *map, RDI_U32 linenum, RDI_U32 *n_out)
|
||||
rdi_line_voffs_from_num(RDI_ParsedSourceLineMap *map, RDI_U32 linenum, RDI_U32 *n_out)
|
||||
{
|
||||
RDI_U64 *result = 0;
|
||||
*n_out = 0;
|
||||
|
||||
@@ -53,6 +53,8 @@ struct RDI_Parsed
|
||||
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;
|
||||
@@ -110,8 +112,8 @@ struct RDI_ParsedLineTable
|
||||
RDI_U64 col_count;
|
||||
};
|
||||
|
||||
typedef struct RDI_ParsedLineMap RDI_ParsedLineMap;
|
||||
struct RDI_ParsedLineMap
|
||||
typedef struct RDI_ParsedSourceLineMap RDI_ParsedSourceLineMap;
|
||||
struct RDI_ParsedSourceLineMap
|
||||
{
|
||||
// NOTE: Mapping LINE_NUMBER -> VOFFs
|
||||
//
|
||||
@@ -146,6 +148,7 @@ 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};
|
||||
@@ -186,8 +189,8 @@ RDI_PROC RDI_U32 *rdi_idx_run_from_first_count(RDI_Parsed *parsed, RDI_U32 first
|
||||
//- line info
|
||||
RDI_PROC void rdi_parsed_from_line_table(RDI_Parsed *p, 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_line_map_from_source_file(RDI_Parsed *p, RDI_SourceFile *srcfile, RDI_ParsedLineMap *out);
|
||||
RDI_PROC RDI_U64 *rdi_line_voffs_from_num(RDI_ParsedLineMap *map, RDI_U32 linenum, RDI_U32 *n_out);
|
||||
RDI_PROC void rdi_parsed_from_source_line_map(RDI_Parsed *p, 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);
|
||||
|
||||
+104
-58
@@ -509,9 +509,14 @@ rdim_src_file_chunk_list_concat_in_place(RDIM_SrcFileChunkList *dst, RDIM_SrcFil
|
||||
RDI_PROC void
|
||||
rdim_src_file_push_line_sequence(RDIM_Arena *arena, RDIM_SrcFileChunkList *src_files, RDIM_SrcFile *src_file, RDIM_LineSequence *seq)
|
||||
{
|
||||
if(src_file->first_line_map_fragment == 0)
|
||||
{
|
||||
src_files->source_line_map_count += 1;
|
||||
}
|
||||
RDIM_SrcFileLineMapFragment *fragment = rdim_push_array(arena, RDIM_SrcFileLineMapFragment, 1);
|
||||
fragment->seq = seq;
|
||||
RDIM_SLLQueuePush(src_file->first_line_map_fragment, src_file->last_line_map_fragment, fragment);
|
||||
src_files->total_line_count += seq->line_count;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -1058,9 +1063,6 @@ rdim_bake_section_count_from_params(RDIM_BakeParams *params)
|
||||
RDI_U64 section_count = 0;
|
||||
{
|
||||
section_count += RDI_DataSectionTag_PRIMARY_COUNT;
|
||||
section_count += params->src_files.total_count; // PER-SOURCE-FILE line map numbers
|
||||
section_count += params->src_files.total_count; // PER-SOURCE-FILE line map ranges
|
||||
section_count += params->src_files.total_count; // PER-SOURCE-FILE line map voffs
|
||||
section_count += RDI_NameMapKind_COUNT-1; // PER-NAME-MAP buckets section
|
||||
section_count += RDI_NameMapKind_COUNT-1; // PER-NAME-MAP nodes section
|
||||
}
|
||||
@@ -1079,33 +1081,16 @@ rdim_bake_section_idx_from_params_tag_idx(RDIM_BakeParams *params, RDI_DataSecti
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
//- rjf: per-source-file sections
|
||||
case (RDI_U32)RDI_DataSectionTag_LineMapNumbers:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 0*params->src_files.total_count + (idx-1)%params->src_files.total_count;
|
||||
}break;
|
||||
case (RDI_U32)RDI_DataSectionTag_LineMapRanges:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 1*params->src_files.total_count + (idx-1)%params->src_files.total_count;
|
||||
}break;
|
||||
case (RDI_U32)RDI_DataSectionTag_LineMapVoffs:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 2*params->src_files.total_count + (idx-1)%params->src_files.total_count;
|
||||
}break;
|
||||
|
||||
//- rjf: per-name-map sections
|
||||
case (RDI_U32)RDI_DataSectionTag_NameMapBuckets:
|
||||
if(idx != 0)
|
||||
{
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 3*params->src_files.total_count + 0*(RDI_NameMapKind_COUNT-1) + (idx-1)%(RDI_NameMapKind_COUNT-1);
|
||||
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 + 3*params->src_files.total_count + 1*(RDI_NameMapKind_COUNT-1) + (idx-1)%(RDI_NameMapKind_COUNT-1);
|
||||
result = RDI_DataSectionTag_PRIMARY_COUNT + 1*(RDI_NameMapKind_COUNT-1) + (idx-1)%(RDI_NameMapKind_COUNT-1);
|
||||
}break;
|
||||
}
|
||||
return result;
|
||||
@@ -2329,14 +2314,34 @@ rdim_bake_unit_vmap_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams
|
||||
RDI_PROC RDIM_BakeSectionList
|
||||
rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree, RDIM_BakeParams *params)
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: iterate all source files, fill serialized version, build sections for line info
|
||||
//- rjf: iterate all source files, fill serialized version, fill line maps, fill line map tables
|
||||
//
|
||||
typedef struct RDIM_DataNode RDIM_DataNode;
|
||||
struct RDIM_DataNode
|
||||
{
|
||||
RDIM_DataNode *next;
|
||||
void *data;
|
||||
RDI_U64 size;
|
||||
};
|
||||
RDI_U32 dst_files_count = params->src_files.total_count + 1;
|
||||
RDI_U32 dst_maps_count = params->src_files.source_line_map_count + 1;
|
||||
RDI_SourceFile *dst_files = rdim_push_array(arena, RDI_SourceFile, dst_files_count);
|
||||
RDI_SourceLineMap *dst_maps = rdim_push_array(arena, RDI_SourceLineMap, dst_maps_count);
|
||||
RDIM_DataNode *first_dst_nums_node = 0;
|
||||
RDIM_DataNode *last_dst_nums_node = 0;
|
||||
RDIM_DataNode *first_dst_rngs_node = 0;
|
||||
RDIM_DataNode *last_dst_rngs_node = 0;
|
||||
RDIM_DataNode *first_dst_voffs_node = 0;
|
||||
RDIM_DataNode *last_dst_voffs_node = 0;
|
||||
RDI_U64 dst_nums_idx = 0;
|
||||
RDI_U64 dst_rngs_idx = 0;
|
||||
RDI_U64 dst_voffs_idx = 0;
|
||||
RDI_U32 dst_file_idx = 1;
|
||||
RDI_U32 dst_map_idx = 1;
|
||||
for(RDIM_SrcFileChunkNode *chunk_n = params->src_files.first;
|
||||
chunk_n != 0;
|
||||
chunk_n = chunk_n->next)
|
||||
@@ -2346,12 +2351,6 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
RDIM_SrcFile *src_file = &chunk_n->v[idx];
|
||||
RDI_SourceFile *dst_file = &dst_files[dst_file_idx];
|
||||
|
||||
////////////////////////
|
||||
//- rjf: fill basics
|
||||
//
|
||||
dst_file->file_path_node_idx = rdim_bake_path_node_idx_from_string(path_tree, src_file->normal_full_path);
|
||||
dst_file->normal_full_path_string_idx = rdim_bake_idx_from_string(strings, src_file->normal_full_path);
|
||||
|
||||
////////////////////////
|
||||
//- rjf: produce combined source file line info
|
||||
//
|
||||
@@ -2361,8 +2360,6 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
RDI_U32 src_file_line_count = 0;
|
||||
RDI_U32 src_file_voff_count = 0;
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: gather line number map
|
||||
typedef struct RDIM_SrcLineMapVoffBlock RDIM_SrcLineMapVoffBlock;
|
||||
struct RDIM_SrcLineMapVoffBlock
|
||||
@@ -2458,9 +2455,9 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
RDIM_SortKey *sorted_keys = rdim_sort_key_array(scratch.arena, keys, line_count);
|
||||
|
||||
//- rjf: bake result
|
||||
RDI_U32 *line_nums = rdim_push_array_no_zero(arena, RDI_U32, line_count);
|
||||
RDI_U32 *line_ranges = rdim_push_array_no_zero(arena, RDI_U32, line_count + 1);
|
||||
RDI_U64 *voffs = rdim_push_array_no_zero(arena, RDI_U64, voff_count);
|
||||
RDI_U32 *line_nums = rdim_push_array_no_zero(scratch.arena, RDI_U32, line_count);
|
||||
RDI_U32 *line_ranges = rdim_push_array_no_zero(scratch.arena, RDI_U32, line_count + 1);
|
||||
RDI_U64 *voffs = rdim_push_array_no_zero(scratch.arena, RDI_U64, voff_count);
|
||||
{
|
||||
RDI_U64 *voff_ptr = voffs;
|
||||
for(RDI_U32 i = 0; i < line_count; i += 1)
|
||||
@@ -2483,30 +2480,90 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
src_file_line_count = line_count;
|
||||
src_file_voffs = voffs;
|
||||
src_file_voff_count = voff_count;
|
||||
rdim_scratch_end(scratch);
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
//- rjf: produce data sections for this source file's line info tables
|
||||
////////////////////////
|
||||
//- rjf: grab & fill the next line map, if this file has one
|
||||
//
|
||||
if(src_file_line_count != 0)
|
||||
RDI_SourceLineMap *dst_map = 0;
|
||||
if(src_file->first_line_map_fragment != 0)
|
||||
{
|
||||
dst_file->line_map_count = src_file_line_count;
|
||||
dst_file->line_map_nums_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineMapNumbers, dst_file_idx); // TODO(rjf): @u64_to_u32
|
||||
dst_file->line_map_range_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineMapRanges, dst_file_idx); // TODO(rjf): @u64_to_u32
|
||||
dst_file->line_map_voff_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineMapVoffs, dst_file_idx); // TODO(rjf): @u64_to_u32
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, src_file_line_nums, sizeof(*src_file_line_nums)*src_file_line_count, RDI_DataSectionTag_LineMapNumbers, dst_file_idx);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, src_file_line_ranges, sizeof(*src_file_line_ranges)*(src_file_line_count + 1), RDI_DataSectionTag_LineMapRanges, dst_file_idx);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, src_file_voffs, sizeof(*src_file_voffs)*src_file_voff_count, RDI_DataSectionTag_LineMapVoffs, dst_file_idx);
|
||||
dst_map = &dst_maps[dst_map_idx];
|
||||
dst_map_idx += 1;
|
||||
dst_map->line_count = (RDI_U32)src_file_line_count; // TODO(rjf): @u64_to_u32
|
||||
dst_map->voff_count = (RDI_U32)src_file_voff_count; // TODO(rjf): @u64_to_u32
|
||||
dst_map->line_map_nums_base_idx = (RDI_U32)dst_nums_idx; // TODO(rjf): @u64_to_u32
|
||||
dst_map->line_map_range_base_idx = (RDI_U32)dst_rngs_idx; // TODO(rjf): @u64_to_u32
|
||||
dst_map->line_map_voff_base_idx = (RDI_U32)dst_voffs_idx; // TODO(rjf): @u64_to_u32
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//- rjf: gather line map data chunks for later collation & storage into their own top-level sections
|
||||
//
|
||||
{
|
||||
RDIM_DataNode *dst_num_node = rdim_push_array(scratch.arena, RDIM_DataNode, 1);
|
||||
RDIM_SLLQueuePush(first_dst_nums_node, last_dst_nums_node, dst_num_node);
|
||||
dst_num_node->data = src_file_line_nums;
|
||||
dst_num_node->size = sizeof(RDI_U32)*src_file_line_count;
|
||||
RDIM_DataNode *dst_rng_node = rdim_push_array(scratch.arena, RDIM_DataNode, 1);
|
||||
RDIM_SLLQueuePush(first_dst_rngs_node, last_dst_rngs_node, dst_rng_node);
|
||||
dst_rng_node->data = src_file_line_ranges;
|
||||
dst_rng_node->size = sizeof(RDI_U32)*(src_file_line_count+1);
|
||||
RDIM_DataNode *dst_voff_node = rdim_push_array(scratch.arena, RDIM_DataNode, 1);
|
||||
RDIM_SLLQueuePush(first_dst_voffs_node, last_dst_voffs_node, dst_voff_node);
|
||||
dst_voff_node->data = src_file_voffs;
|
||||
dst_voff_node->size = sizeof(RDI_U64)*(src_file_voff_count);
|
||||
dst_nums_idx += src_file_line_count;
|
||||
dst_rngs_idx += src_file_line_count+1;
|
||||
dst_voffs_idx+= src_file_voff_count;
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//- rjf: fill file info
|
||||
//
|
||||
dst_file->file_path_node_idx = rdim_bake_path_node_idx_from_string(path_tree, src_file->normal_full_path);
|
||||
dst_file->normal_full_path_string_idx = rdim_bake_idx_from_string(strings, src_file->normal_full_path);
|
||||
dst_file->source_line_map_idx = (RDI_U32)(dst_map ? (dst_map - dst_maps) : 0);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- rjf: build section for all source files
|
||||
//- rjf: coalesce source line map data blobs
|
||||
//
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, dst_files, sizeof(RDI_SourceFile)*dst_files_count, RDI_DataSectionTag_SourceFiles, 0);
|
||||
RDI_U32 *source_line_map_nums = rdim_push_array_no_zero(arena, RDI_U32, dst_nums_idx);
|
||||
RDI_U32 *source_line_map_rngs = rdim_push_array_no_zero(arena, RDI_U32, dst_rngs_idx);
|
||||
RDI_U64 *source_line_map_voffs= rdim_push_array_no_zero(arena, RDI_U64, dst_voffs_idx);
|
||||
{
|
||||
RDI_U64 num_idx = 0;
|
||||
RDI_U64 rng_idx = 0;
|
||||
RDI_U64 voff_idx= 0;
|
||||
for(RDIM_DataNode *num_n = first_dst_nums_node; num_n != 0; num_n = num_n->next)
|
||||
{
|
||||
rdim_memcpy(source_line_map_nums+num_idx, num_n->data, num_n->size);
|
||||
num_idx += num_n->size/sizeof(RDI_U32);
|
||||
}
|
||||
for(RDIM_DataNode *rng_n = first_dst_rngs_node; rng_n != 0; rng_n = rng_n->next)
|
||||
{
|
||||
rdim_memcpy(source_line_map_rngs+rng_idx, rng_n->data, rng_n->size);
|
||||
rng_idx += rng_n->size/sizeof(RDI_U32);
|
||||
}
|
||||
for(RDIM_DataNode *voff_n = first_dst_voffs_node; voff_n != 0; voff_n = voff_n->next)
|
||||
{
|
||||
rdim_memcpy(source_line_map_voffs+voff_idx, voff_n->data, voff_n->size);
|
||||
voff_idx += voff_n->size/sizeof(RDI_U64);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
//- 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_scratch_end(scratch);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@@ -2515,17 +2572,6 @@ rdim_bake_src_file_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMa
|
||||
RDI_PROC RDIM_BakeSectionList
|
||||
rdim_bake_line_table_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams *params)
|
||||
{
|
||||
//
|
||||
// TODO(rjf):
|
||||
// 1. section for all line tables
|
||||
// 2. section for all line info voff ranges
|
||||
// 3. section for all line info lines
|
||||
// 4. section for all line info columns
|
||||
//
|
||||
// the entire line info voffs/lines/columns tables are not sorted together; only sub-sections, belonging to
|
||||
// specific line tables, are sorted as one. so it is known up-front which line table maps to which index
|
||||
// range into the collated line info sections.
|
||||
//
|
||||
//- rjf: build all combined line info
|
||||
RDI_LineTable *dst_line_tables = push_array(arena, RDI_LineTable, params->line_tables.total_count+1);
|
||||
RDI_U64 *dst_line_voffs = push_array(arena, RDI_U64, params->line_tables.total_line_count + params->line_tables.total_seq_count);
|
||||
|
||||
@@ -484,6 +484,8 @@ struct RDIM_SrcFileChunkList
|
||||
RDIM_SrcFileChunkNode *last;
|
||||
RDI_U64 chunk_count;
|
||||
RDI_U64 total_count;
|
||||
RDI_U64 source_line_map_count;
|
||||
RDI_U64 total_line_count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
+44
-40
@@ -216,16 +216,55 @@ 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)
|
||||
{
|
||||
// extract line map data
|
||||
RDI_ParsedLineMap line_map = {0};
|
||||
rdi_line_map_from_source_file(parsed, source_file, &line_map);
|
||||
|
||||
// normal source path
|
||||
String8 path = {0};
|
||||
path.str = rdi_string_from_idx(parsed, source_file->normal_full_path_string_idx, &path.size);
|
||||
str8_list_pushf(arena, out, "%.*spath: \"%S\"\n", indent_level, rdi_stringize_spaces, path);
|
||||
|
||||
// stringize line map data
|
||||
// rjf: source line map idx
|
||||
str8_list_pushf(arena, out, "%.*ssource_line_map: %u\n", indent_level, rdi_stringize_spaces, source_file->source_line_map_idx);
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_line_table(Arena *arena, String8List *out, RDI_Parsed *parsed, 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);
|
||||
|
||||
// rjf: stringize lines
|
||||
str8_list_pushf(arena, out, "%.*slines:\n", indent_level, rdi_stringize_spaces);
|
||||
for(U32 i = 0; i < parsed_line_table.count; i += 1)
|
||||
{
|
||||
U64 first = parsed_line_table.voffs[i];
|
||||
U64 opl = parsed_line_table.voffs[i + 1];
|
||||
RDI_Line *line = parsed_line_table.lines + i;
|
||||
RDI_Column *col = 0;
|
||||
if(i < parsed_line_table.col_count)
|
||||
{
|
||||
col = parsed_line_table.cols + i;
|
||||
}
|
||||
if(col == 0)
|
||||
{
|
||||
str8_list_pushf(arena, out, "%.*s [0x%08llx,0x%08llx) file=%u; line=%u\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
first, opl, line->file_idx, line->line_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_pushf(arena, out, "%.*s [0x%08llx,0x%08llx) file=%u; line=%u; columns=[%u,%u)\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
first, opl, line->file_idx, line->line_num,
|
||||
col->col_first, col->col_opl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_source_line_map(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_SourceLineMap *map, U32 indent_level)
|
||||
{
|
||||
RDI_ParsedSourceLineMap line_map = {0};
|
||||
rdi_parsed_from_source_line_map(parsed, 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)
|
||||
@@ -267,41 +306,6 @@ 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)
|
||||
{
|
||||
// rjf: parse line table
|
||||
RDI_ParsedLineTable parsed_line_table = {0};
|
||||
rdi_parsed_from_line_table(parsed, line_table, &parsed_line_table);
|
||||
|
||||
// rjf: stringize lines
|
||||
str8_list_pushf(arena, out, "%.*slines:\n", indent_level, rdi_stringize_spaces);
|
||||
for(U32 i = 0; i < parsed_line_table.count; i += 1)
|
||||
{
|
||||
U64 first = parsed_line_table.voffs[i];
|
||||
U64 opl = parsed_line_table.voffs[i + 1];
|
||||
RDI_Line *line = parsed_line_table.lines + i;
|
||||
RDI_Column *col = 0;
|
||||
if(i < parsed_line_table.col_count)
|
||||
{
|
||||
col = parsed_line_table.cols + i;
|
||||
}
|
||||
if(col == 0)
|
||||
{
|
||||
str8_list_pushf(arena, out, "%.*s [0x%08llx,0x%08llx) file=%u; line=%u\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
first, opl, line->file_idx, line->line_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_pushf(arena, out, "%.*s [0x%08llx,0x%08llx) file=%u; line=%u; columns=[%u,%u)\n",
|
||||
indent_level, rdi_stringize_spaces,
|
||||
first, opl, line->file_idx, line->line_num,
|
||||
col->col_first, col->col_opl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
rdi_stringize_unit(Arena *arena, String8List *out, RDI_Parsed *parsed, RDI_Unit *unit, U32 indent_level)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ internal void rdi_stringize_binary_section(Arena *arena, String8List *out, RDI_P
|
||||
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);
|
||||
|
||||
@@ -54,18 +54,19 @@ entry_point(CmdLine *cmd_line)
|
||||
DumpFlag_FilePaths = (1<<3),
|
||||
DumpFlag_SourceFiles = (1<<4),
|
||||
DumpFlag_LineTables = (1<<5),
|
||||
DumpFlag_Units = (1<<6),
|
||||
DumpFlag_UnitVMap = (1<<7),
|
||||
DumpFlag_TypeNodes = (1<<8),
|
||||
DumpFlag_UDTs = (1<<9),
|
||||
DumpFlag_GlobalVariables = (1<<10),
|
||||
DumpFlag_GlobalVMap = (1<<11),
|
||||
DumpFlag_ThreadVariables = (1<<12),
|
||||
DumpFlag_Procedures = (1<<13),
|
||||
DumpFlag_Scopes = (1<<14),
|
||||
DumpFlag_ScopeVMap = (1<<15),
|
||||
DumpFlag_NameMaps = (1<<16),
|
||||
DumpFlag_Strings = (1<<17),
|
||||
DumpFlag_SourceLineMaps = (1<<6),
|
||||
DumpFlag_Units = (1<<7),
|
||||
DumpFlag_UnitVMap = (1<<8),
|
||||
DumpFlag_TypeNodes = (1<<9),
|
||||
DumpFlag_UDTs = (1<<10),
|
||||
DumpFlag_GlobalVariables = (1<<11),
|
||||
DumpFlag_GlobalVMap = (1<<12),
|
||||
DumpFlag_ThreadVariables = (1<<13),
|
||||
DumpFlag_Procedures = (1<<14),
|
||||
DumpFlag_Scopes = (1<<15),
|
||||
DumpFlag_ScopeVMap = (1<<16),
|
||||
DumpFlag_NameMaps = (1<<17),
|
||||
DumpFlag_Strings = (1<<18),
|
||||
};
|
||||
String8 input_name = {0};
|
||||
DumpFlags dump_flags = (U32)0xffffffff;
|
||||
@@ -88,6 +89,7 @@ entry_point(CmdLine *cmd_line)
|
||||
else if(str8_match(n->string, str8_lit("file_paths"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_FilePaths; }
|
||||
else if(str8_match(n->string, str8_lit("source_files"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_SourceFiles; }
|
||||
else if(str8_match(n->string, str8_lit("line_tables"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_LineTables; }
|
||||
else if(str8_match(n->string, str8_lit("source_line_maps"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_SourceLineMaps; }
|
||||
else if(str8_match(n->string, str8_lit("units"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_Units; }
|
||||
else if(str8_match(n->string, str8_lit("unit_vmap"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_UnitVMap; }
|
||||
else if(str8_match(n->string, str8_lit("type_nodes"), StringMatchFlag_CaseInsensitive)) { dump_flags |= DumpFlag_TypeNodes; }
|
||||
@@ -185,7 +187,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " section[%u]:\n", i);
|
||||
rdi_stringize_binary_section(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -219,7 +220,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " source_file[%u]:\n", i);
|
||||
rdi_stringize_source_file(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -233,7 +233,19 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " line_table[%u]:\n", i);
|
||||
rdi_stringize_line_table(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
|
||||
//- rjf: SOURCE LINE MAPS
|
||||
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)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " source_line_map[%u]:\n", i);
|
||||
rdi_stringize_source_line_map(arena, &dump, rdi, ptr, 2);
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -247,7 +259,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " unit[%u]:\n", i);
|
||||
rdi_stringize_unit(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -273,7 +284,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " type[%u]:\n", i);
|
||||
rdi_stringize_type_node(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -294,7 +304,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " udt[%u]:\n", i);
|
||||
rdi_stringize_udt(arena, &dump, rdi, &member_bundle, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -308,7 +317,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " global_variable[%u]:\n", i);
|
||||
rdi_stringize_global_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -334,7 +342,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " thread_variable[%u]:\n", i);
|
||||
rdi_stringize_thread_variable(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -348,7 +355,6 @@ entry_point(CmdLine *cmd_line)
|
||||
{
|
||||
str8_list_pushf(arena, &dump, " procedure[%u]:\n", i);
|
||||
rdi_stringize_procedure(arena, &dump, rdi, ptr, 2);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
@@ -376,7 +382,6 @@ entry_point(CmdLine *cmd_line)
|
||||
if(ptr->parent_scope_idx == 0)
|
||||
{
|
||||
rdi_stringize_scope(arena, &dump, rdi, &scope_bundle, ptr, 1);
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
}
|
||||
}
|
||||
str8_list_push(arena, &dump, str8_lit("\n"));
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"";
|
||||
"// \"raddbg\0\0\"";
|
||||
"#define RDI_MAGIC_CONSTANT 0x0000676264646172";
|
||||
"#define RDI_ENCODING_VERSION 2";
|
||||
"#define RDI_ENCODING_VERSION 3";
|
||||
"";
|
||||
"////////////////////////////////////////////////////////////////";
|
||||
"//~ Format Types & Functions";
|
||||
@@ -113,43 +113,44 @@ RDI_HeaderMemberTable:
|
||||
@table(name value desc)
|
||||
RDI_DataSectionTable:
|
||||
{
|
||||
{NULL 0x0000 ""}
|
||||
{TopLevelInfo 0x0001 ""}
|
||||
{StringData 0x0002 ""}
|
||||
{StringTable 0x0003 ""}
|
||||
{IndexRuns 0x0004 ""}
|
||||
{BinarySections 0x0005 ""}
|
||||
{FilePathNodes 0x0006 ""}
|
||||
{SourceFiles 0x0007 ""}
|
||||
{LineTables 0x0008 ""}
|
||||
{LineInfoVoffs 0x0009 ""}
|
||||
{LineInfoLines 0x000A ""}
|
||||
{LineInfoColumns 0x000B ""}
|
||||
{Units 0x000C ""}
|
||||
{UnitVmap 0x000D ""}
|
||||
{TypeNodes 0x000E ""}
|
||||
{UDTs 0x000F ""}
|
||||
{Members 0x0010 ""}
|
||||
{EnumMembers 0x0011 ""}
|
||||
{GlobalVariables 0x0012 ""}
|
||||
{GlobalVmap 0x0013 ""}
|
||||
{ThreadVariables 0x0014 ""}
|
||||
{Procedures 0x0015 ""}
|
||||
{Scopes 0x0016 ""}
|
||||
{ScopeVoffData 0x0017 ""}
|
||||
{ScopeVmap 0x0018 ""}
|
||||
{InlineSites 0x0019 ""}
|
||||
{Locals 0x001A ""}
|
||||
{LocationBlocks 0x001B ""}
|
||||
{LocationData 0x001C ""}
|
||||
{NameMaps 0x001D ""}
|
||||
{PRIMARY_COUNT 0x001E ""}
|
||||
{SECONDARY 0x80000000 ""}
|
||||
{LineMapNumbers `RDI_DataSectionTag_SECONDARY|0x0001` ""}
|
||||
{LineMapRanges `RDI_DataSectionTag_SECONDARY|0x0002` ""}
|
||||
{LineMapVoffs `RDI_DataSectionTag_SECONDARY|0x0003` ""}
|
||||
{NameMapBuckets `RDI_DataSectionTag_SECONDARY|0x0004` ""}
|
||||
{NameMapNodes `RDI_DataSectionTag_SECONDARY|0x0005` ""}
|
||||
{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` ""}
|
||||
}
|
||||
|
||||
@table(name value)
|
||||
@@ -486,10 +487,7 @@ RDI_SourceFileMemberTable:
|
||||
// (line_map_nums * line_number) -> (nil | index)
|
||||
// (line_map_data * index) -> (range)
|
||||
// (line_map_voff_data * range) -> (array(voff))
|
||||
{line_map_count RDI_U32 ""}
|
||||
{line_map_nums_data_idx RDI_U32 ""} // U32[line_map_count] (sorted - not closed ranges)
|
||||
{line_map_range_data_idx RDI_U32 ""} // U32[line_map_count + 1] (pairs form ranges)
|
||||
{line_map_voff_data_idx RDI_U32 ""} // U64[...] (idx by line_map_range_data)
|
||||
{source_line_map_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
@xlist RDI_FilePathNode_XList:
|
||||
@@ -568,6 +566,20 @@ RDI_ColumnMemberTable:
|
||||
{col_opl RDI_U16 ""}
|
||||
}
|
||||
|
||||
@table(name type desc)
|
||||
RDI_SourceLineMapMemberTable:
|
||||
{
|
||||
// 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))
|
||||
{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:
|
||||
{
|
||||
@expand(RDI_LineTableMemberTable a) `$(a.type), $(a.name)`
|
||||
@@ -583,6 +595,11 @@ RDI_ColumnMemberTable:
|
||||
@expand(RDI_ColumnMemberTable a) `$(a.type), $(a.name)`
|
||||
}
|
||||
|
||||
@xlist RDI_SourceLineMapMemberTable:
|
||||
{
|
||||
@expand(RDI_SourceLineMapMemberTable a) `$(a.type), $(a.name)`
|
||||
}
|
||||
|
||||
@struct RDI_LineTable:
|
||||
{
|
||||
@expand(RDI_LineTableMemberTable a) `$(a.type) $(a.name)`
|
||||
@@ -598,6 +615,11 @@ RDI_ColumnMemberTable:
|
||||
@expand(RDI_ColumnMemberTable a) `$(a.type) $(a.name)`
|
||||
}
|
||||
|
||||
@struct RDI_SourceLineMap:
|
||||
{
|
||||
@expand(RDI_SourceLineMapMemberTable a) `$(a.type) $(a.name)`
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Language Info Tables
|
||||
|
||||
|
||||
Reference in New Issue
Block a user