diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-08-29 16:35:51 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-29 16:35:51 -0400 |
| commit | f1b71053de6c5e71e2e1f73daeaff29280b69350 (patch) | |
| tree | 6e27b78ebc073622dec68d49f809fe5ceb5fe674 /std/os | |
| parent | 833477abf5a7df2c8861a2df11fae2105016e087 (diff) | |
| download | zig-f1b71053de6c5e71e2e1f73daeaff29280b69350.tar.gz zig-f1b71053de6c5e71e2e1f73daeaff29280b69350.zip | |
use RtlCaptureStackBackTrace on windows
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/file.zig | 1 | ||||
| -rw-r--r-- | std/os/index.zig | 6 | ||||
| -rw-r--r-- | std/os/windows/index.zig | 1 | ||||
| -rw-r--r-- | std/os/windows/ntdll.zig | 3 |
4 files changed, 9 insertions, 2 deletions
diff --git a/std/os/file.zig b/std/os/file.zig index d63cb1deaa..e90275ec7f 100644 --- a/std/os/file.zig +++ b/std/os/file.zig @@ -271,6 +271,7 @@ pub const File = struct { const err = windows.GetLastError(); return switch (err) { windows.ERROR.INVALID_PARAMETER => unreachable, + windows.ERROR.INVALID_HANDLE => unreachable, else => os.unexpectedErrorWindows(err), }; } diff --git a/std/os/index.zig b/std/os/index.zig index 74f94dce5a..03337b63bc 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -661,6 +661,7 @@ pub fn getBaseAddress() usize { return phdr - @sizeOf(ElfHeader); }, builtin.Os.macosx => return @ptrToInt(&std.c._mh_execute_header), + builtin.Os.windows => return @ptrToInt(windows.GetModuleHandleW(null)), else => @compileError("Unsupported OS"), } } @@ -2069,7 +2070,7 @@ fn testWindowsCmdLine(input_cmd_line: [*]const u8, expected_args: []const []cons } // TODO make this a build variable that you can set -const unexpected_error_tracing = false; +const unexpected_error_tracing = true; const UnexpectedError = error{ /// The Operating System returned an undocumented error code. Unexpected, @@ -2088,8 +2089,9 @@ pub fn unexpectedErrorPosix(errno: usize) UnexpectedError { /// Call this when you made a windows DLL call or something that does SetLastError /// and you get an unexpected error. pub fn unexpectedErrorWindows(err: windows.DWORD) UnexpectedError { - if (true) { + if (unexpected_error_tracing) { debug.warn("unexpected GetLastError(): {}\n", err); + @breakpoint(); debug.dumpCurrentStackTrace(null); } return error.Unexpected; diff --git a/std/os/windows/index.zig b/std/os/windows/index.zig index 5c68176c5a..ca6299dc5e 100644 --- a/std/os/windows/index.zig +++ b/std/os/windows/index.zig @@ -3,6 +3,7 @@ const assert = std.debug.assert; pub use @import("advapi32.zig"); pub use @import("kernel32.zig"); +pub use @import("ntdll.zig"); pub use @import("ole32.zig"); pub use @import("shell32.zig"); pub use @import("shlwapi.zig"); diff --git a/std/os/windows/ntdll.zig b/std/os/windows/ntdll.zig new file mode 100644 index 0000000000..acb78a59f4 --- /dev/null +++ b/std/os/windows/ntdll.zig @@ -0,0 +1,3 @@ +use @import("index.zig"); + +pub extern "NtDll" stdcallcc fn RtlCaptureStackBackTrace(FramesToSkip: DWORD, FramesToCapture: DWORD, BackTrace: **c_void, BackTraceHash: ?*DWORD) WORD; |
