@@ -884,8 +884,14 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_file: File) !ModuleDebugInfo
884
884
const path = try fs .path .resolve (allocator , &[_ ][]const u8 {raw_path });
885
885
defer allocator .free (path );
886
886
887
- const unc_path = try std .fmt .allocPrint (allocator , "\\ ??\\ {s}{s}" , .{if (path [0 ] == '\\ ' ) "UNC" else "" , path });
887
+ var unc_path : []const u8 = undefined ;
888
+ if (path [0 ] == '\\ ' ) {
889
+ unc_path = try std .fmt .allocPrint (allocator , "\\ ??\\ UNC{s}" , .{path });
890
+ } else {
891
+ unc_path = try std .fmt .allocPrint (allocator , "\\ ??\\ {s}" , .{path });
892
+ }
888
893
defer allocator .free (unc_path );
894
+ // path normalized later in openFile
889
895
890
896
di .debug_data = PdbOrDwarf { .pdb = undefined };
891
897
di .debug_data .pdb = pdb .Pdb .init (allocator , unc_path ) catch | err | switch (err ) {
@@ -1137,10 +1143,15 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
1137
1143
var path = line_info .file_name ;
1138
1144
1139
1145
if (native_os == .windows ) {
1140
- var buffer : [std .fs .MAX_PATH_BYTES * 2 ]u8 = undefined ;
1146
+ var buffer : [std .fs .MAX_PATH_BYTES * 2 ]u8 = undefined ;
1141
1147
var fba = std .heap .FixedBufferAllocator .init (& buffer );
1142
1148
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 });
1149
+ if (resolved_path [0 ] == '\\ ' ) {
1150
+ path = try std .fmt .allocPrint (fba .allocator (), "\\ ??\\ UNC{s}" , .{resolved_path });
1151
+ } else {
1152
+ path = try std .fmt .allocPrint (fba .allocator (), "\\ ??\\ {s}" , .{resolved_path });
1153
+ }
1154
+ // path normalized later in openFile
1144
1155
}
1145
1156
1146
1157
var f = try fs .cwd ().openFile (path , .{ .intended_io_mode = .blocking });
@@ -1369,17 +1380,18 @@ pub const DebugInfo = struct {
1369
1380
windows .PATH_MAX_WIDE ,
1370
1381
);
1371
1382
assert (len > 0 );
1372
- var begin : usize = 0 ;
1383
+ var name_start : usize = 0 ;
1373
1384
if (name_buffer [7 ] != '\\ ' ) {
1374
- begin = 3 ;
1385
+ name_start = 3 ;
1375
1386
std .mem .copy (u16 , name_buffer [3.. 7], &[_ ]u16 { '\\ ' , '?' , '?' , '\\ ' });
1376
1387
}
1377
- var name_w16 = std .mem .collapseRepeats (u16 , name_buffer [begin .. len + 7 ], '\\ ' );
1388
+ const name_len = try std .os .windows .normalizePath (u16 , name_buffer [name_start .. len + 7 ]);
1389
+ const name = name_buffer [name_start .. name_start + name_len ];
1378
1390
1379
1391
const obj_di = try self .allocator .create (ModuleDebugInfo );
1380
1392
errdefer self .allocator .destroy (obj_di );
1381
1393
1382
- const coff_file = fs .openFileAbsoluteW (name_w16 , .{}) catch | err | switch (err ) {
1394
+ const coff_file = fs .openFileAbsoluteW (name , .{}) catch | err | switch (err ) {
1383
1395
error .FileNotFound = > return error .MissingDebugInfo ,
1384
1396
else = > return err ,
1385
1397
};
0 commit comments