aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug/SelfInfo/Windows.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-10-28 08:47:39 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-10-29 06:20:52 -0700
commit6f64c8b693446a6f8d170bb09324e5c5e506ce6f (patch)
tree620a2126901c6d92536012ec6599c0b96759d313 /lib/std/debug/SelfInfo/Windows.zig
parent1553c8eae7d830cb793e78c3e52ad816fa8efd23 (diff)
downloadzig-6f64c8b693446a6f8d170bb09324e5c5e506ce6f.tar.gz
zig-6f64c8b693446a6f8d170bb09324e5c5e506ce6f.zip
std.debug.SelfInfo.Windows: less invasive change
restores code closer to master branch in hopes of avoiding a regression that was introduced when this was based on openSelfExe rather than GetModuleFileNameExW.
Diffstat (limited to 'lib/std/debug/SelfInfo/Windows.zig')
-rw-r--r--lib/std/debug/SelfInfo/Windows.zig21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/std/debug/SelfInfo/Windows.zig b/lib/std/debug/SelfInfo/Windows.zig
index 51c41030dc..70009217db 100644
--- a/lib/std/debug/SelfInfo/Windows.zig
+++ b/lib/std/debug/SelfInfo/Windows.zig
@@ -297,7 +297,19 @@ const Module = struct {
// a binary is produced with -gdwarf, since the section names are longer than 8 bytes.
const mapped_file: ?DebugInfo.MappedFile = mapped: {
if (!coff_obj.strtabRequired()) break :mapped null;
- const coff_file = Io.File.openSelfExe(io, .{}) catch |err| switch (err) {
+ var name_buffer: [windows.PATH_MAX_WIDE + 4:0]u16 = undefined;
+ name_buffer[0..4].* = .{ '\\', '?', '?', '\\' }; // openFileAbsoluteW requires the prefix to be present
+ const process_handle = windows.GetCurrentProcess();
+ const len = windows.kernel32.GetModuleFileNameExW(
+ process_handle,
+ module.handle,
+ name_buffer[4..],
+ windows.PATH_MAX_WIDE,
+ );
+ if (len == 0) return error.MissingDebugInfo;
+ const name_w = name_buffer[0 .. len + 4 :0];
+ var threaded: Io.Threaded = .init_single_threaded;
+ const coff_file = threaded.dirOpenFileWtf16(null, name_w, .{}) catch |err| switch (err) {
error.Canceled => |e| return e,
error.Unexpected => |e| return e,
error.FileNotFound => return error.MissingDebugInfo,
@@ -327,12 +339,6 @@ const Module = struct {
error.SystemFdQuotaExceeded,
error.FileLocksNotSupported,
error.FileBusy,
- error.InputOutput,
- error.NotSupported,
- error.FileSystem,
- error.NotLink,
- error.UnrecognizedVolume,
- error.UnknownName,
=> return error.ReadFailed,
};
errdefer coff_file.close(io);
@@ -352,7 +358,6 @@ const Module = struct {
errdefer windows.CloseHandle(section_handle);
var coff_len: usize = 0;
var section_view_ptr: ?[*]const u8 = null;
- const process_handle = windows.GetCurrentProcess();
const map_section_rc = windows.ntdll.NtMapViewOfSection(
section_handle,
process_handle,