| ... | @@ -145,6 +145,7 @@ pub const ResolveAddressesDwarfError = Dwarf.ScanError; | ... | @@ -145,6 +145,7 @@ pub const ResolveAddressesDwarfError = Dwarf.ScanError; |
| 145 | pub fn resolveAddressesDwarf( | 145 | pub fn resolveAddressesDwarf( |
| 146 | cov: *Coverage, | 146 | cov: *Coverage, |
| 147 | gpa: Allocator, | 147 | gpa: Allocator, |
| | 148 | /// Asserts the addresses are in ascending order. |
| 148 | sorted_pc_addrs: []const u64, | 149 | sorted_pc_addrs: []const u64, |
| 149 | /// Asserts its length equals length of `sorted_pc_addrs`. | 150 | /// Asserts its length equals length of `sorted_pc_addrs`. |
| 150 | output: []SourceLocation, | 151 | output: []SourceLocation, |
| ... | @@ -156,11 +157,15 @@ pub fn resolveAddressesDwarf( | ... | @@ -156,11 +157,15 @@ pub fn resolveAddressesDwarf( |
| 156 | var range_i: usize = 0; | 157 | var range_i: usize = 0; |
| 157 | var range: *std.debug.Dwarf.Range = &d.ranges.items[0]; | 158 | var range: *std.debug.Dwarf.Range = &d.ranges.items[0]; |
| 158 | var line_table_i: usize = undefined; | 159 | var line_table_i: usize = undefined; |
| | 160 | var prev_pc: u64 = 0; |
| 159 | var prev_cu: ?*std.debug.Dwarf.CompileUnit = null; | 161 | var prev_cu: ?*std.debug.Dwarf.CompileUnit = null; |
| 160 | // Protects directories and files tables from other threads. | 162 | // Protects directories and files tables from other threads. |
| 161 | cov.mutex.lock(); | 163 | cov.mutex.lock(); |
| 162 | defer cov.mutex.unlock(); | 164 | defer cov.mutex.unlock(); |
| 163 | next_pc: for (sorted_pc_addrs, output) |pc, *out| { | 165 | next_pc: for (sorted_pc_addrs, output) |pc, *out| { |
| | 166 | assert(pc >= prev_pc); |
| | 167 | prev_pc = pc; |
| | 168 | |
| 164 | while (pc >= range.end) { | 169 | while (pc >= range.end) { |
| 165 | range_i += 1; | 170 | range_i += 1; |
| 166 | if (range_i >= d.ranges.items.len) { | 171 | if (range_i >= d.ranges.items.len) { |