fix wonky line table indent

This commit is contained in:
Nikita Smith
2026-02-19 18:11:12 -08:00
parent e7cf2513b7
commit a9d3757dbc
+52 -27
View File
@@ -946,45 +946,59 @@ DW_PRINTER(dw_print_line)
DW_LineVM *vm = dw_line_vm_init(input, &cu_arr[unit_idx]);
// rjf: begin logging line table
dw_printf("line_table: // line_table[%I64u]\n{\n", unit_idx);
dw_printf("line_table: // line_table[%I64u]\n", unit_idx);
dw_printf("{\n");
dw_indent();
{
// rjf: log line table header
DeferLoop(dw_printf(" header:\n {\n"), dw_printf(" }\n\n"))
dw_printf("header:\n");
dw_printf("{\n");
dw_indent();
{
String8List opcode_length_strings = numeric_str8_list_from_data(unit_temp.arena, 16, str8(vm->header.opcode_lens, vm->header.num_opcode_lens), 1);
String8 opcode_lengths_string = str8_list_join(arena, &opcode_length_strings, &(StringJoin){.sep = str8_lit(", ")});
dw_printf(" version: %u\n", vm->header.version );
dw_printf(" line_table_size: %I64u\n", vm->header.unit_length );
dw_printf(" address_size: %u\n", vm->header.address_size );
dw_printf(" segment_selector_size: %u\n", vm->header.segment_selector_size);
dw_printf(" header_length: %I64u\n", vm->header.header_length );
dw_printf(" min_instruction_length: %u\n", vm->header.min_inst_len );
dw_printf(" max_ops_for_instruction: %u\n", vm->header.max_ops_for_inst );
dw_printf(" default_is_stmt: %u\n", vm->header.default_is_stmt );
dw_printf(" line_base: %d\n", vm->header.line_base );
dw_printf(" line_range: %u\n", vm->header.line_range );
dw_printf(" opcode_base: %u\n", vm->header.opcode_base );
dw_printf(" opcode_lengths: %S\n", opcode_lengths_string );
dw_printf("version: %u\n", vm->header.version );
dw_printf("line_table_size: %I64u\n", vm->header.unit_length );
dw_printf("address_size: %u\n", vm->header.address_size );
dw_printf("segment_selector_size: %u\n", vm->header.segment_selector_size);
dw_printf("header_length: %I64u\n", vm->header.header_length );
dw_printf("min_instruction_length: %u\n", vm->header.min_inst_len );
dw_printf("max_ops_for_instruction: %u\n", vm->header.max_ops_for_inst );
dw_printf("default_is_stmt: %u\n", vm->header.default_is_stmt );
dw_printf("line_base: %d\n", vm->header.line_base );
dw_printf("line_range: %u\n", vm->header.line_range );
dw_printf("opcode_base: %u\n", vm->header.opcode_base );
dw_printf("opcode_lengths: { %S }\n", opcode_lengths_string );
}
dw_unindent();
dw_printf("}\n");
// rjf: log directory table
DeferLoop(dw_printf(" directory_table:\n {\n"), dw_printf(" }\n\n"))
dw_printf("directory_table:\n");
dw_printf("{\n");
dw_indent();
{
dw_printf(" // %-4s %-8s\n", "no.", "name");
dw_printf("// %-4s %-30s\n", "no.", "name");
dw_printf("// ---- ------------------------------\n");
for EachIndex(dir_idx, vm->header.dir_table.count)
{
dw_printf(" { %-4I64u %S }\n", dir_idx, vm->header.dir_table.v[dir_idx]);
dw_printf("{ %-4I64u %S }\n", dir_idx, vm->header.dir_table.v[dir_idx]);
}
}
dw_unindent();
dw_printf("}\n\n");
// rjf: log file table
DeferLoop(dw_printf(" file_table:\n {\n"), dw_printf(" }\n\n"))
dw_printf("file_table:\n");
dw_printf("{\n");
dw_indent();
{
dw_printf(" // %-4s %-8s %-8s %-33s %-8s %-8s\n", "no.", "dir_idx", "time", "md5", "size", "name");
dw_printf("// %-4s %-8s %-8s %-33s %-8s %-20s\n", "no.", "dir_idx", "time", "md5", "size", "name");
dw_printf("// ---- -------- -------- --------------------------------- -------- --------------------\n");
for EachIndex(file_idx, vm->header.file_table.count)
{
DW_LineFile *file = &vm->header.file_table.v[file_idx];
dw_printf(" { %-4I64u %-8I64u %-8I64u %016I64x-%016I64x %-8I64u %S }\n",
dw_printf("{ %-4I64u %-8I64u %-8I64u %016I64x-%016I64x %-8I64u %S }\n",
file_idx,
file->dir_idx,
file->modify_time,
@@ -994,13 +1008,17 @@ DW_PRINTER(dw_print_line)
file->file_name);
}
}
dw_unindent();
dw_printf("}\n");
// rjf: log opcodes
DeferLoop(dw_printf(" line_table:\n {\n"), dw_printf(" }\n\n"))
dw_printf("line_table:\n");
dw_printf("{\n");
dw_indent();
{
dw_printf(" //\n");
dw_printf(" // %-16s %-8s %-4s %-5s %-3s %-7s %-16s\n", "Address", "Line", "Col", "File", "ISA", "Discrim", "Flags");
dw_printf(" // ---------------- -------- ---- ----- --- ------- ----------------\n");
dw_printf("//\n");
dw_printf("// %-16s %-8s %-4s %-5s %-3s %-7s %-16s\n", "Address", "Line", "Col", "File", "ISA", "Discrim", "Flags");
dw_printf("// ---------------- -------- ---- ----- --- ------- ----------------\n");
for(;;)
{
@@ -1096,7 +1114,7 @@ DW_PRINTER(dw_print_line)
if(is_verbose)
{
String8 string = str8_list_join(opcode_temp.arena, &opcode_fmt, &(StringJoin){.sep=str8_lit(" ")});
dw_printf(" // %S\n", string);
dw_printf("// %S\n", string);
}
if(vm->new_line) {
@@ -1111,7 +1129,7 @@ DW_PRINTER(dw_print_line)
}
String8 flags = str8_list_join(opcode_temp.arena, &l, &(StringJoin){.sep = str8_lit("|")});
dw_printf(" { %#016I64x %8I64u %4I64u %5I64u %3I64u %7I64u %-16S } %s\n", vm->state.address, vm->state.line, vm->state.column, vm->state.file_index, vm->state.isa, vm->state.discriminator, flags, vm->new_seq ? "// new seq" : "");
dw_printf("{ %#016I64x %8I64u %4I64u %5I64u %3I64u %7I64u %-16S } %s\n", vm->state.address, vm->state.line, vm->state.column, vm->state.file_index, vm->state.isa, vm->state.discriminator, flags, vm->new_seq ? "// new seq" : "");
}
temp_end(opcode_temp);
@@ -1122,8 +1140,14 @@ DW_PRINTER(dw_print_line)
dw_printf("ERROR: Line VM failed stepping @ 0x%I64x\n", vm->cursor);
}
}
dw_unindent();
dw_printf("}\n");
temp_end(unit_temp);
}
dw_unindent();
dw_printf("}\n");
}
scratch_end(scratch);
}
@@ -2141,6 +2165,7 @@ read_only struct {
{ dw_print_info, DW_Section_Info },
{ dw_print_strings, DW_Section_Str },
{ dw_print_frame, DW_Section_Frame },
{ dw_print_line, DW_Section_Line },
};
internal String8List