Skip to content
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

Read traceback data from external debug info #3014

Closed
wants to merge 8 commits into from

Conversation

daurnimator
Copy link
Contributor

@daurnimator daurnimator commented Aug 5, 2019

Part of #2300

Currently on top of #3005

To play with external debug info I've been using:

const std = @import("std");

pub fn main() void {
    std.debug.dumpCurrentStackTrace(@returnAddress());
}

and compiling+running with:

./bin/zig build-exe ../play.zig
objcopy --only-keep-debug play play.debug
objcopy --strip-all play play
objcopy --add-gnu-debuglink=play.debug play
./play

@daurnimator daurnimator added the standard library This issue involves writing Zig code for the standard library. label Aug 5, 2019
@daurnimator
Copy link
Contributor Author

Weirdly, this diff fixes the open issue 2 above:

diff --git a/std/debug.zig b/std/debug.zig
index 0cb3d86f2..a6909ef9c 100644
--- a/std/debug.zig
+++ b/std/debug.zig
@@ -1218,14 +1218,19 @@ fn openSelfDebugInfoPosix(allocator: *mem.Allocator) !DwarfInfo {
         );
     };
     errdefer os.munmap(self_exe_mmap);
-    var self_exe_mmap_seekable = io.SliceSeekableInStream.init(self_exe_mmap);
+
+    const S = struct {
+        var self_exe_mmap_seekable: io.SliceSeekableInStream = undefined;
+    };
+
+    S.self_exe_mmap_seekable = io.SliceSeekableInStream.init(self_exe_mmap);
 
     return openElfDebugInfo(
         allocator,
         // TODO https://github.com/ziglang/zig/issues/764
-        @ptrCast(*DwarfSeekableStream, &self_exe_mmap_seekable.seekable_stream),
+        @ptrCast(*DwarfSeekableStream, &S.self_exe_mmap_seekable.seekable_stream),
         // TODO https://github.com/ziglang/zig/issues/764
-        @ptrCast(*DwarfInStream, &self_exe_mmap_seekable.stream),
+        @ptrCast(*DwarfInStream, &S.self_exe_mmap_seekable.stream),
     );
 }
 

Is this a copy elision bug?

@daurnimator daurnimator mentioned this pull request Aug 11, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Aug 19, 2019
@andrewrk andrewrk removed this from the 0.6.0 milestone Oct 1, 2019
@andrewrk
Copy link
Member

please re-open when you have something ready for review

@andrewrk andrewrk closed this Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants