@@ -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 ) {
@@ -1142,10 +1148,15 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
1142
1148
var path = line_info .file_name ;
1143
1149
1144
1150
if (native_os == .windows ) {
1145
- var buffer : [std .fs .MAX_PATH_BYTES * 2 ]u8 = undefined ;
1151
+ var buffer : [std .fs .MAX_PATH_BYTES * 2 ]u8 = undefined ;
1146
1152
var fba = std .heap .FixedBufferAllocator .init (& buffer );
1147
1153
var resolved_path = try std .fs .path .resolve (fba .allocator (), &.{path });
1148
- path = try std .fmt .allocPrint (fba .allocator (), "\\ ??\\ {s}{s}" , .{if (resolved_path [0 ] == '\\ ' ) "UNC" else "" , resolved_path });
1154
+ if (resolved_path [0 ] == '\\ ' ) {
1155
+ path = try std .fmt .allocPrint (fba .allocator (), "\\ ??\\ UNC{s}" , .{resolved_path });
1156
+ } else {
1157
+ path = try std .fmt .allocPrint (fba .allocator (), "\\ ??\\ {s}" , .{resolved_path });
1158
+ }
1159
+ // path normalized later in openFile
1149
1160
}
1150
1161
1151
1162
var f = try fs .cwd ().openFile (path , .{ .intended_io_mode = .blocking });
@@ -1374,17 +1385,18 @@ pub const DebugInfo = struct {
1374
1385
windows .PATH_MAX_WIDE ,
1375
1386
);
1376
1387
assert (len > 0 );
1377
- var begin : usize = 0 ;
1388
+ var name_start : usize = 0 ;
1378
1389
if (name_buffer [7 ] != '\\ ' ) {
1379
- begin = 3 ;
1390
+ name_start = 3 ;
1380
1391
std .mem .copy (u16 , name_buffer [3.. 7], &[_ ]u16 { '\\ ' , '?' , '?' , '\\ ' });
1381
1392
}
1382
- var name_w16 = std .mem .collapseRepeats (u16 , name_buffer [begin .. len + 7 ], '\\ ' );
1393
+ const name_len = try std .os .windows .normalizePath (u16 , name_buffer [name_start .. len + 7 ]);
1394
+ const name = name_buffer [name_start .. name_start + name_len ];
1383
1395
1384
1396
const obj_di = try self .allocator .create (ModuleDebugInfo );
1385
1397
errdefer self .allocator .destroy (obj_di );
1386
1398
1387
- const coff_file = fs .openFileAbsoluteW (name_w16 , .{}) catch | err | switch (err ) {
1399
+ const coff_file = fs .openFileAbsoluteW (name , .{}) catch | err | switch (err ) {
1388
1400
error .FileNotFound = > return error .MissingDebugInfo ,
1389
1401
else = > return err ,
1390
1402
};
0 commit comments