mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.debug: improve the APIs and stuff
This commit is contained in:
parent
d4f710791f
commit
5709369d05
4 changed files with 457 additions and 676 deletions
1108
lib/std/debug.zig
1108
lib/std/debug.zig
File diff suppressed because it is too large
Load diff
|
|
@ -1449,7 +1449,7 @@ fn getStringGeneric(opt_str: ?[]const u8, offset: u64) ![:0]const u8 {
|
|||
|
||||
pub fn getSymbol(di: *Dwarf, allocator: Allocator, endian: Endian, address: u64) !std.debug.Symbol {
|
||||
const compile_unit = di.findCompileUnit(endian, address) catch |err| switch (err) {
|
||||
error.MissingDebugInfo, error.InvalidDebugInfo => return .{ .name = null, .compile_unit_name = null, .source_location = null },
|
||||
error.MissingDebugInfo, error.InvalidDebugInfo => return .unknown,
|
||||
else => return err,
|
||||
};
|
||||
return .{
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ test {
|
|||
}
|
||||
|
||||
pub const UnwindContext = struct {
|
||||
gpa: Allocator,
|
||||
gpa: Allocator, // MLUGG TODO: make unmanaged (also maybe rename this type, DwarfUnwindContext or smth idk)
|
||||
cfa: ?usize,
|
||||
pc: usize,
|
||||
thread_context: *std.debug.ThreadContext,
|
||||
|
|
@ -166,22 +166,20 @@ pub const UnwindContext = struct {
|
|||
vm: Dwarf.Unwind.VirtualMachine,
|
||||
stack_machine: Dwarf.expression.StackMachine(.{ .call_frame_context = true }),
|
||||
|
||||
pub fn init(gpa: Allocator, thread_context: *std.debug.ThreadContext) !UnwindContext {
|
||||
pub fn init(gpa: Allocator, thread_context: *std.debug.ThreadContext) UnwindContext {
|
||||
comptime assert(supports_unwinding);
|
||||
|
||||
const ip_reg_num = Dwarf.abi.ipRegNum(native_arch).?;
|
||||
const pc = stripInstructionPtrAuthCode(
|
||||
(try regValueNative(thread_context, ip_reg_num, null)).*,
|
||||
);
|
||||
|
||||
const context_copy = try gpa.create(std.debug.ThreadContext);
|
||||
std.debug.copyContext(thread_context, context_copy);
|
||||
const raw_pc_ptr = regValueNative(thread_context, ip_reg_num, null) catch {
|
||||
unreachable; // error means unsupported, in which case `supports_unwinding` should have been `false`
|
||||
};
|
||||
const pc = stripInstructionPtrAuthCode(raw_pc_ptr.*);
|
||||
|
||||
return .{
|
||||
.gpa = gpa,
|
||||
.cfa = null,
|
||||
.pc = pc,
|
||||
.thread_context = context_copy,
|
||||
.thread_context = thread_context,
|
||||
.reg_context = undefined,
|
||||
.vm = .{},
|
||||
.stack_machine = .{},
|
||||
|
|
@ -191,7 +189,6 @@ pub const UnwindContext = struct {
|
|||
pub fn deinit(self: *UnwindContext) void {
|
||||
self.vm.deinit(self.gpa);
|
||||
self.stack_machine.deinit(self.gpa);
|
||||
self.gpa.destroy(self.thread_context);
|
||||
self.* = undefined;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -196,11 +196,7 @@ pub fn getSymbolAtAddress(module: *const DarwinModule, gpa: Allocator, di: *Debu
|
|||
const full = &di.full.?;
|
||||
|
||||
const vaddr = address - module.load_offset;
|
||||
const symbol = MachoSymbol.find(full.symbols, vaddr) orelse return .{
|
||||
.name = null,
|
||||
.compile_unit_name = null,
|
||||
.source_location = null,
|
||||
};
|
||||
const symbol = MachoSymbol.find(full.symbols, vaddr) orelse return .unknown;
|
||||
|
||||
// offset of `address` from start of `symbol`
|
||||
const address_symbol_offset = vaddr - symbol.addr;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue