aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-10-04 19:22:52 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-10-05 00:19:25 -0400
commitb4427bc300cd768721891e6747e59102c8cb06fc (patch)
tree6224f3695774579ca783e92f0c49b8f4b54f334d /src/arch
parent5a35734a48fddec7fa58a10be01b045c49099145 (diff)
downloadzig-b4427bc300cd768721891e6747e59102c8cb06fc.tar.gz
zig-b4427bc300cd768721891e6747e59102c8cb06fc.zip
plan9: refactor debug info
The main goal is to stop depending on `emit.lower.target`.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/aarch64/Emit.zig22
-rw-r--r--src/arch/arm/Emit.zig22
-rw-r--r--src/arch/riscv64/Emit.zig22
-rw-r--r--src/arch/x86_64/Emit.zig22
4 files changed, 40 insertions, 48 deletions
diff --git a/src/arch/aarch64/Emit.zig b/src/arch/aarch64/Emit.zig
index 68c28ed8aa..9ba722f393 100644
--- a/src/arch/aarch64/Emit.zig
+++ b/src/arch/aarch64/Emit.zig
@@ -445,25 +445,23 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {
},
.plan9 => |dbg_out| {
if (delta_pc <= 0) return; // only do this when the pc changes
- // we have already checked the target in the linker to make sure it is compatable
- const quant = @import("../../link/Plan9/aout.zig").getPCQuant(self.target.cpu.arch) catch unreachable;
// increasing the line number
- try @import("../../link/Plan9.zig").changeLine(dbg_out.dbg_line, delta_line);
+ try link.File.Plan9.changeLine(&dbg_out.dbg_line, delta_line);
// increasing the pc
- const d_pc_p9 = @as(i64, @intCast(delta_pc)) - quant;
+ const d_pc_p9 = @as(i64, @intCast(delta_pc)) - dbg_out.pc_quanta;
if (d_pc_p9 > 0) {
- // minus one because if its the last one, we want to leave space to change the line which is one quanta
- try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, quant) + 128)) - quant);
- if (dbg_out.pcop_change_index.*) |pci|
+ // minus one because if its the last one, we want to leave space to change the line which is one pc quanta
+ try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, dbg_out.pc_quanta) + 128)) - dbg_out.pc_quanta);
+ if (dbg_out.pcop_change_index) |pci|
dbg_out.dbg_line.items[pci] += 1;
- dbg_out.pcop_change_index.* = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
+ dbg_out.pcop_change_index = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
} else if (d_pc_p9 == 0) {
- // we don't need to do anything, because adding the quant does it for us
+ // we don't need to do anything, because adding the pc quanta does it for us
} else unreachable;
- if (dbg_out.start_line.* == null)
- dbg_out.start_line.* = self.prev_di_line;
- dbg_out.end_line.* = line;
+ if (dbg_out.start_line == null)
+ dbg_out.start_line = self.prev_di_line;
+ dbg_out.end_line = line;
// only do this if the pc changed
self.prev_di_line = line;
self.prev_di_column = column;
diff --git a/src/arch/arm/Emit.zig b/src/arch/arm/Emit.zig
index 54062d00a7..45c3392918 100644
--- a/src/arch/arm/Emit.zig
+++ b/src/arch/arm/Emit.zig
@@ -362,25 +362,23 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {
},
.plan9 => |dbg_out| {
if (delta_pc <= 0) return; // only do this when the pc changes
- // we have already checked the target in the linker to make sure it is compatable
- const quant = @import("../../link/Plan9/aout.zig").getPCQuant(self.target.cpu.arch) catch unreachable;
// increasing the line number
- try @import("../../link/Plan9.zig").changeLine(dbg_out.dbg_line, delta_line);
+ try link.File.Plan9.changeLine(&dbg_out.dbg_line, delta_line);
// increasing the pc
- const d_pc_p9 = @as(i64, @intCast(delta_pc)) - quant;
+ const d_pc_p9 = @as(i64, @intCast(delta_pc)) - dbg_out.pc_quanta;
if (d_pc_p9 > 0) {
- // minus one because if its the last one, we want to leave space to change the line which is one quanta
- try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, quant) + 128)) - quant);
- if (dbg_out.pcop_change_index.*) |pci|
+ // minus one because if its the last one, we want to leave space to change the line which is one pc quanta
+ try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, dbg_out.pc_quanta) + 128)) - dbg_out.pc_quanta);
+ if (dbg_out.pcop_change_index) |pci|
dbg_out.dbg_line.items[pci] += 1;
- dbg_out.pcop_change_index.* = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
+ dbg_out.pcop_change_index = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
} else if (d_pc_p9 == 0) {
- // we don't need to do anything, because adding the quant does it for us
+ // we don't need to do anything, because adding the pc quanta does it for us
} else unreachable;
- if (dbg_out.start_line.* == null)
- dbg_out.start_line.* = self.prev_di_line;
- dbg_out.end_line.* = line;
+ if (dbg_out.start_line == null)
+ dbg_out.start_line = self.prev_di_line;
+ dbg_out.end_line = line;
// only do this if the pc changed
self.prev_di_line = line;
self.prev_di_column = column;
diff --git a/src/arch/riscv64/Emit.zig b/src/arch/riscv64/Emit.zig
index 20f2c40ba4..9d82cc38cc 100644
--- a/src/arch/riscv64/Emit.zig
+++ b/src/arch/riscv64/Emit.zig
@@ -96,25 +96,23 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void {
},
.plan9 => |dbg_out| {
if (delta_pc <= 0) return; // only do this when the pc changes
- // we have already checked the target in the linker to make sure it is compatable
- const quant = @import("../../link/Plan9/aout.zig").getPCQuant(self.target.cpu.arch) catch unreachable;
// increasing the line number
- try @import("../../link/Plan9.zig").changeLine(dbg_out.dbg_line, delta_line);
+ try link.File.Plan9.changeLine(&dbg_out.dbg_line, delta_line);
// increasing the pc
- const d_pc_p9 = @as(i64, @intCast(delta_pc)) - quant;
+ const d_pc_p9 = @as(i64, @intCast(delta_pc)) - dbg_out.pc_quanta;
if (d_pc_p9 > 0) {
- // minus one because if its the last one, we want to leave space to change the line which is one quanta
- try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, quant) + 128)) - quant);
- if (dbg_out.pcop_change_index.*) |pci|
+ // minus one because if its the last one, we want to leave space to change the line which is one pc quanta
+ try dbg_out.dbg_line.append(@as(u8, @intCast(@divExact(d_pc_p9, dbg_out.pc_quanta) + 128)) - dbg_out.pc_quanta);
+ if (dbg_out.pcop_change_index) |pci|
dbg_out.dbg_line.items[pci] += 1;
- dbg_out.pcop_change_index.* = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
+ dbg_out.pcop_change_index = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
} else if (d_pc_p9 == 0) {
- // we don't need to do anything, because adding the quant does it for us
+ // we don't need to do anything, because adding the pc quanta does it for us
} else unreachable;
- if (dbg_out.start_line.* == null)
- dbg_out.start_line.* = self.prev_di_line;
- dbg_out.end_line.* = line;
+ if (dbg_out.start_line == null)
+ dbg_out.start_line = self.prev_di_line;
+ dbg_out.end_line = line;
// only do this if the pc changed
self.prev_di_line = line;
self.prev_di_column = column;
diff --git a/src/arch/x86_64/Emit.zig b/src/arch/x86_64/Emit.zig
index f17eda57eb..d2a199da42 100644
--- a/src/arch/x86_64/Emit.zig
+++ b/src/arch/x86_64/Emit.zig
@@ -242,16 +242,14 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) Error!void {
},
.plan9 => |dbg_out| {
if (delta_pc <= 0) return; // only do this when the pc changes
- // we have already checked the target in the linker to make sure it is compatable
- const quant = @import("../../link/Plan9/aout.zig").getPCQuant(emit.lower.target.cpu.arch) catch unreachable;
// increasing the line number
- try @import("../../link/Plan9.zig").changeLine(dbg_out.dbg_line, delta_line);
+ try link.File.Plan9.changeLine(&dbg_out.dbg_line, delta_line);
// increasing the pc
- const d_pc_p9 = @as(i64, @intCast(delta_pc)) - quant;
+ const d_pc_p9 = @as(i64, @intCast(delta_pc)) - dbg_out.pc_quanta;
if (d_pc_p9 > 0) {
- // minus one because if its the last one, we want to leave space to change the line which is one quanta
- var diff = @divExact(d_pc_p9, quant) - quant;
+ // minus one because if its the last one, we want to leave space to change the line which is one pc quanta
+ var diff = @divExact(d_pc_p9, dbg_out.pc_quanta) - dbg_out.pc_quanta;
while (diff > 0) {
if (diff < 64) {
try dbg_out.dbg_line.append(@as(u8, @intCast(diff + 128)));
@@ -261,15 +259,15 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) Error!void {
diff -= 64;
}
}
- if (dbg_out.pcop_change_index.*) |pci|
+ if (dbg_out.pcop_change_index) |pci|
dbg_out.dbg_line.items[pci] += 1;
- dbg_out.pcop_change_index.* = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
+ dbg_out.pcop_change_index = @as(u32, @intCast(dbg_out.dbg_line.items.len - 1));
} else if (d_pc_p9 == 0) {
- // we don't need to do anything, because adding the quant does it for us
+ // we don't need to do anything, because adding the pc quanta does it for us
} else unreachable;
- if (dbg_out.start_line.* == null)
- dbg_out.start_line.* = emit.prev_di_line;
- dbg_out.end_line.* = line;
+ if (dbg_out.start_line == null)
+ dbg_out.start_line = emit.prev_di_line;
+ dbg_out.end_line = line;
// only do this if the pc changed
emit.prev_di_line = line;
emit.prev_di_column = column;