authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-01 11:58:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-01 13:47:42-07:00
log377274ee9ab270886cce1ceaf5ffeddaefd9c239
tree28a33a763ff9ce2a045992badb106b7455213e50
parent9c84b5cc18b6f78d1eec25432c3cd2988edb83ed

std.debug.DebugInfo: rename to std.debug.Info

avoiding redundancy in the fully qualified namespace

1 files changed, 30 insertions(+), 30 deletions(-)

lib/std/debug.zig+30-30
......@@ -102,9 +102,9 @@ pub fn getStderrMutex() *std.Thread.Mutex {
102102}
103103
104104/// TODO multithreaded awareness
105var self_debug_info: ?DebugInfo = null;
105var self_debug_info: ?Info = null;
106106
107pub fn getSelfDebugInfo() !*DebugInfo {
107pub fn getSelfDebugInfo() !*Info {
108108 if (self_debug_info) |*info| {
109109 return info;
110110 } else {
......@@ -346,7 +346,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackT
346346 stack_trace.index = slice.len;
347347 } else {
348348 // TODO: This should use the DWARF unwinder if .eh_frame_hdr is available (so that full debug info parsing isn't required).
349 // A new path for loading DebugInfo needs to be created which will only attempt to parse in-memory sections, because
349 // A new path for loading Info needs to be created which will only attempt to parse in-memory sections, because
350350 // stopping to load other debug info (ie. source line info) from disk here is not required for unwinding.
351351 var it = StackIterator.init(first_address, null);
352352 defer it.deinit();
......@@ -524,7 +524,7 @@ pub fn writeStackTrace(
524524 stack_trace: std.builtin.StackTrace,
525525 out_stream: anytype,
526526 allocator: mem.Allocator,
527 debug_info: *DebugInfo,
527 debug_info: *Info,
528528 tty_config: io.tty.Config,
529529) !void {
530530 _ = allocator;
......@@ -561,11 +561,11 @@ pub const StackIterator = struct {
561561 fp: usize,
562562 ma: MemoryAccessor = MemoryAccessor.init,
563563
564 // When DebugInfo and a register context is available, this iterator can unwind
564 // When Info and a register context is available, this iterator can unwind
565565 // stacks with frames that don't use a frame pointer (ie. -fomit-frame-pointer),
566566 // using DWARF and MachO unwind info.
567567 unwind_state: if (have_ucontext) ?struct {
568 debug_info: *DebugInfo,
568 debug_info: *Info,
569569 dwarf_context: DW.UnwindContext,
570570 last_error: ?UnwindError = null,
571571 failed: bool = false,
......@@ -590,7 +590,7 @@ pub const StackIterator = struct {
590590 };
591591 }
592592
593 pub fn initWithContext(first_address: ?usize, debug_info: *DebugInfo, context: *const posix.ucontext_t) !StackIterator {
593 pub fn initWithContext(first_address: ?usize, debug_info: *Info, context: *const posix.ucontext_t) !StackIterator {
594594 // The implementation of DWARF unwinding on aarch64-macos is not complete. However, Apple mandates that
595595 // the frame pointer register is always used, so on this platform we can safely use the FP-based unwinder.
596596 if (comptime builtin.target.isDarwin() and native_arch == .aarch64) {
......@@ -850,7 +850,7 @@ const have_msync = switch (native_os) {
850850
851851pub fn writeCurrentStackTrace(
852852 out_stream: anytype,
853 debug_info: *DebugInfo,
853 debug_info: *Info,
854854 tty_config: io.tty.Config,
855855 start_addr: ?usize,
856856) !void {
......@@ -936,7 +936,7 @@ pub noinline fn walkStackWindows(addresses: []usize, existing_context: ?*const w
936936
937937pub fn writeStackTraceWindows(
938938 out_stream: anytype,
939 debug_info: *DebugInfo,
939 debug_info: *Info,
940940 tty_config: io.tty.Config,
941941 context: *const windows.CONTEXT,
942942 start_addr: ?usize,
......@@ -1000,7 +1000,7 @@ test machoSearchSymbols {
10001000 try testing.expectEqual(&symbols[2], machoSearchSymbols(&symbols, 5000).?);
10011001}
10021002
1003fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: io.tty.Config) !void {
1003fn printUnknownSource(debug_info: *Info, out_stream: anytype, address: usize, tty_config: io.tty.Config) !void {
10041004 const module_name = debug_info.getModuleNameForAddress(address);
10051005 return printLineInfo(
10061006 out_stream,
......@@ -1013,14 +1013,14 @@ fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usiz
10131013 );
10141014}
10151015
1016fn printLastUnwindError(it: *StackIterator, debug_info: *DebugInfo, out_stream: anytype, tty_config: io.tty.Config) void {
1016fn printLastUnwindError(it: *StackIterator, debug_info: *Info, out_stream: anytype, tty_config: io.tty.Config) void {
10171017 if (!have_ucontext) return;
10181018 if (it.getLastError()) |unwind_error| {
10191019 printUnwindError(debug_info, out_stream, unwind_error.address, unwind_error.err, tty_config) catch {};
10201020 }
10211021}
10221022
1023fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void {
1023fn printUnwindError(debug_info: *Info, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void {
10241024 const module_name = debug_info.getModuleNameForAddress(address) orelse "???";
10251025 try tty_config.setColor(out_stream, .dim);
10261026 if (err == error.MissingDebugInfo) {
......@@ -1031,7 +1031,7 @@ fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize,
10311031 try tty_config.setColor(out_stream, .reset);
10321032}
10331033
1034pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: io.tty.Config) !void {
1034pub fn printSourceAtAddress(debug_info: *Info, out_stream: anytype, address: usize, tty_config: io.tty.Config) !void {
10351035 const module = debug_info.getModuleForAddress(address) catch |err| switch (err) {
10361036 error.MissingDebugInfo, error.InvalidDebugInfo => return printUnknownSource(debug_info, out_stream, address, tty_config),
10371037 else => return err,
......@@ -1105,9 +1105,9 @@ fn printLineInfo(
11051105pub const OpenSelfDebugInfoError = error{
11061106 MissingDebugInfo,
11071107 UnsupportedOperatingSystem,
1108} || @typeInfo(@typeInfo(@TypeOf(DebugInfo.init)).Fn.return_type.?).ErrorUnion.error_set;
1108} || @typeInfo(@typeInfo(@TypeOf(Info.init)).Fn.return_type.?).ErrorUnion.error_set;
11091109
1110pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugInfo {
1110pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!Info {
11111111 nosuspend {
11121112 if (builtin.strip_debug_info)
11131113 return error.MissingDebugInfo;
......@@ -1124,7 +1124,7 @@ pub fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugI
11241124 .solaris,
11251125 .illumos,
11261126 .windows,
1127 => return try DebugInfo.init(allocator),
1127 => return try Info.init(allocator),
11281128 else => return error.UnsupportedOperatingSystem,
11291129 }
11301130 }
......@@ -1759,13 +1759,13 @@ pub const WindowsModuleInfo = struct {
17591759 } = null,
17601760};
17611761
1762pub const DebugInfo = struct {
1762pub const Info = struct {
17631763 allocator: mem.Allocator,
17641764 address_map: std.AutoHashMap(usize, *ModuleDebugInfo),
17651765 modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModuleInfo) else void,
17661766
1767 pub fn init(allocator: mem.Allocator) !DebugInfo {
1768 var debug_info = DebugInfo{
1767 pub fn init(allocator: mem.Allocator) !Info {
1768 var debug_info = Info{
17691769 .allocator = allocator,
17701770 .address_map = std.AutoHashMap(usize, *ModuleDebugInfo).init(allocator),
17711771 .modules = if (native_os == .windows) .{} else {},
......@@ -1808,7 +1808,7 @@ pub const DebugInfo = struct {
18081808 return debug_info;
18091809 }
18101810
1811 pub fn deinit(self: *DebugInfo) void {
1811 pub fn deinit(self: *Info) void {
18121812 var it = self.address_map.iterator();
18131813 while (it.next()) |entry| {
18141814 const mdi = entry.value_ptr.*;
......@@ -1825,7 +1825,7 @@ pub const DebugInfo = struct {
18251825 }
18261826 }
18271827
1828 pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1828 pub fn getModuleForAddress(self: *Info, address: usize) !*ModuleDebugInfo {
18291829 if (comptime builtin.target.isDarwin()) {
18301830 return self.lookupModuleDyld(address);
18311831 } else if (native_os == .windows) {
......@@ -1842,7 +1842,7 @@ pub const DebugInfo = struct {
18421842 // Returns the module name for a given address.
18431843 // This can be called when getModuleForAddress fails, so implementations should provide
18441844 // a path that doesn't rely on any side-effects of a prior successful module lookup.
1845 pub fn getModuleNameForAddress(self: *DebugInfo, address: usize) ?[]const u8 {
1845 pub fn getModuleNameForAddress(self: *Info, address: usize) ?[]const u8 {
18461846 if (comptime builtin.target.isDarwin()) {
18471847 return self.lookupModuleNameDyld(address);
18481848 } else if (native_os == .windows) {
......@@ -1856,7 +1856,7 @@ pub const DebugInfo = struct {
18561856 }
18571857 }
18581858
1859 fn lookupModuleDyld(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1859 fn lookupModuleDyld(self: *Info, address: usize) !*ModuleDebugInfo {
18601860 const image_count = std.c._dyld_image_count();
18611861
18621862 var i: u32 = 0;
......@@ -1922,7 +1922,7 @@ pub const DebugInfo = struct {
19221922 return error.MissingDebugInfo;
19231923 }
19241924
1925 fn lookupModuleNameDyld(self: *DebugInfo, address: usize) ?[]const u8 {
1925 fn lookupModuleNameDyld(self: *Info, address: usize) ?[]const u8 {
19261926 _ = self;
19271927 const image_count = std.c._dyld_image_count();
19281928
......@@ -1960,7 +1960,7 @@ pub const DebugInfo = struct {
19601960 return null;
19611961 }
19621962
1963 fn lookupModuleWin32(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1963 fn lookupModuleWin32(self: *Info, address: usize) !*ModuleDebugInfo {
19641964 for (self.modules.items) |*module| {
19651965 if (address >= module.base_address and address < module.base_address + module.size) {
19661966 if (self.address_map.get(module.base_address)) |obj_di| {
......@@ -2050,7 +2050,7 @@ pub const DebugInfo = struct {
20502050 return error.MissingDebugInfo;
20512051 }
20522052
2053 fn lookupModuleNameWin32(self: *DebugInfo, address: usize) ?[]const u8 {
2053 fn lookupModuleNameWin32(self: *Info, address: usize) ?[]const u8 {
20542054 for (self.modules.items) |module| {
20552055 if (address >= module.base_address and address < module.base_address + module.size) {
20562056 return module.name;
......@@ -2059,7 +2059,7 @@ pub const DebugInfo = struct {
20592059 return null;
20602060 }
20612061
2062 fn lookupModuleNameDl(self: *DebugInfo, address: usize) ?[]const u8 {
2062 fn lookupModuleNameDl(self: *Info, address: usize) ?[]const u8 {
20632063 _ = self;
20642064
20652065 var ctx: struct {
......@@ -2097,7 +2097,7 @@ pub const DebugInfo = struct {
20972097 return null;
20982098 }
20992099
2100 fn lookupModuleDl(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
2100 fn lookupModuleDl(self: *Info, address: usize) !*ModuleDebugInfo {
21012101 var ctx: struct {
21022102 // Input
21032103 address: usize,
......@@ -2191,13 +2191,13 @@ pub const DebugInfo = struct {
21912191 return obj_di;
21922192 }
21932193
2194 fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
2194 fn lookupModuleHaiku(self: *Info, address: usize) !*ModuleDebugInfo {
21952195 _ = self;
21962196 _ = address;
21972197 @panic("TODO implement lookup module for Haiku");
21982198 }
21992199
2200 fn lookupModuleWasm(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
2200 fn lookupModuleWasm(self: *Info, address: usize) !*ModuleDebugInfo {
22012201 _ = self;
22022202 _ = address;
22032203 @panic("TODO implement lookup module for Wasm");