mirror of
https://github.com/ziglang/zig.git
synced 2025-12-07 14:53:08 +00:00
fmt and cleanup
This commit is contained in:
parent
c98e03fc7e
commit
a325d7f6d1
@ -162,8 +162,6 @@ pub fn dumpStackTraceFromBase(context: anytype) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var it = StackIterator.initWithContext(null, debug_info, context) catch return;
|
var it = StackIterator.initWithContext(null, debug_info, context) catch return;
|
||||||
|
|
||||||
// TODO: Should `it.dwarf_context.pc` be `it.getIp()`? (but then the non-dwarf case has to store ip)
|
|
||||||
printSourceAtAddress(debug_info, stderr, it.dwarf_context.pc, tty_config) catch return;
|
printSourceAtAddress(debug_info, stderr, it.dwarf_context.pc, tty_config) catch return;
|
||||||
|
|
||||||
while (it.next()) |return_address| {
|
while (it.next()) |return_address| {
|
||||||
@ -2039,59 +2037,6 @@ fn dumpSegfaultInfoPosix(sig: i32, addr: usize, ctx_ptr: ?*const anyopaque) void
|
|||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this logic to dwarf.abi.regBytes
|
|
||||||
|
|
||||||
// switch (native_arch) {
|
|
||||||
// .x86 => {
|
|
||||||
// const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
|
|
||||||
// const ip = @intCast(usize, ctx.mcontext.gregs[os.REG.EIP]) ;
|
|
||||||
// const bp = @intCast(usize, ctx.mcontext.gregs[os.REG.EBP]);
|
|
||||||
// dumpStackTraceFromBase(bp, ip);
|
|
||||||
// },
|
|
||||||
// .x86_64 => {
|
|
||||||
// const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
|
|
||||||
// const ip = switch (native_os) {
|
|
||||||
// .linux, .netbsd, .solaris => @intCast(usize, ctx.mcontext.gregs[os.REG.RIP]),
|
|
||||||
// .freebsd => @intCast(usize, ctx.mcontext.rip),
|
|
||||||
// .openbsd => @intCast(usize, ctx.sc_rip),
|
|
||||||
// .macos => @intCast(usize, ctx.mcontext.ss.rip),
|
|
||||||
// else => unreachable,
|
|
||||||
// };
|
|
||||||
// const bp = switch (native_os) {
|
|
||||||
// .linux, .netbsd, .solaris => @intCast(usize, ctx.mcontext.gregs[os.REG.RBP]),
|
|
||||||
// .openbsd => @intCast(usize, ctx.sc_rbp),
|
|
||||||
// .freebsd => @intCast(usize, ctx.mcontext.rbp),
|
|
||||||
// .macos => @intCast(usize, ctx.mcontext.ss.rbp),
|
|
||||||
// else => unreachable,
|
|
||||||
// };
|
|
||||||
// dumpStackTraceFromBase(bp, ip);
|
|
||||||
// },
|
|
||||||
// .arm => {
|
|
||||||
// const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
|
|
||||||
// const ip = @intCast(usize, ctx.mcontext.arm_pc);
|
|
||||||
// const bp = @intCast(usize, ctx.mcontext.arm_fp);
|
|
||||||
// dumpStackTraceFromBase(bp, ip);
|
|
||||||
// },
|
|
||||||
// .aarch64 => {
|
|
||||||
// const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr));
|
|
||||||
// const ip = switch (native_os) {
|
|
||||||
// .macos => @intCast(usize, ctx.mcontext.ss.pc),
|
|
||||||
// .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.PC]),
|
|
||||||
// .freebsd => @intCast(usize, ctx.mcontext.gpregs.elr),
|
|
||||||
// else => @intCast(usize, ctx.mcontext.pc),
|
|
||||||
// };
|
|
||||||
// // x29 is the ABI-designated frame pointer
|
|
||||||
// const bp = switch (native_os) {
|
|
||||||
// .macos => @intCast(usize, ctx.mcontext.ss.fp),
|
|
||||||
// .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG.FP]),
|
|
||||||
// .freebsd => @intCast(usize, ctx.mcontext.gpregs.x[os.REG.FP]),
|
|
||||||
// else => @intCast(usize, ctx.mcontext.regs[29]),
|
|
||||||
// };
|
|
||||||
// dumpStackTraceFromBase(bp, ip);
|
|
||||||
// },
|
|
||||||
// else => {},
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long {
|
fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows.WINAPI) c_long {
|
||||||
|
|||||||
@ -1603,7 +1603,6 @@ pub const DwarfInfo = struct {
|
|||||||
// TODO: Evaluate expression
|
// TODO: Evaluate expression
|
||||||
_ = expression;
|
_ = expression;
|
||||||
return error.UnimplementedTODO;
|
return error.UnimplementedTODO;
|
||||||
|
|
||||||
},
|
},
|
||||||
else => return error.InvalidCFARule,
|
else => return error.InvalidCFARule,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -18,14 +18,14 @@ pub const StackMachineOptions = struct {
|
|||||||
/// Expressions can be decoded for non-native address size and endianness,
|
/// Expressions can be decoded for non-native address size and endianness,
|
||||||
/// but can only be executed if the current target matches the configuration.
|
/// but can only be executed if the current target matches the configuration.
|
||||||
pub fn StackMachine(comptime options: StackMachineOptions) type {
|
pub fn StackMachine(comptime options: StackMachineOptions) type {
|
||||||
const addr_type = switch(options.addr_size) {
|
const addr_type = switch (options.addr_size) {
|
||||||
2 => u16,
|
2 => u16,
|
||||||
4 => u32,
|
4 => u32,
|
||||||
8 => u64,
|
8 => u64,
|
||||||
else => @compileError("Unsupported address size of " ++ options.addr_size),
|
else => @compileError("Unsupported address size of " ++ options.addr_size),
|
||||||
};
|
};
|
||||||
|
|
||||||
const addr_type_signed = switch(options.addr_size) {
|
const addr_type_signed = switch (options.addr_size) {
|
||||||
2 => i16,
|
2 => i16,
|
||||||
4 => i32,
|
4 => i32,
|
||||||
8 => i64,
|
8 => i64,
|
||||||
@ -61,19 +61,15 @@ pub fn StackMachine(comptime options: StackMachineOptions) type {
|
|||||||
fn generic(value: anytype) Value {
|
fn generic(value: anytype) Value {
|
||||||
const int_info = @typeInfo(@TypeOf(value)).Int;
|
const int_info = @typeInfo(@TypeOf(value)).Int;
|
||||||
if (@sizeOf(@TypeOf(value)) > options.addr_size) {
|
if (@sizeOf(@TypeOf(value)) > options.addr_size) {
|
||||||
return .{
|
return .{ .generic = switch (int_info.signedness) {
|
||||||
.generic = switch (int_info.signedness) {
|
|
||||||
.signed => @bitCast(addr_type, @truncate(addr_type_signed, value)),
|
.signed => @bitCast(addr_type, @truncate(addr_type_signed, value)),
|
||||||
.unsigned => @truncate(addr_type, value),
|
.unsigned => @truncate(addr_type, value),
|
||||||
}
|
} };
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return .{
|
return .{ .generic = switch (int_info.signedness) {
|
||||||
.generic = switch (int_info.signedness) {
|
|
||||||
.signed => @bitCast(addr_type, @intCast(addr_type_signed, value)),
|
.signed => @bitCast(addr_type, @intCast(addr_type_signed, value)),
|
||||||
.unsigned => @intCast(addr_type, value),
|
.unsigned => @intCast(addr_type, value),
|
||||||
}
|
} };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,20 +109,15 @@ pub fn StackMachine(comptime options: StackMachineOptions) type {
|
|||||||
=> generic(try leb.readILEB128(i64, reader)),
|
=> generic(try leb.readILEB128(i64, reader)),
|
||||||
OP.lit0...OP.lit31 => |n| generic(n - OP.lit0),
|
OP.lit0...OP.lit31 => |n| generic(n - OP.lit0),
|
||||||
OP.reg0...OP.reg31 => |n| .{ .register = n - OP.reg0 },
|
OP.reg0...OP.reg31 => |n| .{ .register = n - OP.reg0 },
|
||||||
OP.breg0...OP.breg31 => |n| .{
|
OP.breg0...OP.breg31 => |n| .{ .base_register = .{
|
||||||
.base_register = .{
|
|
||||||
.base_register = n - OP.breg0,
|
.base_register = n - OP.breg0,
|
||||||
.offset = try leb.readILEB128(i64, reader),
|
.offset = try leb.readILEB128(i64, reader),
|
||||||
}
|
} },
|
||||||
},
|
|
||||||
OP.regx => .{ .register = try leb.readULEB128(u8, reader) },
|
OP.regx => .{ .register = try leb.readULEB128(u8, reader) },
|
||||||
OP.bregx,
|
OP.bregx, OP.regval_type => .{ .base_register = .{
|
||||||
OP.regval_type => .{
|
|
||||||
.base_register = .{
|
|
||||||
.base_register = try leb.readULEB128(u8, reader),
|
.base_register = try leb.readULEB128(u8, reader),
|
||||||
.offset = try leb.readILEB128(i64, reader),
|
.offset = try leb.readILEB128(i64, reader),
|
||||||
}
|
} },
|
||||||
},
|
|
||||||
OP.piece => .{
|
OP.piece => .{
|
||||||
.composite_location = .{
|
.composite_location = .{
|
||||||
.size = try leb.readULEB128(u8, reader),
|
.size = try leb.readULEB128(u8, reader),
|
||||||
@ -139,9 +130,7 @@ pub fn StackMachine(comptime options: StackMachineOptions) type {
|
|||||||
.offset = try leb.readILEB128(i64, reader),
|
.offset = try leb.readILEB128(i64, reader),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
OP.implicit_value,
|
OP.implicit_value, OP.entry_value => blk: {
|
||||||
OP.entry_value
|
|
||||||
=> blk: {
|
|
||||||
const size = try leb.readULEB128(u8, reader);
|
const size = try leb.readULEB128(u8, reader);
|
||||||
if (stream.pos + size > stream.buffer.len) return error.InvalidExpression;
|
if (stream.pos + size > stream.buffer.len) return error.InvalidExpression;
|
||||||
const block = stream.buffer[stream.pos..][0..size];
|
const block = stream.buffer[stream.pos..][0..size];
|
||||||
@ -156,12 +145,10 @@ pub fn StackMachine(comptime options: StackMachineOptions) type {
|
|||||||
if (stream.pos + size > stream.buffer.len) return error.InvalidExpression;
|
if (stream.pos + size > stream.buffer.len) return error.InvalidExpression;
|
||||||
const value_bytes = stream.buffer[stream.pos..][0..size];
|
const value_bytes = stream.buffer[stream.pos..][0..size];
|
||||||
stream.pos += size;
|
stream.pos += size;
|
||||||
break :blk .{
|
break :blk .{ .base_type = .{
|
||||||
.base_type = .{
|
|
||||||
.type_offset = type_offset,
|
.type_offset = type_offset,
|
||||||
.value_bytes = value_bytes,
|
.value_bytes = value_bytes,
|
||||||
}
|
} };
|
||||||
};
|
|
||||||
},
|
},
|
||||||
OP.deref_type,
|
OP.deref_type,
|
||||||
OP.xderef_type,
|
OP.xderef_type,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user