| author | |
| committer | |
| log | 12e34e70377882363dbedf2a7afdc8737a7435c5 |
| tree | c3e01b1a26a83062425af5fabaef8c0fc92092cf |
| parent | 97827d6d38ecd078fbbcff3d71a7e104341695cd |
7 files changed, 56 insertions(+), 97 deletions(-)
src/arch/aarch64/Emit.zig+3-17| ... | ... | @@ -10,8 +10,6 @@ const link = @import("../../link.zig"); |
| 10 | 10 | const Module = @import("../../Module.zig"); |
| 11 | 11 | const ErrorMsg = Module.ErrorMsg; |
| 12 | 12 | const assert = std.debug.assert; |
| 13 | const DW = std.dwarf; | |
| 14 | const leb128 = std.leb; | |
| 15 | 13 | const Instruction = bits.Instruction; |
| 16 | 14 | const Register = bits.Register; |
| 17 | 15 | const log = std.log.scoped(.aarch64_emit); |
| ... | ... | @@ -440,19 +438,7 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void { |
| 440 | 438 | const delta_pc: usize = self.code.items.len - self.prev_di_pc; |
| 441 | 439 | switch (self.debug_output) { |
| 442 | 440 | .dwarf => |dw| { |
| 443 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 444 | // It lets you emit single-byte opcodes that add different numbers to | |
| 445 | // both the PC and the line number at the same time. | |
| 446 | const dbg_line = &dw.dbg_line; | |
| 447 | try dbg_line.ensureUnusedCapacity(11); | |
| 448 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 449 | leb128.writeULEB128(dbg_line.writer(), delta_pc) catch unreachable; | |
| 450 | if (delta_line != 0) { | |
| 451 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 452 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 453 | } | |
| 454 | dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 455 | self.prev_di_pc = self.code.items.len; | |
| 441 | try dw.advancePCAndLine(delta_line, delta_pc); | |
| 456 | 442 | self.prev_di_line = line; |
| 457 | 443 | self.prev_di_column = column; |
| 458 | 444 | self.prev_di_pc = self.code.items.len; |
| ... | ... | @@ -652,7 +638,7 @@ fn mirDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 652 | 638 | fn mirDebugPrologueEnd(self: *Emit) !void { |
| 653 | 639 | switch (self.debug_output) { |
| 654 | 640 | .dwarf => |dw| { |
| 655 | try dw.dbg_line.append(DW.LNS.set_prologue_end); | |
| 641 | try dw.setPrologueEnd(); | |
| 656 | 642 | try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column); |
| 657 | 643 | }, |
| 658 | 644 | .plan9 => {}, |
| ... | ... | @@ -663,7 +649,7 @@ fn mirDebugPrologueEnd(self: *Emit) !void { |
| 663 | 649 | fn mirDebugEpilogueBegin(self: *Emit) !void { |
| 664 | 650 | switch (self.debug_output) { |
| 665 | 651 | .dwarf => |dw| { |
| 666 | try dw.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 652 | try dw.setEpilogueBegin(); | |
| 667 | 653 | try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column); |
| 668 | 654 | }, |
| 669 | 655 | .plan9 => {}, |
src/arch/arm/Emit.zig+3-17| ... | ... | @@ -13,8 +13,6 @@ const Type = @import("../../type.zig").Type; |
| 13 | 13 | const ErrorMsg = Module.ErrorMsg; |
| 14 | 14 | const Target = std.Target; |
| 15 | 15 | const assert = std.debug.assert; |
| 16 | const DW = std.dwarf; | |
| 17 | const leb128 = std.leb; | |
| 18 | 16 | const Instruction = bits.Instruction; |
| 19 | 17 | const Register = bits.Register; |
| 20 | 18 | const log = std.log.scoped(.aarch64_emit); |
| ... | ... | @@ -356,19 +354,7 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void { |
| 356 | 354 | const delta_pc: usize = self.code.items.len - self.prev_di_pc; |
| 357 | 355 | switch (self.debug_output) { |
| 358 | 356 | .dwarf => |dw| { |
| 359 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 360 | // It lets you emit single-byte opcodes that add different numbers to | |
| 361 | // both the PC and the line number at the same time. | |
| 362 | const dbg_line = &dw.dbg_line; | |
| 363 | try dbg_line.ensureUnusedCapacity(11); | |
| 364 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 365 | leb128.writeULEB128(dbg_line.writer(), delta_pc) catch unreachable; | |
| 366 | if (delta_line != 0) { | |
| 367 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 368 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 369 | } | |
| 370 | dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 371 | self.prev_di_pc = self.code.items.len; | |
| 357 | try dw.advancePCAndLine(delta_line, delta_pc); | |
| 372 | 358 | self.prev_di_line = line; |
| 373 | 359 | self.prev_di_column = column; |
| 374 | 360 | self.prev_di_pc = self.code.items.len; |
| ... | ... | @@ -543,7 +529,7 @@ fn mirDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 543 | 529 | fn mirDebugPrologueEnd(emit: *Emit) !void { |
| 544 | 530 | switch (emit.debug_output) { |
| 545 | 531 | .dwarf => |dw| { |
| 546 | try dw.dbg_line.append(DW.LNS.set_prologue_end); | |
| 532 | try dw.setPrologueEnd(); | |
| 547 | 533 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 548 | 534 | }, |
| 549 | 535 | .plan9 => {}, |
| ... | ... | @@ -554,7 +540,7 @@ fn mirDebugPrologueEnd(emit: *Emit) !void { |
| 554 | 540 | fn mirDebugEpilogueBegin(emit: *Emit) !void { |
| 555 | 541 | switch (emit.debug_output) { |
| 556 | 542 | .dwarf => |dw| { |
| 557 | try dw.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 543 | try dw.setEpilogueBegin(); | |
| 558 | 544 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 559 | 545 | }, |
| 560 | 546 | .plan9 => {}, |
src/arch/riscv64/Emit.zig+3-17| ... | ... | @@ -10,8 +10,6 @@ const link = @import("../../link.zig"); |
| 10 | 10 | const Module = @import("../../Module.zig"); |
| 11 | 11 | const ErrorMsg = Module.ErrorMsg; |
| 12 | 12 | const assert = std.debug.assert; |
| 13 | const DW = std.dwarf; | |
| 14 | const leb128 = std.leb; | |
| 15 | 13 | const Instruction = bits.Instruction; |
| 16 | 14 | const Register = bits.Register; |
| 17 | 15 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; |
| ... | ... | @@ -90,19 +88,7 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void { |
| 90 | 88 | const delta_pc: usize = self.code.items.len - self.prev_di_pc; |
| 91 | 89 | switch (self.debug_output) { |
| 92 | 90 | .dwarf => |dw| { |
| 93 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 94 | // It lets you emit single-byte opcodes that add different numbers to | |
| 95 | // both the PC and the line number at the same time. | |
| 96 | const dbg_line = &dw.dbg_line; | |
| 97 | try dbg_line.ensureUnusedCapacity(11); | |
| 98 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 99 | leb128.writeULEB128(dbg_line.writer(), delta_pc) catch unreachable; | |
| 100 | if (delta_line != 0) { | |
| 101 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 102 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 103 | } | |
| 104 | dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 105 | self.prev_di_pc = self.code.items.len; | |
| 91 | try dw.advancePCAndLine(delta_line, delta_pc); | |
| 106 | 92 | self.prev_di_line = line; |
| 107 | 93 | self.prev_di_column = column; |
| 108 | 94 | self.prev_di_pc = self.code.items.len; |
| ... | ... | @@ -184,7 +170,7 @@ fn mirDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 184 | 170 | fn mirDebugPrologueEnd(self: *Emit) !void { |
| 185 | 171 | switch (self.debug_output) { |
| 186 | 172 | .dwarf => |dw| { |
| 187 | try dw.dbg_line.append(DW.LNS.set_prologue_end); | |
| 173 | try dw.setPrologueEnd(); | |
| 188 | 174 | try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column); |
| 189 | 175 | }, |
| 190 | 176 | .plan9 => {}, |
| ... | ... | @@ -195,7 +181,7 @@ fn mirDebugPrologueEnd(self: *Emit) !void { |
| 195 | 181 | fn mirDebugEpilogueBegin(self: *Emit) !void { |
| 196 | 182 | switch (self.debug_output) { |
| 197 | 183 | .dwarf => |dw| { |
| 198 | try dw.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 184 | try dw.setEpilogueBegin(); | |
| 199 | 185 | try self.dbgAdvancePCAndLine(self.prev_di_line, self.prev_di_column); |
| 200 | 186 | }, |
| 201 | 187 | .plan9 => {}, |
src/arch/sparc64/Emit.zig+3-16| ... | ... | @@ -10,8 +10,6 @@ const ErrorMsg = Module.ErrorMsg; |
| 10 | 10 | const Liveness = @import("../../Liveness.zig"); |
| 11 | 11 | const log = std.log.scoped(.sparcv9_emit); |
| 12 | 12 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; |
| 13 | const DW = std.dwarf; | |
| 14 | const leb128 = std.leb; | |
| 15 | 13 | |
| 16 | 14 | const Emit = @This(); |
| 17 | 15 | const Mir = @import("Mir.zig"); |
| ... | ... | @@ -168,7 +166,7 @@ fn mirDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 168 | 166 | fn mirDebugPrologueEnd(emit: *Emit) !void { |
| 169 | 167 | switch (emit.debug_output) { |
| 170 | 168 | .dwarf => |dbg_out| { |
| 171 | try dbg_out.dbg_line.append(DW.LNS.set_prologue_end); | |
| 169 | try dbg_out.setPrologueEnd(); | |
| 172 | 170 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 173 | 171 | }, |
| 174 | 172 | .plan9 => {}, |
| ... | ... | @@ -179,7 +177,7 @@ fn mirDebugPrologueEnd(emit: *Emit) !void { |
| 179 | 177 | fn mirDebugEpilogueBegin(emit: *Emit) !void { |
| 180 | 178 | switch (emit.debug_output) { |
| 181 | 179 | .dwarf => |dbg_out| { |
| 182 | try dbg_out.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 180 | try dbg_out.setEpilogueBegin(); | |
| 183 | 181 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 184 | 182 | }, |
| 185 | 183 | .plan9 => {}, |
| ... | ... | @@ -468,18 +466,7 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void { |
| 468 | 466 | const delta_pc: usize = emit.code.items.len - emit.prev_di_pc; |
| 469 | 467 | switch (emit.debug_output) { |
| 470 | 468 | .dwarf => |dbg_out| { |
| 471 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 472 | // It lets you emit single-byte opcodes that add different numbers to | |
| 473 | // both the PC and the line number at the same time. | |
| 474 | try dbg_out.dbg_line.ensureUnusedCapacity(11); | |
| 475 | dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 476 | leb128.writeULEB128(dbg_out.dbg_line.writer(), delta_pc) catch unreachable; | |
| 477 | if (delta_line != 0) { | |
| 478 | dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 479 | leb128.writeILEB128(dbg_out.dbg_line.writer(), delta_line) catch unreachable; | |
| 480 | } | |
| 481 | dbg_out.dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 482 | emit.prev_di_pc = emit.code.items.len; | |
| 469 | try dbg_out.advancePCAndLine(delta_line, delta_pc); | |
| 483 | 470 | emit.prev_di_line = line; |
| 484 | 471 | emit.prev_di_column = column; |
| 485 | 472 | emit.prev_di_pc = emit.code.items.len; |
src/arch/wasm/Emit.zig+6-12| ... | ... | @@ -444,18 +444,12 @@ fn emitDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void { |
| 444 | 444 | fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void { |
| 445 | 445 | if (emit.dbg_output != .dwarf) return; |
| 446 | 446 | |
| 447 | const dbg_line = &emit.dbg_output.dwarf.dbg_line; | |
| 448 | try dbg_line.ensureUnusedCapacity(11); | |
| 449 | dbg_line.appendAssumeCapacity(std.dwarf.LNS.advance_pc); | |
| 447 | const delta_line = @intCast(i32, line) - @intCast(i32, emit.prev_di_line); | |
| 448 | const delta_pc = emit.offset() - emit.prev_di_offset; | |
| 450 | 449 | // TODO: This must emit a relocation to calculate the offset relative |
| 451 | 450 | // to the code section start. |
| 452 | leb128.writeULEB128(dbg_line.writer(), emit.offset() - emit.prev_di_offset) catch unreachable; | |
| 453 | const delta_line = @intCast(i32, line) - @intCast(i32, emit.prev_di_line); | |
| 454 | if (delta_line != 0) { | |
| 455 | dbg_line.appendAssumeCapacity(std.dwarf.LNS.advance_line); | |
| 456 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 457 | } | |
| 458 | dbg_line.appendAssumeCapacity(std.dwarf.LNS.copy); | |
| 451 | try emit.dbg_output.dwarf.advancePCAndLine(delta_line, delta_pc); | |
| 452 | ||
| 459 | 453 | emit.prev_di_line = line; |
| 460 | 454 | emit.prev_di_column = column; |
| 461 | 455 | emit.prev_di_offset = emit.offset(); |
| ... | ... | @@ -464,13 +458,13 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) !void { |
| 464 | 458 | fn emitDbgPrologueEnd(emit: *Emit) !void { |
| 465 | 459 | if (emit.dbg_output != .dwarf) return; |
| 466 | 460 | |
| 467 | try emit.dbg_output.dwarf.dbg_line.append(std.dwarf.LNS.set_prologue_end); | |
| 461 | try emit.dbg_output.dwarf.setPrologueEnd(); | |
| 468 | 462 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 469 | 463 | } |
| 470 | 464 | |
| 471 | 465 | fn emitDbgEpilogueBegin(emit: *Emit) !void { |
| 472 | 466 | if (emit.dbg_output != .dwarf) return; |
| 473 | 467 | |
| 474 | try emit.dbg_output.dwarf.dbg_line.append(std.dwarf.LNS.set_epilogue_begin); | |
| 468 | try emit.dbg_output.dwarf.setEpilogueBegin(); | |
| 475 | 469 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 476 | 470 | } |
src/arch/x86_64/Emit.zig+11-18| ... | ... | @@ -7,7 +7,6 @@ const std = @import("std"); |
| 7 | 7 | const assert = std.debug.assert; |
| 8 | 8 | const bits = @import("bits.zig"); |
| 9 | 9 | const abi = @import("abi.zig"); |
| 10 | const leb128 = std.leb; | |
| 11 | 10 | const link = @import("../../link.zig"); |
| 12 | 11 | const log = std.log.scoped(.codegen); |
| 13 | 12 | const math = std.math; |
| ... | ... | @@ -18,7 +17,6 @@ const Air = @import("../../Air.zig"); |
| 18 | 17 | const Allocator = mem.Allocator; |
| 19 | 18 | const CodeGen = @import("CodeGen.zig"); |
| 20 | 19 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; |
| 21 | const DW = std.dwarf; | |
| 22 | 20 | const Encoder = bits.Encoder; |
| 23 | 21 | const ErrorMsg = Module.ErrorMsg; |
| 24 | 22 | const MCValue = @import("CodeGen.zig").MCValue; |
| ... | ... | @@ -1184,18 +1182,7 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void { |
| 1184 | 1182 | log.debug(" (advance pc={d} and line={d})", .{ delta_line, delta_pc }); |
| 1185 | 1183 | switch (emit.debug_output) { |
| 1186 | 1184 | .dwarf => |dw| { |
| 1187 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 1188 | // It lets you emit single-byte opcodes that add different numbers to | |
| 1189 | // both the PC and the line number at the same time. | |
| 1190 | const dbg_line = &dw.dbg_line; | |
| 1191 | try dbg_line.ensureUnusedCapacity(11); | |
| 1192 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 1193 | leb128.writeULEB128(dbg_line.writer(), delta_pc) catch unreachable; | |
| 1194 | if (delta_line != 0) { | |
| 1195 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 1196 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 1197 | } | |
| 1198 | dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 1185 | try dw.advancePCAndLine(delta_line, delta_pc); | |
| 1199 | 1186 | emit.prev_di_line = line; |
| 1200 | 1187 | emit.prev_di_column = column; |
| 1201 | 1188 | emit.prev_di_pc = emit.code.items.len; |
| ... | ... | @@ -1244,8 +1231,11 @@ fn mirDbgPrologueEnd(emit: *Emit, inst: Mir.Inst.Index) InnerError!void { |
| 1244 | 1231 | assert(tag == .dbg_prologue_end); |
| 1245 | 1232 | switch (emit.debug_output) { |
| 1246 | 1233 | .dwarf => |dw| { |
| 1247 | try dw.dbg_line.append(DW.LNS.set_prologue_end); | |
| 1248 | log.debug("mirDbgPrologueEnd (line={d}, col={d})", .{ emit.prev_di_line, emit.prev_di_column }); | |
| 1234 | try dw.setPrologueEnd(); | |
| 1235 | log.debug("mirDbgPrologueEnd (line={d}, col={d})", .{ | |
| 1236 | emit.prev_di_line, | |
| 1237 | emit.prev_di_column, | |
| 1238 | }); | |
| 1249 | 1239 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 1250 | 1240 | }, |
| 1251 | 1241 | .plan9 => {}, |
| ... | ... | @@ -1258,8 +1248,11 @@ fn mirDbgEpilogueBegin(emit: *Emit, inst: Mir.Inst.Index) InnerError!void { |
| 1258 | 1248 | assert(tag == .dbg_epilogue_begin); |
| 1259 | 1249 | switch (emit.debug_output) { |
| 1260 | 1250 | .dwarf => |dw| { |
| 1261 | try dw.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 1262 | log.debug("mirDbgEpilogueBegin (line={d}, col={d})", .{ emit.prev_di_line, emit.prev_di_column }); | |
| 1251 | try dw.setEpilogueBegin(); | |
| 1252 | log.debug("mirDbgEpilogueBegin (line={d}, col={d})", .{ | |
| 1253 | emit.prev_di_line, | |
| 1254 | emit.prev_di_column, | |
| 1255 | }); | |
| 1263 | 1256 | try emit.dbgAdvancePCAndLine(emit.prev_di_line, emit.prev_di_column); |
| 1264 | 1257 | }, |
| 1265 | 1258 | .plan9 => {}, |
src/link/Dwarf.zig+27| ... | ... | @@ -778,6 +778,33 @@ pub const DeclState = struct { |
| 778 | 778 | try self.addTypeRelocGlobal(atom, child_ty, @intCast(u32, index)); |
| 779 | 779 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string |
| 780 | 780 | } |
| 781 | ||
| 782 | pub fn advancePCAndLine( | |
| 783 | self: *DeclState, | |
| 784 | delta_line: i32, | |
| 785 | delta_pc: usize, | |
| 786 | ) error{OutOfMemory}!void { | |
| 787 | // TODO Look into using the DWARF special opcodes to compress this data. | |
| 788 | // It lets you emit single-byte opcodes that add different numbers to | |
| 789 | // both the PC and the line number at the same time. | |
| 790 | const dbg_line = &self.dbg_line; | |
| 791 | try dbg_line.ensureUnusedCapacity(11); | |
| 792 | dbg_line.appendAssumeCapacity(DW.LNS.advance_pc); | |
| 793 | leb128.writeULEB128(dbg_line.writer(), delta_pc) catch unreachable; | |
| 794 | if (delta_line != 0) { | |
| 795 | dbg_line.appendAssumeCapacity(DW.LNS.advance_line); | |
| 796 | leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable; | |
| 797 | } | |
| 798 | dbg_line.appendAssumeCapacity(DW.LNS.copy); | |
| 799 | } | |
| 800 | ||
| 801 | pub fn setPrologueEnd(self: *DeclState) error{OutOfMemory}!void { | |
| 802 | try self.dbg_line.append(DW.LNS.set_prologue_end); | |
| 803 | } | |
| 804 | ||
| 805 | pub fn setEpilogueBegin(self: *DeclState) error{OutOfMemory}!void { | |
| 806 | try self.dbg_line.append(DW.LNS.set_epilogue_begin); | |
| 807 | } | |
| 781 | 808 | }; |
| 782 | 809 | |
| 783 | 810 | pub const AbbrevEntry = struct { |