Skip to content

Commit

Permalink
Merge pull request #10525 from g-w1/plan9-zig-test
Browse files Browse the repository at this point in the history
Plan9 zig test
  • Loading branch information
kubkon authored Jan 9, 2022
2 parents 2a39d80 + 398c0b1 commit d66c97d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/arch/x86_64/Isel.zig
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,16 @@ fn dbgAdvancePCAndLine(isel: *Isel, line: u32, column: u32) InnerError!void {
const d_pc_p9 = @intCast(i64, delta_pc) - quant;
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(@intCast(u8, @divExact(d_pc_p9, quant) + 128) - quant);
var diff = @divExact(d_pc_p9, quant) - quant;
while (diff > 0) {
if (diff < 64) {
try dbg_out.dbg_line.append(@intCast(u8, diff + 128));
diff = 0;
} else {
try dbg_out.dbg_line.append(@intCast(u8, 64 + 128));
diff -= 64;
}
}
if (dbg_out.pcop_change_index.*) |pci|
dbg_out.dbg_line.items[pci] += 1;
dbg_out.pcop_change_index.* = @intCast(u32, dbg_out.dbg_line.items.len - 1);
Expand Down
2 changes: 1 addition & 1 deletion src/link.zig
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ pub const File = struct {
.coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl),
.elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl),
.macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl),
.plan9 => @panic("GET VADDR"),
.plan9 => return @fieldParentPtr(Plan9, "base", base).getDeclVAddr(decl),
.c => unreachable,
.wasm => unreachable,
.spirv => unreachable,
Expand Down
25 changes: 24 additions & 1 deletion src/link/Plan9.zig
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn putFn(self: *Plan9, decl: *Module.Decl, out: FnDeclOutput) !void {
self.syms.items[fn_map_res.value_ptr.sym_index] = .{
.type = .z,
// just put a giant number, no source file will have this many newlines
.value = std.math.maxInt(u32),
.value = std.math.maxInt(u31),
.name = &.{ 0, 0 },
};
}
Expand Down Expand Up @@ -740,3 +740,26 @@ pub fn allocateDeclIndexes(self: *Plan9, decl: *Module.Decl) !void {
_ = self;
_ = decl;
}
pub fn getDeclVAddr(self: *Plan9, decl: *const Module.Decl) u64 {
if (decl.ty.zigTypeTag() == .Fn) {
var start = self.bases.text;
var it_file = self.fn_decl_table.iterator();
while (it_file.next()) |fentry| {
var symidx_and_submap = fentry.value_ptr;
var submap_it = symidx_and_submap.functions.iterator();
while (submap_it.next()) |entry| {
if (entry.key_ptr.* == decl) return start;
start += entry.value_ptr.code.len;
}
}
unreachable;
} else {
var start = self.bases.data + self.got_len * if (!self.sixtyfour_bit) @as(u32, 4) else 8;
var it = self.data_decl_table.iterator();
while (it.next()) |kv| {
if (decl == kv.key_ptr.*) return start;
start += kv.value_ptr.len;
}
unreachable;
}
}

0 comments on commit d66c97d

Please # to comment.