| author | |
| committer | |
| log | 6abf1fbfe6f7f3c06e70e331a3c9e5101624d501 |
| tree | 6f2b2b0adfe08900a864b6888590c5f17043a483 |
| parent | 84a1244b6c8d8b093d514cf267c832ad24d4400f |
5 files changed, 26 insertions(+), 30 deletions(-)
lib/std/debug.zig+4-4| ... | ... | @@ -987,7 +987,7 @@ pub fn readElfDebugInfo( |
| 987 | 987 | |
| 988 | 988 | if (mem.eql(u8, name, ".gnu_debuglink")) { |
| 989 | 989 | const gnu_debuglink = try chopSlice(mapped_mem, shdr.sh_offset, shdr.sh_size); |
| 990 | const debug_filename = mem.sliceTo(@ptrCast([*:0]const u8, gnu_debuglink.ptr), 0); | |
| 990 | const debug_filename = mem.sliceTo(@as([*:0]const u8, @ptrCast(gnu_debuglink.ptr)), 0); | |
| 991 | 991 | const crc_offset = mem.alignForward(usize, @intFromPtr(&debug_filename[debug_filename.len]) + 1, 4) - @intFromPtr(gnu_debuglink.ptr); |
| 992 | 992 | const crc_bytes = gnu_debuglink[crc_offset .. crc_offset + 4]; |
| 993 | 993 | separate_debug_crc = mem.readIntSliceNative(u32, crc_bytes); |
| ... | ... | @@ -1535,7 +1535,7 @@ pub const DebugInfo = struct { |
| 1535 | 1535 | switch (phdr.p_type) { |
| 1536 | 1536 | elf.PT_NOTE => { |
| 1537 | 1537 | // Look for .note.gnu.build-id |
| 1538 | const note_bytes = @ptrFromInt([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz]; | |
| 1538 | const note_bytes = @as([*]const u8, @ptrFromInt(info.dlpi_addr + phdr.p_vaddr))[0..phdr.p_memsz]; | |
| 1539 | 1539 | const name_size = mem.readIntSliceNative(u32, note_bytes[0..4]); |
| 1540 | 1540 | if (name_size != 4) continue; |
| 1541 | 1541 | const desc_size = mem.readIntSliceNative(u32, note_bytes[4..8]); |
| ... | ... | @@ -1545,7 +1545,7 @@ pub const DebugInfo = struct { |
| 1545 | 1545 | context.build_id = note_bytes[16..][0..desc_size]; |
| 1546 | 1546 | }, |
| 1547 | 1547 | elf.PT_GNU_EH_FRAME => { |
| 1548 | context.gnu_eh_frame = @ptrFromInt([*]const u8, info.dlpi_addr + phdr.p_vaddr)[0..phdr.p_memsz]; | |
| 1548 | context.gnu_eh_frame = @as([*]const u8, @ptrFromInt(info.dlpi_addr + phdr.p_vaddr))[0..phdr.p_memsz]; | |
| 1549 | 1549 | }, |
| 1550 | 1550 | else => {}, |
| 1551 | 1551 | } |
| ... | ... | @@ -2094,7 +2094,7 @@ fn dumpSegfaultInfoPosix(sig: i32, addr: usize, ctx_ptr: ?*const anyopaque) void |
| 2094 | 2094 | .arm, |
| 2095 | 2095 | .aarch64, |
| 2096 | 2096 | => { |
| 2097 | const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); | |
| 2097 | const ctx: *const os.ucontext_t = @ptrCast(@alignCast(ctx_ptr)); | |
| 2098 | 2098 | dumpStackTraceFromBase(ctx); |
| 2099 | 2099 | }, |
| 2100 | 2100 | else => {}, |
lib/std/dwarf.zig+8-12| ... | ... | @@ -1538,9 +1538,7 @@ pub const DwarfInfo = struct { |
| 1538 | 1538 | .cie => { |
| 1539 | 1539 | const cie = try CommonInformationEntry.parse( |
| 1540 | 1540 | entry_header.entry_bytes, |
| 1541 | -@intCast(isize, @intFromPtr(binary_mem.ptr)), | |
| 1542 | //@ptrToInt(eh_frame.ptr), | |
| 1543 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), | |
| 1541 | -@as(i64, @intCast(@intFromPtr(binary_mem.ptr))), | |
| 1544 | 1542 | true, |
| 1545 | 1543 | entry_header.length_offset, |
| 1546 | 1544 | @sizeOf(usize), |
| ... | ... | @@ -1552,9 +1550,7 @@ pub const DwarfInfo = struct { |
| 1552 | 1550 | const cie = di.cie_map.get(cie_offset) orelse return badDwarf(); |
| 1553 | 1551 | const fde = try FrameDescriptionEntry.parse( |
| 1554 | 1552 | entry_header.entry_bytes, |
| 1555 | -@intCast(isize, @intFromPtr(binary_mem.ptr)), | |
| 1556 | //@ptrToInt(eh_frame.ptr), | |
| 1557 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), | |
| 1553 | -@as(i64, @intCast(@intFromPtr(binary_mem.ptr))), | |
| 1558 | 1554 | true, |
| 1559 | 1555 | cie, |
| 1560 | 1556 | @sizeOf(usize), |
| ... | ... | @@ -1783,10 +1779,10 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo |
| 1783 | 1779 | }; |
| 1784 | 1780 | |
| 1785 | 1781 | const ptr = if (base) |b| switch (value) { |
| 1786 | .signed => |s| @intCast(u64, s + @intCast(i64, b)), | |
| 1782 | .signed => |s| @as(u64, @intCast(s + @as(i64, @intCast(b)))), | |
| 1787 | 1783 | .unsigned => |u| u + b, |
| 1788 | 1784 | } else switch (value) { |
| 1789 | .signed => |s| @intCast(u64, s), | |
| 1785 | .signed => |s| @as(u64, @intCast(s)), | |
| 1790 | 1786 | .unsigned => |u| u, |
| 1791 | 1787 | }; |
| 1792 | 1788 | |
| ... | ... | @@ -1798,7 +1794,7 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo |
| 1798 | 1794 | |
| 1799 | 1795 | const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow; |
| 1800 | 1796 | return switch (addr_size_bytes) { |
| 1801 | 2, 4, 8 => return @ptrFromInt(*const usize, native_ptr).*, | |
| 1797 | 2, 4, 8 => return @as(*const usize, @ptrFromInt(native_ptr)).*, | |
| 1802 | 1798 | else => return error.UnsupportedAddrSize, |
| 1803 | 1799 | }; |
| 1804 | 1800 | } else { |
| ... | ... | @@ -1903,7 +1899,7 @@ pub const ExceptionFrameHeader = struct { |
| 1903 | 1899 | if (self.isValidPtr(fde_ptr + 11, isValidMemory, eh_frame_len)) fde_entry_header_len = 12; |
| 1904 | 1900 | |
| 1905 | 1901 | // Even if eh_frame_len is not specified, all ranges accssed are checked by isValidPtr |
| 1906 | const eh_frame = @ptrFromInt([*]const u8, self.eh_frame_ptr)[0..eh_frame_len orelse math.maxInt(u32)]; | |
| 1902 | const eh_frame = @as([*]const u8, @ptrFromInt(self.eh_frame_ptr))[0 .. eh_frame_len orelse math.maxInt(u32)]; | |
| 1907 | 1903 | |
| 1908 | 1904 | const fde_offset = fde_ptr - self.eh_frame_ptr; |
| 1909 | 1905 | var eh_frame_stream = io.fixedBufferStream(eh_frame); |
| ... | ... | @@ -2248,8 +2244,8 @@ pub const FrameDescriptionEntry = struct { |
| 2248 | 2244 | |
| 2249 | 2245 | fn pcRelBase(field_ptr: usize, pc_rel_offset: i64) !usize { |
| 2250 | 2246 | if (pc_rel_offset < 0) { |
| 2251 | return math.sub(usize, field_ptr, @intCast(usize, -pc_rel_offset)); | |
| 2247 | return math.sub(usize, field_ptr, @as(usize, @intCast(-pc_rel_offset))); | |
| 2252 | 2248 | } else { |
| 2253 | return math.add(usize, field_ptr, @intCast(usize, pc_rel_offset)); | |
| 2249 | return math.add(usize, field_ptr, @as(usize, @intCast(pc_rel_offset))); | |
| 2254 | 2250 | } |
| 2255 | 2251 | } |
lib/std/dwarf/call_frame.zig+9-9| ... | ... | @@ -206,13 +206,13 @@ pub const Instruction = union(Opcode) { |
| 206 | 206 | ) !Instruction { |
| 207 | 207 | return switch (try stream.reader().readByte()) { |
| 208 | 208 | inline Opcode.lo_inline...Opcode.hi_inline => |opcode| blk: { |
| 209 | const e = @enumFromInt(Opcode, opcode & 0b11000000); | |
| 209 | const e: Opcode = @enumFromInt(opcode & 0b11000000); | |
| 210 | 210 | var result = @unionInit(Instruction, @tagName(e), undefined); |
| 211 | try result.readOperands(stream, @intCast(u6, opcode & 0b111111), addr_size_bytes, endian); | |
| 211 | try result.readOperands(stream, @as(u6, @intCast(opcode & 0b111111)), addr_size_bytes, endian); | |
| 212 | 212 | break :blk result; |
| 213 | 213 | }, |
| 214 | 214 | inline Opcode.lo_reserved...Opcode.hi_reserved => |opcode| blk: { |
| 215 | const e = @enumFromInt(Opcode, opcode); | |
| 215 | const e: Opcode = @enumFromInt(opcode); | |
| 216 | 216 | var result = @unionInit(Instruction, @tagName(e), undefined); |
| 217 | 217 | try result.readOperands(stream, null, addr_size_bytes, endian); |
| 218 | 218 | break :blk result; |
| ... | ... | @@ -234,9 +234,9 @@ pub const Instruction = union(Opcode) { |
| 234 | 234 | /// an error and fall back to FP-based unwinding. |
| 235 | 235 | pub fn applyOffset(base: usize, offset: i64) !usize { |
| 236 | 236 | return if (offset >= 0) |
| 237 | try std.math.add(usize, base, @intCast(usize, offset)) | |
| 237 | try std.math.add(usize, base, @as(usize, @intCast(offset))) | |
| 238 | 238 | else |
| 239 | try std.math.sub(usize, base, @intCast(usize, -offset)); | |
| 239 | try std.math.sub(usize, base, @as(usize, @intCast(-offset))); | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /// This is a virtual machine that runs DWARF call frame instructions. |
| ... | ... | @@ -304,7 +304,7 @@ pub const VirtualMachine = struct { |
| 304 | 304 | .same_value => {}, |
| 305 | 305 | .offset => |offset| { |
| 306 | 306 | if (context.cfa) |cfa| { |
| 307 | const ptr = @ptrFromInt(*const usize, try applyOffset(cfa, offset)); | |
| 307 | const ptr: *const usize = @ptrFromInt(try applyOffset(cfa, offset)); | |
| 308 | 308 | |
| 309 | 309 | // TODO: context.isValidMemory(ptr) |
| 310 | 310 | mem.writeIntSliceNative(usize, out, ptr.*); |
| ... | ... | @@ -480,7 +480,7 @@ pub const VirtualMachine = struct { |
| 480 | 480 | => |i| { |
| 481 | 481 | try self.resolveCopyOnWrite(allocator); |
| 482 | 482 | const column = try self.getOrAddColumn(allocator, i.operands.register); |
| 483 | column.rule = .{ .offset = @intCast(i64, i.operands.offset) * cie.data_alignment_factor }; | |
| 483 | column.rule = .{ .offset = @as(i64, @intCast(i.operands.offset)) * cie.data_alignment_factor }; | |
| 484 | 484 | }, |
| 485 | 485 | inline .restore, |
| 486 | 486 | .restore_extended, |
| ... | ... | @@ -526,7 +526,7 @@ pub const VirtualMachine = struct { |
| 526 | 526 | try self.resolveCopyOnWrite(allocator); |
| 527 | 527 | self.current_row.cfa = .{ |
| 528 | 528 | .register = i.operands.register, |
| 529 | .rule = .{ .val_offset = @intCast(i64, i.operands.offset) }, | |
| 529 | .rule = .{ .val_offset = @intCast(i.operands.offset) }, | |
| 530 | 530 | }; |
| 531 | 531 | }, |
| 532 | 532 | .def_cfa_sf => |i| { |
| ... | ... | @@ -544,7 +544,7 @@ pub const VirtualMachine = struct { |
| 544 | 544 | .def_cfa_offset => |i| { |
| 545 | 545 | try self.resolveCopyOnWrite(allocator); |
| 546 | 546 | if (self.current_row.cfa.register == null or self.current_row.cfa.rule != .val_offset) return error.InvalidOperation; |
| 547 | self.current_row.cfa.rule = .{ .val_offset = @intCast(i64, i.operands.offset) }; | |
| 547 | self.current_row.cfa.rule = .{ .val_offset = @intCast(i.operands.offset) }; | |
| 548 | 548 | }, |
| 549 | 549 | .def_cfa_offset_sf => |i| { |
| 550 | 550 | try self.resolveCopyOnWrite(allocator); |
lib/std/dwarf/expressions.zig+4-4| ... | ... | @@ -62,13 +62,13 @@ pub fn StackMachine(comptime options: StackMachineOptions) type { |
| 62 | 62 | const int_info = @typeInfo(@TypeOf(value)).Int; |
| 63 | 63 | if (@sizeOf(@TypeOf(value)) > options.addr_size) { |
| 64 | 64 | return .{ .generic = switch (int_info.signedness) { |
| 65 | .signed => @bitCast(addr_type, @truncate(addr_type_signed, value)), | |
| 66 | .unsigned => @truncate(addr_type, value), | |
| 65 | .signed => @bitCast(@as(addr_type_signed, @truncate(value))), | |
| 66 | .unsigned => @truncate(value), | |
| 67 | 67 | } }; |
| 68 | 68 | } else { |
| 69 | 69 | return .{ .generic = switch (int_info.signedness) { |
| 70 | .signed => @bitCast(addr_type, @intCast(addr_type_signed, value)), | |
| 71 | .unsigned => @intCast(addr_type, value), | |
| 70 | .signed => @bitCast(@as(addr_type_signed, @intCast(value))), | |
| 71 | .unsigned => @intCast(value), | |
| 72 | 72 | } }; |
| 73 | 73 | } |
| 74 | 74 | } |
src/crash_report.zig+1-1| ... | ... | @@ -207,7 +207,7 @@ fn handleSegfaultPosix(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const any |
| 207 | 207 | .x86_64, |
| 208 | 208 | .arm, |
| 209 | 209 | .aarch64, |
| 210 | => StackContext{ .exception = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)) }, | |
| 210 | => StackContext{ .exception = @ptrCast(@alignCast(ctx_ptr)) }, | |
| 211 | 211 | else => .not_supported, |
| 212 | 212 | }; |
| 213 | 213 |