| author | |
| committer | |
| log | ac4d633ed691159ea61130182a1b51635a95e228 |
| tree | 74e812bb31ea93d5499d63e81a41eb48a1394005 |
| parent | f40fbdb3b300233a2fc880bad77c986259c38b0f |
| signature |
3 files changed, 12 insertions(+), 8 deletions(-)
lib/std/debug/Coverage.zig+2-1| ... | ... | @@ -145,6 +145,7 @@ pub const ResolveAddressesDwarfError = Dwarf.ScanError; |
| 145 | 145 | pub fn resolveAddressesDwarf( |
| 146 | 146 | cov: *Coverage, |
| 147 | 147 | gpa: Allocator, |
| 148 | endian: std.builtin.Endian, | |
| 148 | 149 | /// Asserts the addresses are in ascending order. |
| 149 | 150 | sorted_pc_addrs: []const u64, |
| 150 | 151 | /// Asserts its length equals length of `sorted_pc_addrs`. |
| ... | ... | @@ -184,7 +185,7 @@ pub fn resolveAddressesDwarf( |
| 184 | 185 | if (cu.src_loc_cache == null) { |
| 185 | 186 | cov.mutex.unlock(); |
| 186 | 187 | defer cov.mutex.lock(); |
| 187 | d.populateSrcLocCache(gpa, cu) catch |err| switch (err) { | |
| 188 | d.populateSrcLocCache(gpa, endian, cu) catch |err| switch (err) { | |
| 188 | 189 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| 189 | 190 | out.* = SourceLocation.invalid; |
| 190 | 191 | continue :next_pc; |
lib/std/debug/Dwarf.zig+2-2| ... | ... | @@ -652,7 +652,7 @@ fn scanAllCompileUnits(di: *Dwarf, allocator: Allocator, endian: Endian) ScanErr |
| 652 | 652 | } |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | pub fn populateRanges(d: *Dwarf, gpa: Allocator) ScanError!void { | |
| 655 | pub fn populateRanges(d: *Dwarf, gpa: Allocator, endian: Endian) ScanError!void { | |
| 656 | 656 | assert(d.ranges.items.len == 0); |
| 657 | 657 | |
| 658 | 658 | for (d.compile_unit_list.items, 0..) |*cu, cu_index| { |
| ... | ... | @@ -665,7 +665,7 @@ pub fn populateRanges(d: *Dwarf, gpa: Allocator) ScanError!void { |
| 665 | 665 | continue; |
| 666 | 666 | } |
| 667 | 667 | const ranges_value = cu.die.getAttr(AT.ranges) orelse continue; |
| 668 | var iter = DebugRangeIterator.init(ranges_value, d, cu) catch continue; | |
| 668 | var iter = DebugRangeIterator.init(ranges_value, d, endian, cu) catch continue; | |
| 669 | 669 | while (try iter.next()) |range| { |
| 670 | 670 | // Not sure why LLVM thinks it's OK to emit these... |
| 671 | 671 | if (range.start == range.end) continue; |
lib/std/debug/Info.zig+8-5| ... | ... | @@ -24,14 +24,15 @@ coverage: *Coverage, |
| 24 | 24 | pub const LoadError = Dwarf.ElfModule.LoadError; |
| 25 | 25 | |
| 26 | 26 | pub fn load(gpa: Allocator, path: Path, coverage: *Coverage) LoadError!Info { |
| 27 | var sections: Dwarf.SectionArray = Dwarf.null_section_array; | |
| 28 | var elf_module = try Dwarf.ElfModule.load(gpa, path, null, null, &sections, null); | |
| 29 | try elf_module.dwarf.populateRanges(gpa); | |
| 27 | var elf_module = try Dwarf.ElfModule.load(gpa, path, null, null, null, null); | |
| 28 | // This is correct because `Dwarf.ElfModule` currently only supports native-endian ELF files. | |
| 29 | const endian = @import("builtin").target.cpu.arch.endian(); | |
| 30 | try elf_module.dwarf.populateRanges(gpa, endian); | |
| 30 | 31 | var info: Info = .{ |
| 31 | 32 | .address_map = .{}, |
| 32 | 33 | .coverage = coverage, |
| 33 | 34 | }; |
| 34 | try info.address_map.put(gpa, elf_module.base_address, elf_module); | |
| 35 | try info.address_map.put(gpa, 0, elf_module); | |
| 35 | 36 | return info; |
| 36 | 37 | } |
| 37 | 38 | |
| ... | ... | @@ -58,5 +59,7 @@ pub fn resolveAddresses( |
| 58 | 59 | assert(sorted_pc_addrs.len == output.len); |
| 59 | 60 | if (info.address_map.entries.len != 1) @panic("TODO"); |
| 60 | 61 | const elf_module = &info.address_map.values()[0]; |
| 61 | return info.coverage.resolveAddressesDwarf(gpa, sorted_pc_addrs, output, &elf_module.dwarf); | |
| 62 | // This is correct because `Dwarf.ElfModule` currently only supports native-endian ELF files. | |
| 63 | const endian = @import("builtin").target.cpu.arch.endian(); | |
| 64 | return info.coverage.resolveAddressesDwarf(gpa, endian, sorted_pc_addrs, output, &elf_module.dwarf); | |
| 62 | 65 | } |