mirror of
https://github.com/ziglang/zig.git
synced 2025-02-08 13:40:30 +00:00
avoid a branch in resolveAddressesDwarf
This commit is contained in:
parent
e8e49efe21
commit
a9e7fb0e01
@ -664,8 +664,8 @@ fn addEntryPoint(ws: *WebServer, coverage_id: u64, addr: u64) error{ AlreadyRepo
|
||||
if (false) {
|
||||
const sl = coverage_map.source_locations[index];
|
||||
const file_name = coverage_map.coverage.stringAt(coverage_map.coverage.fileAt(sl.file).basename);
|
||||
log.debug("server found entry point {s}:{d}:{d}", .{
|
||||
file_name, sl.line, sl.column,
|
||||
log.debug("server found entry point for 0x{x} at {s}:{d}:{d}", .{
|
||||
addr, file_name, sl.line, sl.column,
|
||||
});
|
||||
}
|
||||
const gpa = ws.gpa;
|
||||
|
@ -174,28 +174,30 @@ pub fn resolveAddressesDwarf(
|
||||
continue :next_pc;
|
||||
}
|
||||
const cu = &d.compile_unit_list.items[range.compile_unit_index];
|
||||
if (cu.src_loc_cache == null) {
|
||||
cov.mutex.unlock();
|
||||
defer cov.mutex.lock();
|
||||
d.populateSrcLocCache(gpa, cu) catch |err| switch (err) {
|
||||
error.MissingDebugInfo, error.InvalidDebugInfo => {
|
||||
out.* = SourceLocation.invalid;
|
||||
continue :next_pc;
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
}
|
||||
const slc = &cu.src_loc_cache.?;
|
||||
const table_addrs = slc.line_table.keys();
|
||||
if (cu != prev_cu) {
|
||||
prev_cu = cu;
|
||||
if (cu.src_loc_cache == null) {
|
||||
cov.mutex.unlock();
|
||||
defer cov.mutex.lock();
|
||||
d.populateSrcLocCache(gpa, cu) catch |err| switch (err) {
|
||||
error.MissingDebugInfo, error.InvalidDebugInfo => {
|
||||
out.* = SourceLocation.invalid;
|
||||
continue :next_pc;
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
}
|
||||
const slc = &cu.src_loc_cache.?;
|
||||
const table_addrs = slc.line_table.keys();
|
||||
line_table_i = std.sort.upperBound(u64, table_addrs, pc, struct {
|
||||
fn order(context: u64, item: u64) std.math.Order {
|
||||
return std.math.order(item, context);
|
||||
}
|
||||
}.order);
|
||||
}
|
||||
while (line_table_i < table_addrs.len and table_addrs[line_table_i] < pc) line_table_i += 1;
|
||||
const slc = &cu.src_loc_cache.?;
|
||||
const table_addrs = slc.line_table.keys();
|
||||
while (line_table_i < table_addrs.len and table_addrs[line_table_i] <= pc) line_table_i += 1;
|
||||
|
||||
const entry = slc.line_table.values()[line_table_i - 1];
|
||||
const corrected_file_index = entry.file - @intFromBool(slc.version < 5);
|
||||
|
Loading…
Reference in New Issue
Block a user