Skip to content

Commit eedcfd3

Browse files
committed
windows: stacktrace fix line info printing
1 parent 8db3b5c commit eedcfd3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/std/debug.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,16 @@ fn readMachODebugInfo(allocator: mem.Allocator, macho_file: File) !ModuleDebugIn
11341134
fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
11351135
// Need this to always block even in async I/O mode, because this could potentially
11361136
// be called from e.g. the event loop code crashing.
1137-
var f = try fs.cwd().openFile(line_info.file_name, .{ .intended_io_mode = .blocking });
1137+
var path = line_info.file_name;
1138+
1139+
if (native_os == .windows) {
1140+
var buffer: [std.fs.MAX_PATH_BYTES*2]u8 = undefined;
1141+
var fba = std.heap.FixedBufferAllocator.init(&buffer);
1142+
var resolved_path = try std.fs.path.resolve(fba.allocator(), &.{path});
1143+
path = try std.fmt.allocPrint(fba.allocator(), "\\??\\{s}{s}", .{if (resolved_path[0] == '\\') "UNC" else "", resolved_path});
1144+
}
1145+
1146+
var f = try fs.cwd().openFile(path, .{ .intended_io_mode = .blocking });
11381147
defer f.close();
11391148
// TODO fstat and make sure that the file has the correct size
11401149

0 commit comments

Comments
 (0)