-
Notifications
You must be signed in to change notification settings - Fork 0
attempt to print stack trace addresses #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
when run with our friend: // err.zig
const std = @import("std");
pub fn main() !void {
const allocator = std.debug.global_allocator;
const args = try std.os.argsAlloc(allocator);
defer std.os.argsFree(allocator, args);
const count = try parseFile(allocator, args[1]);
if (count < 10) return error.NotEnoughItems;
}
fn parseFile(allocator: &std.mem.Allocator, file_path: []const u8) !usize {
const contents = std.io.readFileAlloc(allocator, file_path) catch return error.UnableToReadFile;
defer allocator.free(contents);
return contents.len;
} looks something like
|
We don't want to introduce a dependency on .h files and libc in the standard library. What we can do is read the source for the code you're calling into and port it into zig |
Yes, I know that about the libc dep, hence the "just experimenting" But, is this headed in the right direction? |
I think that the existing dwarf code can actually support macos, but it incorrectly looks for it in its own binary, whereas in reality you have to find the object files and look there. I'd start with trying to figure out, perhaps by reading the implementation of the code you just called into, how to find the actual dwarf info |
Yes I think these are the keys to doing it. cc @bnoordhuis are you still working on this? |
Yes, but using the symtab segment from the image, not external dSYM data. It's less precise but at least it's always available. I'll try to PR it in the next few days. |
I'm just experimenting, but I'm at
https://www.unix.com/man-page/osx/3/backtrace/
and
https://searchfox.org/mozilla-central/source/widget/cocoa/nsCocoaDebugUtils.h#11
and
rust-lang/rust#24346