d2r2: fix scope voff miscount; pattern match trivial value-register locations -> simple kind; fix pre-dwarf5 file table parsing

This commit is contained in:
Ryan Fleury
2026-04-30 18:09:30 -07:00
parent 0e2b37ba32
commit 0054935252
2 changed files with 25 additions and 2 deletions
+6
View File
@@ -722,6 +722,12 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
// rjf: gather additional files
for(;off < off_opl;)
{
U8 next_byte = 0;
str8_deserial_read_struct(data, off, &next_byte);
if(next_byte == 0)
{
break;
}
String8 file_name = {0};
U64 dir_idx = 0;
U64 modify_time = 0;
+19 -2
View File
@@ -249,7 +249,7 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
U64 voff_first = (base_addr - base_vaddr);
U64 voff_opl = voff_first + range_size;
RDIM_Rng1U64 range = {voff_first, voff_opl};
rdim_rng1u64_chunk_list_push(scratch.arena, &voff_ranges, 256, range);
rdim_rng1u64_chunk_list_push(arena, &voff_ranges, 256, range);
}
if(off == start_off)
{
@@ -3568,6 +3568,22 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
}
}
// rjf: match val registers
if(loc.kind == RDI_LocationKind_ValBytecodeStream &&
beginning_ops[0] == RDI_EvalOp_RegRead &&
beginning_ops[1] == RDI_EvalOp_Stop)
{
U8 rdi_reg_code = (beginning_nodes[0]->p&0x0000FF)>>0;
U8 byte_size = (beginning_nodes[0]->p&0x00FF00)>>8;
U8 byte_off = (beginning_nodes[0]->p&0xFF0000)>>16;
if(byte_size == unit_parse_ctx->addr_size &&
byte_off == 0)
{
loc.kind = RDI_LocationKind_ValReg;
loc.reg_code = rdi_reg_code;
}
}
// rjf: match simple register offsets
if(loc.kind == RDI_LocationKind_AddrBytecodeStream &&
beginning_ops[0] == RDI_EvalOp_RegRead &&
@@ -3681,7 +3697,7 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
procedure->location_cases = framebase_location_cases;
root_scope->symbol = procedure;
root_scope->voff_ranges = ranges;
dst_unit->scopes.scope_voff_count += 2;
dst_unit->scopes.scope_voff_count += 2*ranges.count;
new_scope_open = root_scope;
}break;
@@ -3725,6 +3741,7 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
{
RDIM_Scope *scope = rdim_scope_chunk_list_push(arena, &dst_unit->scopes, chunk_count);
scope->voff_ranges = ranges;
dst_unit->scopes.scope_voff_count += 2*ranges.count;
new_scope_open = scope;
}break;
}