mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-17 09:32:22 -07:00
eliminate old per-unit line info code
This commit is contained in:
@@ -2249,281 +2249,6 @@ rdim_bake_unit_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTig
|
||||
return sections;
|
||||
}
|
||||
|
||||
#if 0 // TODO(rjf): @inline_sites
|
||||
|
||||
RDI_PROC RDIM_BakeSectionList
|
||||
rdim_bake_section_list_from_unit(RDIM_Arena *arena, RDIM_Unit *unit)
|
||||
{
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
|
||||
////////////////////////
|
||||
//- rjf: produce combined unit line info
|
||||
//
|
||||
RDI_U64 *unit_voffs = 0;
|
||||
RDI_Line *unit_lines = 0;
|
||||
RDI_U16 *unit_cols = 0;
|
||||
RDI_U32 unit_line_count = 0;
|
||||
RDIM_ProfScope("produce combined unit line info")
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: gather up all line info into two arrays:
|
||||
//
|
||||
// [1] keys: sortable array; pairs voffs with line info records; null records are sequence enders
|
||||
// [2] recs: contains all the source coordinates for a range of voffs
|
||||
//
|
||||
typedef struct RDIM_LineRec RDIM_LineRec;
|
||||
struct RDIM_LineRec
|
||||
{
|
||||
RDI_U32 file_id;
|
||||
RDI_U32 line_num;
|
||||
RDI_U16 col_first;
|
||||
RDI_U16 col_opl;
|
||||
};
|
||||
RDI_U64 line_count = 0;
|
||||
RDI_U64 seq_count = 0;
|
||||
for(RDIM_LineSequenceNode *seq_n = unit->line_sequences.first; seq_n != 0; seq_n = seq_n->next)
|
||||
{
|
||||
seq_count += 1;
|
||||
line_count += seq_n->v.line_count;
|
||||
}
|
||||
RDI_U64 key_count = line_count + seq_count;
|
||||
RDIM_SortKey *line_keys = rdim_push_array_no_zero(scratch.arena, RDIM_SortKey, key_count);
|
||||
RDIM_LineRec *line_recs = rdim_push_array_no_zero(scratch.arena, RDIM_LineRec, line_count);
|
||||
{
|
||||
RDIM_SortKey *key_ptr = line_keys;
|
||||
RDIM_LineRec *rec_ptr = line_recs;
|
||||
for(RDIM_LineSequenceNode *seq_n = unit->line_sequences.first; seq_n != 0; seq_n = seq_n->next)
|
||||
{
|
||||
RDIM_LineSequence *seq = &seq_n->v;
|
||||
for(RDI_U64 line_idx = 0; line_idx < seq->line_count; line_idx += 1)
|
||||
{
|
||||
key_ptr->key = seq->voffs[line_idx];
|
||||
key_ptr->val = rec_ptr;
|
||||
key_ptr += 1;
|
||||
rec_ptr->file_id = (RDI_U32)rdim_idx_from_src_file(seq->src_file); // TODO(rjf): @u64_to_u32
|
||||
rec_ptr->line_num = seq->line_nums[line_idx];
|
||||
if(seq->col_nums != 0)
|
||||
{
|
||||
rec_ptr->col_first = seq->col_nums[line_idx*2];
|
||||
rec_ptr->col_opl = seq->col_nums[line_idx*2 + 1];
|
||||
}
|
||||
rec_ptr += 1;
|
||||
}
|
||||
key_ptr->key = seq->voffs[seq->line_count];
|
||||
key_ptr->val = 0;
|
||||
key_ptr += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: sort
|
||||
RDIM_SortKey *sorted_line_keys = 0;
|
||||
RDIM_ProfScope("sort")
|
||||
{
|
||||
sorted_line_keys = rdim_sort_key_array(scratch.arena, line_keys, key_count);
|
||||
}
|
||||
|
||||
// TODO(rjf): do a pass over sorted keys to make sure duplicate keys
|
||||
// are sorted with null record first, and no more than one null
|
||||
// record and one non-null record
|
||||
|
||||
//- rjf: arrange output
|
||||
RDI_U64 *arranged_voffs = rdim_push_array_no_zero(arena, RDI_U64, key_count + 1);
|
||||
RDI_Line *arranged_lines = rdim_push_array_no_zero(arena, RDI_Line, key_count);
|
||||
RDIM_ProfScope("arrange output")
|
||||
{
|
||||
for(RDI_U64 i = 0; i < key_count; i += 1)
|
||||
{
|
||||
arranged_voffs[i] = sorted_line_keys[i].key;
|
||||
}
|
||||
arranged_voffs[key_count] = ~0ull;
|
||||
for(RDI_U64 i = 0; i < key_count; i += 1)
|
||||
{
|
||||
RDIM_LineRec *rec = (RDIM_LineRec*)sorted_line_keys[i].val;
|
||||
if(rec != 0)
|
||||
{
|
||||
arranged_lines[i].file_idx = rec->file_id;
|
||||
arranged_lines[i].line_num = rec->line_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
arranged_lines[i].file_idx = 0;
|
||||
arranged_lines[i].line_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: fill output
|
||||
unit_voffs = arranged_voffs;
|
||||
unit_lines = arranged_lines;
|
||||
unit_cols = 0;
|
||||
unit_line_count = key_count;
|
||||
rdim_scratch_end(scratch);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//- rjf: build line info sections
|
||||
//
|
||||
U64 unit_idx = rdim_idx_from_unit(unit);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_voffs, sizeof(RDI_U64)*(unit_line_count+1), RDI_DataSectionTag_LineInfoVoffs, unit_idx);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_lines, sizeof(RDI_Line)*unit_line_count, RDI_DataSectionTag_LineInfoData, unit_idx);
|
||||
if(unit_cols != 0)
|
||||
{
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_cols, sizeof(RDI_Column)*unit_line_count, RDI_DataSectionTag_LineInfoColumns, unit_idx);
|
||||
}
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
RDI_PROC RDIM_BakeSectionList
|
||||
rdim_bake_unit_top_level_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree, RDIM_BakeParams *params)
|
||||
{
|
||||
RDIM_BakeSectionList sections = {0};
|
||||
RDI_Unit *dst_base = rdim_push_array(arena, RDI_Unit, params->units.total_count+1);
|
||||
RDI_U64 dst_idx = 1;
|
||||
for(RDIM_UnitChunkNode *src_n = params->units.first; src_n != 0; src_n = src_n->next)
|
||||
{
|
||||
for(RDI_U64 src_chunk_idx = 0; src_chunk_idx < src_n->count; src_chunk_idx += 1, dst_idx += 1)
|
||||
{
|
||||
RDIM_Unit *src = &src_n->v[src_chunk_idx];
|
||||
RDI_Unit *dst = &dst_base[dst_idx];
|
||||
|
||||
////////////////////////
|
||||
//- rjf: produce combined unit line info
|
||||
//
|
||||
RDI_U64 *unit_voffs = 0;
|
||||
RDI_Line *unit_lines = 0;
|
||||
RDI_U16 *unit_cols = 0;
|
||||
RDI_U32 unit_line_count = 0;
|
||||
RDIM_ProfScope("produce combined unit line info")
|
||||
{
|
||||
RDIM_Temp scratch = rdim_scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: gather up all line info into two arrays:
|
||||
//
|
||||
// [1] keys: sortable array; pairs voffs with line info records; null records are sequence enders
|
||||
// [2] recs: contains all the source coordinates for a range of voffs
|
||||
//
|
||||
typedef struct RDIM_LineRec RDIM_LineRec;
|
||||
struct RDIM_LineRec
|
||||
{
|
||||
RDI_U32 file_id;
|
||||
RDI_U32 line_num;
|
||||
RDI_U16 col_first;
|
||||
RDI_U16 col_opl;
|
||||
};
|
||||
RDI_U64 line_count = 0;
|
||||
RDI_U64 seq_count = 0;
|
||||
for(RDIM_LineSequenceNode *seq_n = src->line_sequences.first; seq_n != 0; seq_n = seq_n->next)
|
||||
{
|
||||
seq_count += 1;
|
||||
line_count += seq_n->v.line_count;
|
||||
}
|
||||
RDI_U64 key_count = line_count + seq_count;
|
||||
RDIM_SortKey *line_keys = rdim_push_array_no_zero(scratch.arena, RDIM_SortKey, key_count);
|
||||
RDIM_LineRec *line_recs = rdim_push_array_no_zero(scratch.arena, RDIM_LineRec, line_count);
|
||||
{
|
||||
RDIM_SortKey *key_ptr = line_keys;
|
||||
RDIM_LineRec *rec_ptr = line_recs;
|
||||
for(RDIM_LineSequenceNode *seq_n = src->line_sequences.first; seq_n != 0; seq_n = seq_n->next)
|
||||
{
|
||||
RDIM_LineSequence *seq = &seq_n->v;
|
||||
for(RDI_U64 line_idx = 0; line_idx < seq->line_count; line_idx += 1)
|
||||
{
|
||||
key_ptr->key = seq->voffs[line_idx];
|
||||
key_ptr->val = rec_ptr;
|
||||
key_ptr += 1;
|
||||
rec_ptr->file_id = (RDI_U32)rdim_idx_from_src_file(seq->src_file); // TODO(rjf): @u64_to_u32
|
||||
rec_ptr->line_num = seq->line_nums[line_idx];
|
||||
if(seq->col_nums != 0)
|
||||
{
|
||||
rec_ptr->col_first = seq->col_nums[line_idx*2];
|
||||
rec_ptr->col_opl = seq->col_nums[line_idx*2 + 1];
|
||||
}
|
||||
rec_ptr += 1;
|
||||
}
|
||||
key_ptr->key = seq->voffs[seq->line_count];
|
||||
key_ptr->val = 0;
|
||||
key_ptr += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: sort
|
||||
RDIM_SortKey *sorted_line_keys = 0;
|
||||
RDIM_ProfScope("sort")
|
||||
{
|
||||
sorted_line_keys = rdim_sort_key_array(scratch.arena, line_keys, key_count);
|
||||
}
|
||||
|
||||
// TODO(rjf): do a pass over sorted keys to make sure duplicate keys
|
||||
// are sorted with null record first, and no more than one null
|
||||
// record and one non-null record
|
||||
|
||||
//- rjf: arrange output
|
||||
RDI_U64 *arranged_voffs = rdim_push_array_no_zero(arena, RDI_U64, key_count + 1);
|
||||
RDI_Line *arranged_lines = rdim_push_array_no_zero(arena, RDI_Line, key_count);
|
||||
RDIM_ProfScope("arrange output")
|
||||
{
|
||||
for(RDI_U64 i = 0; i < key_count; i += 1)
|
||||
{
|
||||
arranged_voffs[i] = sorted_line_keys[i].key;
|
||||
}
|
||||
arranged_voffs[key_count] = ~0ull;
|
||||
for(RDI_U64 i = 0; i < key_count; i += 1)
|
||||
{
|
||||
RDIM_LineRec *rec = (RDIM_LineRec*)sorted_line_keys[i].val;
|
||||
if(rec != 0)
|
||||
{
|
||||
arranged_lines[i].file_idx = rec->file_id;
|
||||
arranged_lines[i].line_num = rec->line_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
arranged_lines[i].file_idx = 0;
|
||||
arranged_lines[i].line_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: fill output
|
||||
unit_voffs = arranged_voffs;
|
||||
unit_lines = arranged_lines;
|
||||
unit_cols = 0;
|
||||
unit_line_count = key_count;
|
||||
rdim_scratch_end(scratch);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//- rjf: build line info sections
|
||||
//
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_voffs, sizeof(RDI_U64)*(unit_line_count+1), RDI_DataSectionTag_LineInfoVoffs, dst_idx);
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_lines, sizeof(RDI_Line)*unit_line_count, RDI_DataSectionTag_LineInfoData, dst_idx);
|
||||
if(unit_cols != 0)
|
||||
{
|
||||
rdim_bake_section_list_push_new_unpacked(arena, §ions, unit_cols, sizeof(RDI_Column)*unit_line_count, RDI_DataSectionTag_LineInfoColumns, dst_idx);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//- rjf: fill output
|
||||
//
|
||||
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);
|
||||
dst->build_path_node = rdim_bake_path_node_idx_from_string(path_tree, src->build_path);
|
||||
dst->language = src->language;
|
||||
dst->line_info_voffs_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineInfoVoffs, dst_idx); // TODO(rjf): @u64_to_u32
|
||||
dst->line_info_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineInfoData, dst_idx); // TODO(rjf): @u64_to_u32
|
||||
dst->line_info_col_data_idx = (RDI_U32)rdim_bake_section_idx_from_params_tag_idx(params, RDI_DataSectionTag_LineInfoColumns, dst_idx); // 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);
|
||||
return sections;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//- rjf: unit vmap
|
||||
|
||||
RDI_PROC RDIM_BakeSectionList
|
||||
|
||||
@@ -1274,10 +1274,6 @@ RDI_PROC RDIM_BakeSectionList rdim_bake_binary_section_section_list_from_params(
|
||||
|
||||
//- rjf: units
|
||||
RDI_PROC RDIM_BakeSectionList rdim_bake_unit_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree, RDIM_BakeParams *params);
|
||||
#if 0 // TODO(rjf): @inline_sites
|
||||
RDI_PROC RDIM_BakeSectionList rdim_bake_section_list_from_unit(RDIM_Arena *arena, RDIM_Unit *unit);
|
||||
RDI_PROC RDIM_BakeSectionList rdim_bake_unit_top_level_section_list_from_params(RDIM_Arena *arena, RDIM_BakeStringMapTight *strings, RDIM_BakePathTree *path_tree, RDIM_BakeParams *params);
|
||||
#endif
|
||||
|
||||
//- rjf: unit vmap
|
||||
RDI_PROC RDIM_BakeSectionList rdim_bake_unit_vmap_section_list_from_params(RDIM_Arena *arena, RDIM_BakeParams *params);
|
||||
|
||||
@@ -528,16 +528,6 @@ RDI_UnitMemberTable:
|
||||
{line_table_idx RDI_U32 ""}
|
||||
}
|
||||
|
||||
/* // TODO(rjf): @inline_sites
|
||||
// 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))
|
||||
{line_info_voffs_data_idx RDI_U32 ""} // U64[line_info_count + 1] (sorted ranges)
|
||||
{line_info_data_idx RDI_U32 ""} // RDI_Line[line_info_count]
|
||||
{line_info_col_data_idx RDI_U32 ""} // RDI_Col[line_info_count]
|
||||
{line_info_count RDI_U32 ""}
|
||||
*/
|
||||
|
||||
@xlist RDI_Unit_XList:
|
||||
{
|
||||
@expand(RDI_UnitMemberTable a) `$(a.type), $(a.name)`
|
||||
@@ -554,6 +544,9 @@ RDI_UnitMemberTable:
|
||||
@table(name type desc)
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user