mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
dwarf: refactor arm and riscv64 to the new scheme
This commit is contained in:
parent
4120332577
commit
17ab40f755
@ -4029,18 +4029,11 @@ fn genInlineMemsetCode(
|
||||
// end:
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfMemory}!void {
|
||||
fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfMemory}!void {
|
||||
const mcv = self.args[arg_index];
|
||||
const ty = self.air.instructions.items(.data)[inst].ty;
|
||||
const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index);
|
||||
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl);
|
||||
const atom = switch (self.bin_file.tag) {
|
||||
.elf => &fn_owner_decl.link.elf.dbg_info_atom,
|
||||
.macho => &fn_owner_decl.link.macho.dbg_info_atom,
|
||||
else => unreachable,
|
||||
};
|
||||
const atom = self.getDbgInfoAtom();
|
||||
|
||||
switch (self.debug_output) {
|
||||
.dwarf => |dw| switch (mcv) {
|
||||
@ -4069,6 +4062,17 @@ fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfM
|
||||
}
|
||||
}
|
||||
|
||||
fn getDbgInfoAtom(self: Self) *link.File.Dwarf.Atom {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl);
|
||||
const atom = switch (self.bin_file.tag) {
|
||||
.elf => &fn_owner_decl.link.elf.dbg_info_atom,
|
||||
.macho => &fn_owner_decl.link.macho.dbg_info_atom,
|
||||
else => unreachable,
|
||||
};
|
||||
return atom;
|
||||
}
|
||||
|
||||
fn airArg(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const arg_index = self.arg_index;
|
||||
self.arg_index += 1;
|
||||
|
||||
@ -2460,26 +2460,6 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
// Common helper functions
|
||||
|
||||
/// Adds a Type to the .debug_info at the current position. The bytes will be populated later,
|
||||
/// after codegen for this symbol is done.
|
||||
fn addDbgInfoTypeReloc(self: *Self, ty: Type) !void {
|
||||
switch (self.debug_output) {
|
||||
.dwarf => |dw| {
|
||||
assert(ty.hasRuntimeBits());
|
||||
const dbg_info = &dw.dbg_info;
|
||||
const index = dbg_info.items.len;
|
||||
try dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const atom = switch (self.bin_file.tag) {
|
||||
.elf => &mod.declPtr(self.mod_fn.owner_decl).link.elf.dbg_info_atom,
|
||||
else => unreachable,
|
||||
};
|
||||
try dw.addTypeRelocGlobal(atom, ty, @intCast(u32, index));
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index {
|
||||
const gpa = self.gpa;
|
||||
try self.mir_instructions.ensureUnusedCapacity(gpa, 1);
|
||||
@ -3272,40 +3252,32 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
|
||||
self.finishAirBookkeeping();
|
||||
}
|
||||
|
||||
fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void {
|
||||
fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void {
|
||||
const ty = self.air.instructions.items(.data)[inst].ty;
|
||||
const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index);
|
||||
const name_with_null = name.ptr[0 .. name.len + 1];
|
||||
const atom = self.getDbgInfoAtomPtr();
|
||||
|
||||
switch (mcv) {
|
||||
.register => |reg| {
|
||||
switch (self.debug_output) {
|
||||
.dwarf => |dw| {
|
||||
const dbg_info = &dw.dbg_info;
|
||||
try dbg_info.ensureUnusedCapacity(3);
|
||||
dbg_info.appendAssumeCapacity(@enumToInt(link.File.Dwarf.AbbrevKind.parameter));
|
||||
dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
|
||||
1, // ULEB128 dwarf expression length
|
||||
reg.dwarfLocOp(),
|
||||
});
|
||||
try dbg_info.ensureUnusedCapacity(5 + name_with_null.len);
|
||||
try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4
|
||||
dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
},
|
||||
.stack_offset => |offset| {
|
||||
_ = offset;
|
||||
switch (self.debug_output) {
|
||||
.dwarf => {},
|
||||
else => {},
|
||||
}
|
||||
switch (self.debug_output) {
|
||||
.dwarf => |dw| switch (mcv) {
|
||||
.register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{
|
||||
.register = reg.dwarfLocOp(),
|
||||
}),
|
||||
else => {},
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn getDbgInfoAtomPtr(self: Self) *link.File.Dwarf.Atom {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl);
|
||||
const atom = switch (self.bin_file.tag) {
|
||||
.elf => &fn_owner_decl.link.elf.dbg_info_atom,
|
||||
else => unreachable,
|
||||
};
|
||||
return atom;
|
||||
}
|
||||
|
||||
// TODO replace this to call to extern memcpy
|
||||
fn genInlineMemcpy(
|
||||
self: *Self,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user