mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
delete std.debug.FixedBufferReader
now that std.Io.Reader has sufficient debug performance
This commit is contained in:
parent
afea419470
commit
12686d9b7d
@ -14,7 +14,6 @@ const native_os = builtin.os.tag;
|
||||
const native_endian = native_arch.endian();
|
||||
const Writer = std.io.Writer;
|
||||
|
||||
pub const FixedBufferReader = @import("debug/FixedBufferReader.zig");
|
||||
pub const Dwarf = @import("debug/Dwarf.zig");
|
||||
pub const Pdb = @import("debug/Pdb.zig");
|
||||
pub const SelfInfo = @import("debug/SelfInfo.zig");
|
||||
@ -1773,7 +1772,6 @@ pub inline fn inValgrind() bool {
|
||||
|
||||
test {
|
||||
_ = &Dwarf;
|
||||
_ = &FixedBufferReader;
|
||||
_ = &Pdb;
|
||||
_ = &SelfInfo;
|
||||
_ = &dumpHex;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,70 +0,0 @@
|
||||
//! Optimized for performance in debug builds.
|
||||
|
||||
const std = @import("../std.zig");
|
||||
|
||||
const FixedBufferReader = @This();
|
||||
|
||||
buf: []const u8,
|
||||
pos: usize = 0,
|
||||
endian: std.builtin.Endian,
|
||||
|
||||
pub const Error = error{ EndOfBuffer, Overflow, InvalidBuffer };
|
||||
|
||||
pub fn seekTo(fbr: *FixedBufferReader, pos: u64) Error!void {
|
||||
if (pos > fbr.buf.len) return error.EndOfBuffer;
|
||||
fbr.pos = @intCast(pos);
|
||||
}
|
||||
|
||||
pub fn seekForward(fbr: *FixedBufferReader, amount: u64) Error!void {
|
||||
if (fbr.buf.len - fbr.pos < amount) return error.EndOfBuffer;
|
||||
fbr.pos += @intCast(amount);
|
||||
}
|
||||
|
||||
pub inline fn readByte(fbr: *FixedBufferReader) Error!u8 {
|
||||
if (fbr.pos >= fbr.buf.len) return error.EndOfBuffer;
|
||||
defer fbr.pos += 1;
|
||||
return fbr.buf[fbr.pos];
|
||||
}
|
||||
|
||||
pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 {
|
||||
return @bitCast(try fbr.readByte());
|
||||
}
|
||||
|
||||
pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T {
|
||||
const size = @divExact(@typeInfo(T).int.bits, 8);
|
||||
if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer;
|
||||
defer fbr.pos += size;
|
||||
return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian);
|
||||
}
|
||||
|
||||
pub fn readUleb128(fbr: *FixedBufferReader, comptime T: type) Error!T {
|
||||
return std.leb.readUleb128(T, fbr);
|
||||
}
|
||||
|
||||
pub fn readIleb128(fbr: *FixedBufferReader, comptime T: type) Error!T {
|
||||
return std.leb.readIleb128(T, fbr);
|
||||
}
|
||||
|
||||
pub fn readAddress(fbr: *FixedBufferReader, format: std.dwarf.Format) Error!u64 {
|
||||
return switch (format) {
|
||||
.@"32" => try fbr.readInt(u32),
|
||||
.@"64" => try fbr.readInt(u64),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn readBytes(fbr: *FixedBufferReader, len: usize) Error![]const u8 {
|
||||
if (fbr.buf.len - fbr.pos < len) return error.EndOfBuffer;
|
||||
defer fbr.pos += len;
|
||||
return fbr.buf[fbr.pos..][0..len];
|
||||
}
|
||||
|
||||
pub fn readBytesTo(fbr: *FixedBufferReader, comptime sentinel: u8) Error![:sentinel]const u8 {
|
||||
const end = @call(.always_inline, std.mem.indexOfScalarPos, .{
|
||||
u8,
|
||||
fbr.buf,
|
||||
fbr.pos,
|
||||
sentinel,
|
||||
}) orelse return error.EndOfBuffer;
|
||||
defer fbr.pos = end + 1;
|
||||
return fbr.buf[fbr.pos..end :sentinel];
|
||||
}
|
||||
@ -1555,26 +1555,24 @@ pub fn unwindFrameDwarf(
|
||||
if (!supports_unwinding) return error.UnsupportedCpuArchitecture;
|
||||
if (context.pc == 0) return 0;
|
||||
|
||||
const endian = di.endian;
|
||||
|
||||
// Find the FDE and CIE
|
||||
const cie, const fde = if (explicit_fde_offset) |fde_offset| blk: {
|
||||
const dwarf_section: Dwarf.Section.Id = .eh_frame;
|
||||
const frame_section = di.section(dwarf_section) orelse return error.MissingFDE;
|
||||
if (fde_offset >= frame_section.len) return error.MissingFDE;
|
||||
|
||||
var fbr: std.debug.FixedBufferReader = .{
|
||||
.buf = frame_section,
|
||||
.pos = fde_offset,
|
||||
.endian = di.endian,
|
||||
};
|
||||
var fbr: std.Io.Reader = .fixed(frame_section);
|
||||
fbr.seek = fde_offset;
|
||||
|
||||
const fde_entry_header = try Dwarf.EntryHeader.read(&fbr, dwarf_section);
|
||||
const fde_entry_header = try Dwarf.EntryHeader.read(&fbr, dwarf_section, endian);
|
||||
if (fde_entry_header.type != .fde) return error.MissingFDE;
|
||||
|
||||
const cie_offset = fde_entry_header.type.fde;
|
||||
try fbr.seekTo(cie_offset);
|
||||
fbr.seek = @intCast(cie_offset);
|
||||
|
||||
fbr.endian = native_endian;
|
||||
const cie_entry_header = try Dwarf.EntryHeader.read(&fbr, dwarf_section);
|
||||
const cie_entry_header = try Dwarf.EntryHeader.read(&fbr, dwarf_section, endian);
|
||||
if (cie_entry_header.type != .cie) return Dwarf.bad();
|
||||
|
||||
const cie = try Dwarf.CommonInformationEntry.parse(
|
||||
@ -1617,6 +1615,7 @@ pub fn unwindFrameDwarf(
|
||||
context.pc,
|
||||
&cie,
|
||||
&fde,
|
||||
endian,
|
||||
) catch |err| switch (err) {
|
||||
error.MissingDebugInfo => {
|
||||
// `.eh_frame_hdr` appears to be incomplete, so go ahead and populate `cie_map`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user