aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-10-24 01:06:03 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-10-24 01:14:52 -0400
commit60cd11bd4b48e4dfdf11d1f25cb1ee842a49ee1d (patch)
tree457ea0157f0f42dccf905593426154be8682812b /lib/std/debug.zig
parent8591731f2b938b2b55b05181d5ec0e27f79c86fa (diff)
downloadzig-60cd11bd4b48e4dfdf11d1f25cb1ee842a49ee1d.tar.gz
zig-60cd11bd4b48e4dfdf11d1f25cb1ee842a49ee1d.zip
get rid of std.os.foo.is_the_target
It had the downside of running all the comptime blocks and resolving all the usingnamespaces of each system, when just trying to discover if the current system is a particular one. For Darwin, where it's nice to use `std.Target.current.isDarwin()`, this demonstrates the utility that #425 would provide.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 0be778b3b6..95670dc4ea 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -133,7 +133,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {
/// chopping off the irrelevant frames and shifting so that the returned addresses pointer
/// equals the passed in addresses pointer.
pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace) void {
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
const addrs = stack_trace.instruction_addresses;
const u32_addrs_len = @intCast(u32, addrs.len);
const first_addr = first_address orelse {
@@ -310,7 +310,7 @@ pub const StackIterator = struct {
};
pub fn writeCurrentStackTrace(out_stream: var, debug_info: *DebugInfo, tty_color: bool, start_addr: ?usize) !void {
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
return writeCurrentStackTraceWindows(out_stream, debug_info, tty_color, start_addr);
}
var it = StackIterator.init(start_addr);
@@ -342,10 +342,10 @@ pub fn writeCurrentStackTraceWindows(
/// TODO once https://github.com/ziglang/zig/issues/3157 is fully implemented,
/// make this `noasync fn` and remove the individual noasync calls.
pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: usize, tty_color: bool) !void {
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
return noasync printSourceAtAddressWindows(debug_info, out_stream, address, tty_color);
}
- if (os.darwin.is_the_target) {
+ if (comptime std.Target.current.isDarwin()) {
return noasync printSourceAtAddressMacOs(debug_info, out_stream, address, tty_color);
}
return noasync printSourceAtAddressPosix(debug_info, out_stream, address, tty_color);
@@ -832,10 +832,10 @@ pub const OpenSelfDebugInfoError = error{
pub fn openSelfDebugInfo(allocator: *mem.Allocator) !DebugInfo {
if (builtin.strip_debug_info)
return error.MissingDebugInfo;
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
return noasync openSelfDebugInfoWindows(allocator);
}
- if (os.darwin.is_the_target) {
+ if (comptime std.Target.current.isDarwin()) {
return noasync openSelfDebugInfoMacOs(allocator);
}
return noasync openSelfDebugInfoPosix(allocator);
@@ -2364,7 +2364,7 @@ pub fn attachSegfaultHandler() void {
if (!have_segfault_handling_support) {
@compileError("segfault handler not supported for this target");
}
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
windows_segfault_handle = windows.kernel32.AddVectoredExceptionHandler(0, handleSegfaultWindows);
return;
}
@@ -2378,7 +2378,7 @@ pub fn attachSegfaultHandler() void {
}
fn resetSegfaultHandler() void {
- if (windows.is_the_target) {
+ if (builtin.os == .windows) {
if (windows_segfault_handle) |handle| {
assert(windows.kernel32.RemoveVectoredExceptionHandler(handle) != 0);
windows_segfault_handle = null;