aboutsummaryrefslogtreecommitdiff
path: root/std/debug/index.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-15 00:01:02 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-15 00:01:02 -0500
commit7b57454cc11371b71097967656e19f0a1736d733 (patch)
tree4eff514fcb0a0c1f95ac253624c4f705fe95b03e /std/debug/index.zig
parentd973b40884be1c7874805c81981cac7edca5605b (diff)
downloadzig-7b57454cc11371b71097967656e19f0a1736d733.tar.gz
zig-7b57454cc11371b71097967656e19f0a1736d733.zip
clean up error return tracing
* error return tracing is disabled in release-fast mode * add @errorReturnTrace * zig build API changes build return type from `void` to `%void` * allow `void`, `noreturn`, and `u8` from main. closes #535
Diffstat (limited to 'std/debug/index.zig')
-rw-r--r--std/debug/index.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/std/debug/index.zig b/std/debug/index.zig
index f7f6ffa323..5dc7b0dbfa 100644
--- a/std/debug/index.zig
+++ b/std/debug/index.zig
@@ -56,7 +56,7 @@ pub fn dumpCurrentStackTrace() {
}
/// Tries to print a stack trace to stderr, unbuffered, and ignores any error returned.
-pub fn dumpStackTrace(stack_trace: &builtin.StackTrace) {
+pub fn dumpStackTrace(stack_trace: &const builtin.StackTrace) {
const stderr = getStderrStream() catch return;
const debug_info = openSelfDebugInfo(global_allocator) catch |err| {
stderr.print("Unable to open debug info: {}\n", @errorName(err)) catch return;
@@ -127,7 +127,7 @@ const RESET = "\x1b[0m";
error PathNotFound;
error InvalidDebugInfo;
-pub fn writeStackTrace(stack_trace: &builtin.StackTrace, out_stream: &io.OutStream, allocator: &mem.Allocator,
+pub fn writeStackTrace(stack_trace: &const builtin.StackTrace, out_stream: &io.OutStream, allocator: &mem.Allocator,
debug_info: &ElfStackTrace, tty_color: bool) -> %void
{
var frame_index: usize = undefined;
@@ -167,6 +167,9 @@ pub fn writeCurrentStackTrace(out_stream: &io.OutStream, allocator: &mem.Allocat
}
fn printSourceAtAddress(debug_info: &ElfStackTrace, out_stream: &io.OutStream, address: usize) -> %void {
+ if (builtin.os == builtin.Os.windows) {
+ return error.UnsupportedDebugInfo;
+ }
// TODO we really should be able to convert @sizeOf(usize) * 2 to a string literal
// at compile time. I'll call it issue #313
const ptr_hex = if (@sizeOf(usize) == 4) "0x{x8}" else "0x{x16}";
@@ -177,7 +180,7 @@ fn printSourceAtAddress(debug_info: &ElfStackTrace, out_stream: &io.OutStream, a
return;
};
const compile_unit_name = try compile_unit.die.getAttrString(debug_info, DW.AT_name);
- if (getLineNumberInfo(debug_info, compile_unit, usize(address) - 1)) |line_info| {
+ if (getLineNumberInfo(debug_info, compile_unit, address - 1)) |line_info| {
defer line_info.deinit();
try out_stream.print(WHITE ++ "{}:{}:{}" ++ RESET ++ ": " ++
DIM ++ ptr_hex ++ " in ??? ({})" ++ RESET ++ "\n",