aboutsummaryrefslogtreecommitdiff
path: root/std/debug/index.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-07-31 14:36:27 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-07-31 14:36:27 -0400
commitf804310d9f953c9d78a4271ba8d75133341840e6 (patch)
tree71a9db15bcabbec32d6f2c795927603f9b278ceb /std/debug/index.zig
parentdd9728c5a03844267bc378c326c353fd2b0e084e (diff)
parent058bfb254c4c0e1cfb254791f771c88c74f299e8 (diff)
downloadzig-f804310d9f953c9d78a4271ba8d75133341840e6.tar.gz
zig-f804310d9f953c9d78a4271ba8d75133341840e6.zip
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'std/debug/index.zig')
-rw-r--r--std/debug/index.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/std/debug/index.zig b/std/debug/index.zig
index 3070e0b40b..ab50d79db3 100644
--- a/std/debug/index.zig
+++ b/std/debug/index.zig
@@ -27,7 +27,7 @@ pub fn warn(comptime fmt: []const u8, args: ...) void {
const stderr = getStderrStream() catch return;
stderr.print(fmt, args) catch return;
}
-fn getStderrStream() !*io.OutStream(io.FileOutStream.Error) {
+pub fn getStderrStream() !*io.OutStream(io.FileOutStream.Error) {
if (stderr_stream) |st| {
return st;
} else {
@@ -172,6 +172,16 @@ pub fn writeStackTrace(stack_trace: *const builtin.StackTrace, out_stream: var,
}
}
+pub inline fn getReturnAddress(frame_count: usize) usize {
+ var fp = @ptrToInt(@frameAddress());
+ var i: usize = 0;
+ while (fp != 0 and i < frame_count) {
+ fp = @intToPtr(*const usize, fp).*;
+ i += 1;
+ }
+ return @intToPtr(*const usize, fp + @sizeOf(usize)).*;
+}
+
pub fn writeCurrentStackTrace(out_stream: var, allocator: *mem.Allocator, debug_info: *ElfStackTrace, tty_color: bool, start_addr: ?usize) !void {
const AddressState = union(enum) {
NotLookingForStartAddress,
@@ -205,7 +215,7 @@ pub fn writeCurrentStackTrace(out_stream: var, allocator: *mem.Allocator, debug_
}
}
-fn printSourceAtAddress(debug_info: *ElfStackTrace, out_stream: var, address: usize, tty_color: bool) !void {
+pub fn printSourceAtAddress(debug_info: *ElfStackTrace, out_stream: var, address: usize, tty_color: bool) !void {
switch (builtin.os) {
builtin.Os.windows => return error.UnsupportedDebugInfo,
builtin.Os.macosx => {