Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/dwarf/dwarf_parse_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
//- rjf: gather directories
DW2_LineTableFileList dir_list = {0};
{
// rjf: push compile directory as first list element, always
// rjf: push compile directory as first list element, if available
if(ctx->unit_dir.size != 0)
{
DW2_LineTableFileNode *n = push_array(scratch.arena, DW2_LineTableFileNode, 1);
SLLQueuePush(dir_list.first, dir_list.last, n);
Expand Down Expand Up @@ -750,7 +751,8 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
//- rjf: gather files
DW2_LineTableFileList file_list = {0};
{
// rjf: push main compilation unit file as first list element, always
// rjf: push main compilation unit file as first list element, if available
if(ctx->unit_file.size != 0)
{
DW2_LineTableFileNode *n = push_array(scratch.arena, DW2_LineTableFileNode, 1);
SLLQueuePush(file_list.first, file_list.last, n);
Expand Down
27 changes: 23 additions & 4 deletions src/rdi_from_dwarf/rdi_from_dwarf_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,10 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
//- rjf: set up vm registers
DW2_LineVMRegs vm_regs = {0};
{
vm_regs.file_index = 1;
vm_regs.file_index = (line_table_header->version < DW_Version_5 ? 1 : 0);
vm_regs.line = 1;
vm_regs.is_stmt = line_table_header->default_is_stmt;
}
}

//- rjf: run the line opcode program
B32 emit_line = 0;
Expand Down Expand Up @@ -1035,9 +1035,28 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)

//- rjf: map file index -> rdim src file
RDIM_SrcFile *src_file = 0;
if(vm_regs.file_index < line_table_header->files.count)
{
src_file = unit_src_file_maps[unit_idx].v[vm_regs.file_index];
B32 valid_file = 0;
U64 file_array_idx = vm_regs.file_index;
if(line_table_header->version < DW_Version_5)
{
if(vm_regs.file_index >= 1 && vm_regs.file_index <= line_table_header->files.count)
{
valid_file = 1;
file_array_idx = vm_regs.file_index - 1;
}
}
else
{
if(vm_regs.file_index < line_table_header->files.count)
{
valid_file = 1;
}
}
if(valid_file)
{
src_file = unit_src_file_maps[unit_idx].v[file_array_idx];
}
}

//- rjf: sequence ended explicitly, or file change, or end of stream? -> push to line table
Expand Down