Merge branch 'master' into zig-0.15.0
This commit is contained in:
commit
4e80bae8b8
24 changed files with 701 additions and 262 deletions
|
@ -11,10 +11,12 @@ const RGB = @import("color").RGB;
|
|||
|
||||
const Plane = @This();
|
||||
|
||||
const name_buf_len = 128;
|
||||
|
||||
window: vaxis.Window,
|
||||
row: i32 = 0,
|
||||
col: i32 = 0,
|
||||
name_buf: [128]u8,
|
||||
name_buf: [name_buf_len]u8,
|
||||
name_len: usize,
|
||||
cache: GraphemeCache = .{},
|
||||
style: vaxis.Cell.Style = .{},
|
||||
|
@ -27,7 +29,7 @@ pub const Options = struct {
|
|||
x: usize = 0,
|
||||
rows: usize = 0,
|
||||
cols: usize = 0,
|
||||
name: [*:0]const u8,
|
||||
name: []const u8,
|
||||
flags: option = .none,
|
||||
};
|
||||
|
||||
|
@ -44,13 +46,14 @@ pub fn init(nopts: *const Options, parent_: Plane) !Plane {
|
|||
.height = @as(u16, @intCast(nopts.rows)),
|
||||
.border = .{},
|
||||
};
|
||||
const len = @min(nopts.name.len, name_buf_len);
|
||||
var plane: Plane = .{
|
||||
.window = parent_.window.child(opts),
|
||||
.name_buf = undefined,
|
||||
.name_len = std.mem.span(nopts.name).len,
|
||||
.name_len = len,
|
||||
.scrolling = nopts.flags == .VSCROLL,
|
||||
};
|
||||
@memcpy(plane.name_buf[0..plane.name_len], nopts.name);
|
||||
@memcpy(plane.name_buf[0..len], nopts.name[0..len]);
|
||||
return plane;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ pub const Error = error{
|
|||
InvalidPIntType,
|
||||
JsonIncompatibleType,
|
||||
NotAnObject,
|
||||
BadArrayAllocExtract,
|
||||
} || std.Thread.SpawnError;
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, handler_ctx: *anyopaque, no_alternate: bool, _: *const fn (ctx: *anyopaque) void) Error!Self {
|
||||
|
@ -135,15 +136,46 @@ pub fn install_crash_handler() void {
|
|||
std.posix.sigaction(std.posix.SIG.ILL, &act, null);
|
||||
}
|
||||
|
||||
pub var jit_debugger_enabled: bool = false;
|
||||
|
||||
fn handle_crash(sig: i32, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) noreturn {
|
||||
const debug = @import("std/debug.zig");
|
||||
debug.lockStdErr();
|
||||
|
||||
if (panic_in_progress())
|
||||
std.posix.abort();
|
||||
|
||||
in_panic.store(true, .release);
|
||||
const cleanup = panic_cleanup;
|
||||
panic_cleanup = null;
|
||||
|
||||
if (cleanup) |self| {
|
||||
self.vx.deinit(self.allocator, self.tty.anyWriter());
|
||||
self.tty.deinit();
|
||||
}
|
||||
@import("std/debug.zig").handleSegfaultPosix(sig, info, ctx_ptr);
|
||||
if (builtin.os.tag == .linux and jit_debugger_enabled) {
|
||||
handleSegfaultPosixNoAbort(sig, info, ctx_ptr);
|
||||
@import("thespian").sighdl_debugger(sig, @ptrCast(@constCast(info)), ctx_ptr);
|
||||
std.posix.abort();
|
||||
} else {
|
||||
debug.handleSegfaultPosix(sig, info, ctx_ptr);
|
||||
}
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn handleSegfaultPosixNoAbort(sig: i32, info: *const std.posix.siginfo_t, ctx_ptr: ?*anyopaque) void {
|
||||
const debug = @import("std/debug.zig");
|
||||
debug.resetSegfaultHandler();
|
||||
const addr = switch (builtin.os.tag) {
|
||||
.linux => @intFromPtr(info.fields.sigfault.addr),
|
||||
.freebsd, .macos => @intFromPtr(info.addr),
|
||||
.netbsd => @intFromPtr(info.info.reason.fault.addr),
|
||||
.openbsd => @intFromPtr(info.data.fault.addr),
|
||||
.solaris, .illumos => @intFromPtr(info.reason.fault.addr),
|
||||
else => unreachable,
|
||||
};
|
||||
const code = if (builtin.os.tag == .netbsd) info.info.code else info.code;
|
||||
debug.dumpSegfaultInfoPosix(sig, code, addr, ctx_ptr);
|
||||
}
|
||||
|
||||
pub fn run(self: *Self) Error!void {
|
||||
|
|
|
@ -1384,7 +1384,7 @@ pub fn attachSegfaultHandler() void {
|
|||
updateSegfaultHandler(&act);
|
||||
}
|
||||
|
||||
fn resetSegfaultHandler() void {
|
||||
pub fn resetSegfaultHandler() void {
|
||||
if (native_os == .windows) {
|
||||
if (windows_segfault_handle) |handle| {
|
||||
assert(windows.kernel32.RemoveVectoredExceptionHandler(handle) != 0);
|
||||
|
@ -1442,7 +1442,7 @@ pub fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*an
|
|||
posix.abort();
|
||||
}
|
||||
|
||||
fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque) void {
|
||||
pub fn dumpSegfaultInfoPosix(sig: i32, code: i32, addr: usize, ctx_ptr: ?*anyopaque) void {
|
||||
const stderr = io.getStdErr().writer();
|
||||
_ = switch (sig) {
|
||||
posix.SIG.SEGV => if (native_arch == .x86_64 and native_os == .linux and code == 128) // SI_KERNEL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue