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