| ... | ... | @@ -257,13 +257,21 @@ pub const Attribute = struct { |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | pub fn getString(self: Attribute, ctx: DwarfInfo, cuh: CompileUnit.Header) ?[]const u8 { |
| 260 | | if (self.form != dwarf.FORM.strp) return null; |
| 261 | 260 | const debug_info = self.getDebugInfo(ctx); |
| 262 | | const off = if (cuh.is_64bit) |
| 263 | | mem.readIntLittle(u64, debug_info[0..8]) |
| 264 | | else |
| 265 | | mem.readIntLittle(u32, debug_info[0..4]); |
| 266 | | return ctx.getString(off); |
| 261 | |
| 262 | switch (self.form) { |
| 263 | dwarf.FORM.string => { |
| 264 | return mem.sliceTo(@ptrCast([*:0]const u8, debug_info.ptr), 0); |
| 265 | }, |
| 266 | dwarf.FORM.strp => { |
| 267 | const off = if (cuh.is_64bit) |
| 268 | mem.readIntLittle(u64, debug_info[0..8]) |
| 269 | else |
| 270 | mem.readIntLittle(u32, debug_info[0..4]); |
| 271 | return ctx.getString(off); |
| 272 | }, |
| 273 | else => return null, |
| 274 | } |
| 267 | 275 | } |
| 268 | 276 | |
| 269 | 277 | pub fn getConstant(self: Attribute, ctx: DwarfInfo) !?i128 { |
| ... | ... | @@ -440,8 +448,9 @@ fn findFormSize(self: DwarfInfo, form: u64, di_off: usize, cuh: CompileUnit.Head |
| 440 | 448 | |
| 441 | 449 | dwarf.FORM.string => { |
| 442 | 450 | var count: usize = 0; |
| 443 | | while (true) : (count += 1) { |
| 451 | while (true) { |
| 444 | 452 | const byte = try reader.readByte(); |
| 453 | count += 1; |
| 445 | 454 | if (byte == 0x0) break; |
| 446 | 455 | } |
| 447 | 456 | return count; |