mirror of
https://github.com/ziglang/zig.git
synced 2025-12-07 23:03:08 +00:00
...which have a ucontext_t but not a PC register. The current stack unwinding implementation does not yet support this architecture. Also fix name of `std.debug.SelfInfo.openSelf` to remove redundancy. Also removed this hook into root providing an "openSelfDebugInfo" function. Sorry, this debugging code is not of sufficient quality to offer a plugin API right now.
28 lines
986 B
Zig
28 lines
986 B
Zig
const std = @import("std");
|
|
const assert = std.debug.assert;
|
|
const testing = std.testing;
|
|
|
|
extern fn add(a: u32, b: u32, addr: *usize) u32;
|
|
|
|
pub fn main() !void {
|
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
defer assert(gpa.deinit() == .ok);
|
|
const allocator = gpa.allocator();
|
|
|
|
var debug_info = try std.debug.SelfInfo.open(allocator);
|
|
defer debug_info.deinit();
|
|
|
|
var add_addr: usize = undefined;
|
|
_ = add(1, 2, &add_addr);
|
|
|
|
const module = try debug_info.getModuleForAddress(add_addr);
|
|
const symbol = try module.getSymbolAtAddress(allocator, add_addr);
|
|
defer symbol.deinit(allocator);
|
|
|
|
try testing.expectEqualStrings("add", symbol.symbol_name);
|
|
try testing.expect(symbol.line_info != null);
|
|
try testing.expectEqualStrings("shared_lib.c", std.fs.path.basename(symbol.line_info.?.file_name));
|
|
try testing.expectEqual(@as(u64, 3), symbol.line_info.?.line);
|
|
try testing.expectEqual(@as(u64, 0), symbol.line_info.?.column);
|
|
}
|