| ... | @@ -297,7 +297,19 @@ const Module = struct { | ... | @@ -297,7 +297,19 @@ const Module = struct { |
| 297 | // a binary is produced with -gdwarf, since the section names are longer than 8 bytes. | 297 | // a binary is produced with -gdwarf, since the section names are longer than 8 bytes. |
| 298 | const mapped_file: ?DebugInfo.MappedFile = mapped: { | 298 | const mapped_file: ?DebugInfo.MappedFile = mapped: { |
| 299 | if (!coff_obj.strtabRequired()) break :mapped null; | 299 | if (!coff_obj.strtabRequired()) break :mapped null; |
| 300 | const coff_file = Io.File.openSelfExe(io, .{}) catch |err| switch (err) { | 300 | var name_buffer: [windows.PATH_MAX_WIDE + 4:0]u16 = undefined; |
| | 301 | name_buffer[0..4].* = .{ '\\', '?', '?', '\\' }; // openFileAbsoluteW requires the prefix to be present |
| | 302 | const process_handle = windows.GetCurrentProcess(); |
| | 303 | const len = windows.kernel32.GetModuleFileNameExW( |
| | 304 | process_handle, |
| | 305 | module.handle, |
| | 306 | name_buffer[4..], |
| | 307 | windows.PATH_MAX_WIDE, |
| | 308 | ); |
| | 309 | if (len == 0) return error.MissingDebugInfo; |
| | 310 | const name_w = name_buffer[0 .. len + 4 :0]; |
| | 311 | var threaded: Io.Threaded = .init_single_threaded; |
| | 312 | const coff_file = threaded.dirOpenFileWtf16(null, name_w, .{}) catch |err| switch (err) { |
| 301 | error.Canceled => |e| return e, | 313 | error.Canceled => |e| return e, |
| 302 | error.Unexpected => |e| return e, | 314 | error.Unexpected => |e| return e, |
| 303 | error.FileNotFound => return error.MissingDebugInfo, | 315 | error.FileNotFound => return error.MissingDebugInfo, |
| ... | @@ -327,12 +339,6 @@ const Module = struct { | ... | @@ -327,12 +339,6 @@ const Module = struct { |
| 327 | error.SystemFdQuotaExceeded, | 339 | error.SystemFdQuotaExceeded, |
| 328 | error.FileLocksNotSupported, | 340 | error.FileLocksNotSupported, |
| 329 | error.FileBusy, | 341 | error.FileBusy, |
| 330 | error.InputOutput, | | |
| 331 | error.NotSupported, | | |
| 332 | error.FileSystem, | | |
| 333 | error.NotLink, | | |
| 334 | error.UnrecognizedVolume, | | |
| 335 | error.UnknownName, | | |
| 336 | => return error.ReadFailed, | 342 | => return error.ReadFailed, |
| 337 | }; | 343 | }; |
| 338 | errdefer coff_file.close(io); | 344 | errdefer coff_file.close(io); |
| ... | @@ -352,7 +358,6 @@ const Module = struct { | ... | @@ -352,7 +358,6 @@ const Module = struct { |
| 352 | errdefer windows.CloseHandle(section_handle); | 358 | errdefer windows.CloseHandle(section_handle); |
| 353 | var coff_len: usize = 0; | 359 | var coff_len: usize = 0; |
| 354 | var section_view_ptr: ?[*]const u8 = null; | 360 | var section_view_ptr: ?[*]const u8 = null; |
| 355 | const process_handle = windows.GetCurrentProcess(); | | |
| 356 | const map_section_rc = windows.ntdll.NtMapViewOfSection( | 361 | const map_section_rc = windows.ntdll.NtMapViewOfSection( |
| 357 | section_handle, | 362 | section_handle, |
| 358 | process_handle, | 363 | process_handle, |