diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-01-17 01:20:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 01:20:11 -0500 |
| commit | 4bace0f6212a3007247c42b0effcc40c6cfe61a8 (patch) | |
| tree | a5c1fee87a9266319d8ceffa7717ca5c70b61f7b /lib/std/debug | |
| parent | 257054a1467b2612725bd66852d84496024cf66c (diff) | |
| parent | 8c8dfb35f398407319764f0f8998de34c5247ed6 (diff) | |
| download | zig-4bace0f6212a3007247c42b0effcc40c6cfe61a8.tar.gz zig-4bace0f6212a3007247c42b0effcc40c6cfe61a8.zip | |
Merge pull request #22386 from jacobly0/x86_64-rewrite
x86_64: begin rewriting instruction selection
Diffstat (limited to 'lib/std/debug')
| -rw-r--r-- | lib/std/debug/NoPanic.zig | 59 | ||||
| -rw-r--r-- | lib/std/debug/SelfInfo.zig | 8 |
2 files changed, 63 insertions, 4 deletions
diff --git a/lib/std/debug/NoPanic.zig b/lib/std/debug/NoPanic.zig new file mode 100644 index 0000000000..04ae79b8cc --- /dev/null +++ b/lib/std/debug/NoPanic.zig @@ -0,0 +1,59 @@ +//! This namespace can be used with `pub const Panic = std.debug.NoPanic;` in the root file. +//! It emits as little code as possible, for testing purposes. +//! +//! For a functional alternative, see `std.debug.FormattedPanic`. + +const std = @import("../std.zig"); + +pub fn call(_: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn { + @branchHint(.cold); + @trap(); +} + +pub inline fn sentinelMismatch(_: anytype, _: anytype) noreturn { + @branchHint(.cold); + @trap(); +} + +pub inline fn unwrapError(_: ?*std.builtin.StackTrace, _: anyerror) noreturn { + @branchHint(.cold); + @trap(); +} + +pub inline fn outOfBounds(_: usize, _: usize) noreturn { + @branchHint(.cold); + @trap(); +} + +pub inline fn startGreaterThanEnd(_: usize, _: usize) noreturn { + @branchHint(.cold); + @trap(); +} + +pub inline fn inactiveUnionField(_: anytype, _: anytype) noreturn { + @branchHint(.cold); + @trap(); +} + +pub const messages = struct { + pub const reached_unreachable = ""; + pub const unwrap_null = ""; + pub const cast_to_null = ""; + pub const incorrect_alignment = ""; + pub const invalid_error_code = ""; + pub const cast_truncated_data = ""; + pub const negative_to_unsigned = ""; + pub const integer_overflow = ""; + pub const shl_overflow = ""; + pub const shr_overflow = ""; + pub const divide_by_zero = ""; + pub const exact_division_remainder = ""; + pub const integer_part_out_of_bounds = ""; + pub const corrupt_switch = ""; + pub const shift_rhs_too_big = ""; + pub const invalid_enum_value = ""; + pub const for_len_mismatch = ""; + pub const memcpy_len_mismatch = ""; + pub const memcpy_alias = ""; + pub const noreturn_returned = ""; +}; diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index 544cf0ac6f..4dd0b4e842 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -121,13 +121,13 @@ pub fn deinit(self: *SelfInfo) void { } pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module { - if (comptime builtin.target.isDarwin()) { + if (builtin.target.isDarwin()) { return self.lookupModuleDyld(address); } else if (native_os == .windows) { return self.lookupModuleWin32(address); } else if (native_os == .haiku) { return self.lookupModuleHaiku(address); - } else if (comptime builtin.target.isWasm()) { + } else if (builtin.target.isWasm()) { return self.lookupModuleWasm(address); } else { return self.lookupModuleDl(address); @@ -138,13 +138,13 @@ pub fn getModuleForAddress(self: *SelfInfo, address: usize) !*Module { // This can be called when getModuleForAddress fails, so implementations should provide // a path that doesn't rely on any side-effects of a prior successful module lookup. pub fn getModuleNameForAddress(self: *SelfInfo, address: usize) ?[]const u8 { - if (comptime builtin.target.isDarwin()) { + if (builtin.target.isDarwin()) { return self.lookupModuleNameDyld(address); } else if (native_os == .windows) { return self.lookupModuleNameWin32(address); } else if (native_os == .haiku) { return null; - } else if (comptime builtin.target.isWasm()) { + } else if (builtin.target.isWasm()) { return null; } else { return self.lookupModuleNameDl(address); |
