authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-02 23:38:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-07 00:48:32-07:00
logc2ab4614b69a2303d640837df357c2336b0cedf2
treec62d3ac773bd0c3e3c8d5d21e4e1da03193531ac
parent1792258dc813cde7083fd7860442e6ec92afd4ba

std.Debug.Info: remove std.Progress integration

it's too fast to need it now

3 files changed, 4 insertions(+), 17 deletions(-)

lib/std/debug/Dwarf.zig-5
...@@ -2354,19 +2354,14 @@ pub fn resolveSourceLocations(...@@ -2354,19 +2354,14 @@ pub fn resolveSourceLocations(
2354 sorted_pc_addrs: []const u64,2354 sorted_pc_addrs: []const u64,
2355 /// Asserts its length equals length of `sorted_pc_addrs`.2355 /// Asserts its length equals length of `sorted_pc_addrs`.
2356 output: []std.debug.SourceLocation,2356 output: []std.debug.SourceLocation,
2357 parent_prog_node: std.Progress.Node,
2358) ResolveSourceLocationsError!void {2357) ResolveSourceLocationsError!void {
2359 assert(sorted_pc_addrs.len == output.len);2358 assert(sorted_pc_addrs.len == output.len);
2360 assert(d.compile_units_sorted);2359 assert(d.compile_units_sorted);
23612360
2362 const prog_node = parent_prog_node.start("Resolve Source Locations", sorted_pc_addrs.len);
2363 defer prog_node.end();
2364
2365 var cu_i: usize = 0;2361 var cu_i: usize = 0;
2366 var cu: *CompileUnit = &d.compile_unit_list.items[0];2362 var cu: *CompileUnit = &d.compile_unit_list.items[0];
2367 var range = cu.pc_range.?;2363 var range = cu.pc_range.?;
2368 next_pc: for (sorted_pc_addrs, output) |pc, *out| {2364 next_pc: for (sorted_pc_addrs, output) |pc, *out| {
2369 defer prog_node.completeOne();
2370 while (pc >= range.end) {2365 while (pc >= range.end) {
2371 cu_i += 1;2366 cu_i += 1;
2372 if (cu_i >= d.compile_unit_list.items.len) {2367 if (cu_i >= d.compile_unit_list.items.len) {
lib/std/debug/Info.zig+2-7
...@@ -20,13 +20,9 @@ address_map: std.AutoArrayHashMapUnmanaged(u64, Dwarf.ElfModule),...@@ -20,13 +20,9 @@ address_map: std.AutoArrayHashMapUnmanaged(u64, Dwarf.ElfModule),
2020
21pub const LoadError = Dwarf.ElfModule.LoadError;21pub const LoadError = Dwarf.ElfModule.LoadError;
2222
23pub fn load(gpa: Allocator, path: Path, parent_prog_node: std.Progress.Node) LoadError!Info {23pub fn load(gpa: Allocator, path: Path) LoadError!Info {
24 var sections: Dwarf.SectionArray = Dwarf.null_section_array;24 var sections: Dwarf.SectionArray = Dwarf.null_section_array;
25 var prog_node = parent_prog_node.start("Loading Debug Info", 0);
26 defer prog_node.end();
27 var elf_module = try Dwarf.ElfModule.loadPath(gpa, path, null, null, &sections, null);25 var elf_module = try Dwarf.ElfModule.loadPath(gpa, path, null, null, &sections, null);
28 prog_node.end();
29 prog_node = parent_prog_node.start("Sort Compile Units", 0);
30 try elf_module.dwarf.sortCompileUnits();26 try elf_module.dwarf.sortCompileUnits();
31 var info: Info = .{27 var info: Info = .{
32 .address_map = .{},28 .address_map = .{},
...@@ -51,10 +47,9 @@ pub fn resolveSourceLocations(...@@ -51,10 +47,9 @@ pub fn resolveSourceLocations(
51 sorted_pc_addrs: []const u64,47 sorted_pc_addrs: []const u64,
52 /// Asserts its length equals length of `sorted_pc_addrs`.48 /// Asserts its length equals length of `sorted_pc_addrs`.
53 output: []std.debug.SourceLocation,49 output: []std.debug.SourceLocation,
54 parent_prog_node: std.Progress.Node,
55) ResolveSourceLocationsError!void {50) ResolveSourceLocationsError!void {
56 assert(sorted_pc_addrs.len == output.len);51 assert(sorted_pc_addrs.len == output.len);
57 if (info.address_map.entries.len != 1) @panic("TODO");52 if (info.address_map.entries.len != 1) @panic("TODO");
58 const elf_module = &info.address_map.values()[0];53 const elf_module = &info.address_map.values()[0];
59 return elf_module.dwarf.resolveSourceLocations(gpa, sorted_pc_addrs, output, parent_prog_node);54 return elf_module.dwarf.resolveSourceLocations(gpa, sorted_pc_addrs, output);
60}55}
tools/dump-cov.zig+2-5
...@@ -28,10 +28,7 @@ pub fn main() !void {...@@ -28,10 +28,7 @@ pub fn main() !void {
28 .sub_path = cov_file_name,28 .sub_path = cov_file_name,
29 };29 };
3030
31 const prog_node = std.Progress.start(.{});31 var debug_info = std.debug.Info.load(gpa, exe_path) catch |err| {
32 defer prog_node.end();
33
34 var debug_info = std.debug.Info.load(gpa, exe_path, prog_node) catch |err| {
35 fatal("failed to load debug info for {}: {s}", .{ exe_path, @errorName(err) });32 fatal("failed to load debug info for {}: {s}", .{ exe_path, @errorName(err) });
36 };33 };
37 defer debug_info.deinit(gpa);34 defer debug_info.deinit(gpa);
...@@ -54,7 +51,7 @@ pub fn main() !void {...@@ -54,7 +51,7 @@ pub fn main() !void {
54 assert(std.sort.isSorted(usize, pcs, {}, std.sort.asc(usize)));51 assert(std.sort.isSorted(usize, pcs, {}, std.sort.asc(usize)));
5552
56 const source_locations = try arena.alloc(std.debug.SourceLocation, pcs.len);53 const source_locations = try arena.alloc(std.debug.SourceLocation, pcs.len);
57 try debug_info.resolveSourceLocations(gpa, pcs, source_locations, prog_node);54 try debug_info.resolveSourceLocations(gpa, pcs, source_locations);
58 defer for (source_locations) |sl| {55 defer for (source_locations) |sl| {
59 gpa.free(sl.file_name);56 gpa.free(sl.file_name);
60 };57 };