mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
std.debug.Coverage.resolveAddressesDwarf: assert sorted
This commit is contained in:
parent
022bca9b06
commit
a726e09389
@ -145,6 +145,7 @@ pub const ResolveAddressesDwarfError = Dwarf.ScanError;
|
|||||||
pub fn resolveAddressesDwarf(
|
pub fn resolveAddressesDwarf(
|
||||||
cov: *Coverage,
|
cov: *Coverage,
|
||||||
gpa: Allocator,
|
gpa: Allocator,
|
||||||
|
/// Asserts the addresses are in ascending order.
|
||||||
sorted_pc_addrs: []const u64,
|
sorted_pc_addrs: []const u64,
|
||||||
/// Asserts its length equals length of `sorted_pc_addrs`.
|
/// Asserts its length equals length of `sorted_pc_addrs`.
|
||||||
output: []SourceLocation,
|
output: []SourceLocation,
|
||||||
@ -156,11 +157,15 @@ pub fn resolveAddressesDwarf(
|
|||||||
var range_i: usize = 0;
|
var range_i: usize = 0;
|
||||||
var range: *std.debug.Dwarf.Range = &d.ranges.items[0];
|
var range: *std.debug.Dwarf.Range = &d.ranges.items[0];
|
||||||
var line_table_i: usize = undefined;
|
var line_table_i: usize = undefined;
|
||||||
|
var prev_pc: u64 = 0;
|
||||||
var prev_cu: ?*std.debug.Dwarf.CompileUnit = null;
|
var prev_cu: ?*std.debug.Dwarf.CompileUnit = null;
|
||||||
// Protects directories and files tables from other threads.
|
// Protects directories and files tables from other threads.
|
||||||
cov.mutex.lock();
|
cov.mutex.lock();
|
||||||
defer cov.mutex.unlock();
|
defer cov.mutex.unlock();
|
||||||
next_pc: for (sorted_pc_addrs, output) |pc, *out| {
|
next_pc: for (sorted_pc_addrs, output) |pc, *out| {
|
||||||
|
assert(pc >= prev_pc);
|
||||||
|
prev_pc = pc;
|
||||||
|
|
||||||
while (pc >= range.end) {
|
while (pc >= range.end) {
|
||||||
range_i += 1;
|
range_i += 1;
|
||||||
if (range_i >= d.ranges.items.len) {
|
if (range_i >= d.ranges.items.len) {
|
||||||
|
|||||||
@ -51,6 +51,7 @@ pub const ResolveAddressesError = Coverage.ResolveAddressesDwarfError;
|
|||||||
pub fn resolveAddresses(
|
pub fn resolveAddresses(
|
||||||
info: *Info,
|
info: *Info,
|
||||||
gpa: Allocator,
|
gpa: Allocator,
|
||||||
|
/// Asserts the addresses are in ascending order.
|
||||||
sorted_pc_addrs: []const u64,
|
sorted_pc_addrs: []const u64,
|
||||||
/// Asserts its length equals length of `sorted_pc_addrs`.
|
/// Asserts its length equals length of `sorted_pc_addrs`.
|
||||||
output: []SourceLocation,
|
output: []SourceLocation,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user