diff --git a/src/dasm_cache/dasm_cache.c b/src/dasm_cache/dasm_cache.c index 85963a80..ae248831 100644 --- a/src/dasm_cache/dasm_cache.c +++ b/src/dasm_cache/dasm_cache.c @@ -463,7 +463,7 @@ dasm_parse_thread__entry_point(void *p) 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, 0); + 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]; diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index a2221427..cf59414c 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -3278,7 +3278,7 @@ df_text_line_src2dasm_info_list_array_from_src_line_range(Arena *arena, DF_Entit 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, 0); + U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, base_voff); if(unit_line_info.voffs != 0) { Rng1U64 range = r1u64(base_voff, unit_line_info.voffs[line_info_idx+1]); @@ -3322,7 +3322,7 @@ df_text_line_dasm2src_info_from_dbgi_key_voff(DI_Key *dbgi_key, U64 voff) 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, 0); + 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]; @@ -3957,7 +3957,7 @@ df_eval_parse_ctx_from_src_loc(DI_Scope *scope, DF_Entity *file, TxtPt pt) 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, 0); + U64 line_info_idx = rdi_line_info_idx_from_voff(&unit_line_info, base_voff); Rng1U64 range = r1u64(base_voff, unit_line_info.voffs[line_info_idx+1]); S64 actual_line = (S64)unit_line_info.lines[line_info_idx].line_num; DF_TextLineSrc2DasmInfoNode *src2dasm_n = push_array(scratch.arena, DF_TextLineSrc2DasmInfoNode, 1); diff --git a/src/lib_rdi_format/rdi_format_parse.c b/src/lib_rdi_format/rdi_format_parse.c index 85af6af7..e89df1e9 100644 --- a/src/lib_rdi_format/rdi_format_parse.c +++ b/src/lib_rdi_format/rdi_format_parse.c @@ -231,9 +231,10 @@ rdi_parsed_from_line_table(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_Parse } RDI_PROC RDI_U64 -rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff, RDI_U64 depth) +rdi_line_info_idx_range_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff, RDI_U64 *n_out) { RDI_U64 result = 0; + RDI_U64 n = 0; if(line_info->count > 0 && line_info->voffs[0] <= voff && voff < line_info->voffs[line_info->count - 1]) { //- rjf: find i such that: (vmap[i].voff <= voff) && (voff < vmap[i + 1].voff) @@ -276,12 +277,12 @@ rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff, RDI_U6 } } - //- rjf: scan rightward, to match depth parameter - for(U64 idx = 0; idx < depth && result+1 < line_info->count; idx += 1) + //- rjf: scan rightward, to count # of line info with this voff + for(U64 idx = result; idx < line_info->count; idx += 1) { - if(line_info->voffs[result+1] == voff) + if(line_info->voffs[idx] == voff) { - result += 1; + n += 1; } else { @@ -289,6 +290,18 @@ rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff, RDI_U6 } } } + if(n_out) + { + *n_out = n; + } + return result; +} + +RDI_PROC RDI_U64 +rdi_line_info_idx_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff) +{ + RDI_U64 count = 0; + RDI_U64 result = rdi_line_info_idx_range_from_voff(line_info, voff, &count); return result; } @@ -641,20 +654,20 @@ rdi_line_table_from_unit(RDI_Parsed *rdi, RDI_Unit *unit) //- line info RDI_PROC RDI_Line -rdi_line_from_voff(RDI_Parsed *rdi, RDI_U64 voff, RDI_U64 depth) +rdi_line_from_voff(RDI_Parsed *rdi, RDI_U64 voff) { RDI_Unit *unit = rdi_unit_from_voff(rdi, voff); RDI_LineTable *line_table = rdi_line_table_from_unit(rdi, unit); - RDI_Line line = rdi_line_from_line_table_voff(rdi, line_table, voff, depth); + RDI_Line line = rdi_line_from_line_table_voff(rdi, line_table, voff); return line; } RDI_PROC RDI_Line -rdi_line_from_line_table_voff(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_U64 voff, RDI_U64 depth) +rdi_line_from_line_table_voff(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_U64 voff) { RDI_ParsedLineTable parsed = {0}; rdi_parsed_from_line_table(rdi, line_table, &parsed); - RDI_U64 line_info_idx = rdi_line_info_idx_from_voff(&parsed, voff, depth); + RDI_U64 line_info_idx = rdi_line_info_idx_from_voff(&parsed, voff); RDI_Line result = {0}; if(line_info_idx < parsed.count) { diff --git a/src/lib_rdi_format/rdi_format_parse.h b/src/lib_rdi_format/rdi_format_parse.h index 82ccdbe7..66a20cdc 100644 --- a/src/lib_rdi_format/rdi_format_parse.h +++ b/src/lib_rdi_format/rdi_format_parse.h @@ -159,7 +159,8 @@ RDI_PROC RDI_U32 *rdi_idx_run_from_first_count(RDI_Parsed *rdi, RDI_U32 raw_firs //- line info 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_U64 depth); +RDI_PROC RDI_U64 rdi_line_info_idx_range_from_voff(RDI_ParsedLineTable *line_info, RDI_U64 voff, RDI_U64 *n_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 *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); @@ -195,8 +196,8 @@ RDI_PROC RDI_Unit *rdi_unit_from_voff(RDI_Parsed *rdi, RDI_U64 voff); RDI_PROC RDI_LineTable *rdi_line_table_from_unit(RDI_Parsed *rdi, RDI_Unit *unit); //- line tables -RDI_PROC RDI_Line rdi_line_from_voff(RDI_Parsed *rdi, RDI_U64 voff, RDI_U64 depth); -RDI_PROC RDI_Line rdi_line_from_line_table_voff(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_U64 voff, RDI_U64 depth); +RDI_PROC RDI_Line rdi_line_from_voff(RDI_Parsed *rdi, RDI_U64 voff); +RDI_PROC RDI_Line rdi_line_from_line_table_voff(RDI_Parsed *rdi, RDI_LineTable *line_table, RDI_U64 voff); RDI_PROC RDI_SourceFile *rdi_source_file_from_line(RDI_Parsed *rdi, RDI_Line *line); //- source files