| ... | @@ -27,7 +27,7 @@ const CompileUnitIterator = struct { | ... | @@ -27,7 +27,7 @@ const CompileUnitIterator = struct { |
| 27 | pub fn next(self: *CompileUnitIterator) !?CompileUnit { | 27 | pub fn next(self: *CompileUnitIterator) !?CompileUnit { |
| 28 | if (self.pos >= self.ctx.debug_info.len) return null; | 28 | if (self.pos >= self.ctx.debug_info.len) return null; |
| 29 | | 29 | |
| 30 | var stream = std.io.fixedBufferStream(self.ctx.debug_info); | 30 | var stream = std.io.fixedBufferStream(self.ctx.debug_info[self.pos..]); |
| 31 | var creader = std.io.countingReader(stream.reader()); | 31 | var creader = std.io.countingReader(stream.reader()); |
| 32 | const reader = creader.reader(); | 32 | const reader = creader.reader(); |
| 33 | | 33 | |
| ... | @@ -37,7 +37,7 @@ const CompileUnitIterator = struct { | ... | @@ -37,7 +37,7 @@ const CompileUnitIterator = struct { |
| 37 | | 37 | |
| 38 | const cu = CompileUnit{ | 38 | const cu = CompileUnit{ |
| 39 | .cuh = cuh, | 39 | .cuh = cuh, |
| 40 | .debug_info_off = offset, | 40 | .debug_info_off = self.pos + offset, |
| 41 | }; | 41 | }; |
| 42 | | 42 | |
| 43 | self.pos += (math.cast(usize, total_length) orelse return error.Overflow); | 43 | self.pos += (math.cast(usize, total_length) orelse return error.Overflow); |
| ... | @@ -188,7 +188,7 @@ const AbbrevEntryIterator = struct { | ... | @@ -188,7 +188,7 @@ const AbbrevEntryIterator = struct { |
| 188 | return AbbrevEntry.null(); | 188 | return AbbrevEntry.null(); |
| 189 | } | 189 | } |
| 190 | | 190 | |
| 191 | const abbrev_pos = lookup.get(kind) orelse return error.MalformedDwarf; | 191 | const abbrev_pos = lookup.get(kind) orelse return null; |
| 192 | const len = try findAbbrevEntrySize( | 192 | const len = try findAbbrevEntrySize( |
| 193 | self.ctx, | 193 | self.ctx, |
| 194 | abbrev_pos.pos, | 194 | abbrev_pos.pos, |
| ... | @@ -290,21 +290,6 @@ pub const Attribute = struct { | ... | @@ -290,21 +290,6 @@ pub const Attribute = struct { |
| 290 | }; | 290 | }; |
| 291 | } | 291 | } |
| 292 | | 292 | |
| 293 | pub fn getReference(self: Attribute, ctx: DwarfInfo) !?u64 { | | |
| 294 | const debug_info = self.getDebugInfo(ctx); | | |
| 295 | var stream = std.io.fixedBufferStream(debug_info); | | |
| 296 | const reader = stream.reader(); | | |
| 297 | | | |
| 298 | return switch (self.form) { | | |
| 299 | dwarf.FORM.ref1 => debug_info[0], | | |
| 300 | dwarf.FORM.ref2 => mem.readIntLittle(u16, debug_info[0..2]), | | |
| 301 | dwarf.FORM.ref4 => mem.readIntLittle(u32, debug_info[0..4]), | | |
| 302 | dwarf.FORM.ref8 => mem.readIntLittle(u64, debug_info[0..8]), | | |
| 303 | dwarf.FORM.ref_udata => try leb.readULEB128(u64, reader), | | |
| 304 | else => null, | | |
| 305 | }; | | |
| 306 | } | | |
| 307 | | | |
| 308 | pub fn getAddr(self: Attribute, ctx: DwarfInfo, cuh: CompileUnit.Header) ?u64 { | 293 | pub fn getAddr(self: Attribute, ctx: DwarfInfo, cuh: CompileUnit.Header) ?u64 { |
| 309 | if (self.form != dwarf.FORM.addr) return null; | 294 | if (self.form != dwarf.FORM.addr) return null; |
| 310 | const debug_info = self.getDebugInfo(ctx); | 295 | const debug_info = self.getDebugInfo(ctx); |