| ... | @@ -1255,13 +1255,14 @@ pub const DebugInfo = struct { | ... | @@ -1255,13 +1255,14 @@ pub const DebugInfo = struct { |
| 1255 | const seg_end = seg_start + info.SizeOfImage; | 1255 | const seg_end = seg_start + info.SizeOfImage; |
| 1256 | | 1256 | |
| 1257 | if (address >= seg_start and address < seg_end) { | 1257 | if (address >= seg_start and address < seg_end) { |
| 1258 | var name_buffer: [windows.MAX_PATH]u8 = undefined; | 1258 | var name_buffer: [windows.PATH_MAX_WIDE + 4:0]u16 = undefined; |
| 1259 | // XXX: Use W variant (#534) | 1259 | // openFileAbsoluteW requires the prefix to be present |
| 1260 | const len = windows.kernel32.K32GetModuleFileNameExA( | 1260 | mem.copy(u16, name_buffer[0..4], &[_]u16{ '\\', '?', '?', '\\' }); |
| | 1261 | const len = windows.kernel32.K32GetModuleFileNameExW( |
| 1261 | process_handle, | 1262 | process_handle, |
| 1262 | module, | 1263 | module, |
| 1263 | @ptrCast(windows.LPSTR, &name_buffer), | 1264 | @ptrCast(windows.LPWSTR, &name_buffer[4]), |
| 1264 | @sizeOf(@TypeOf(name_buffer)) / @sizeOf(u8), | 1265 | windows.PATH_MAX_WIDE, |
| 1265 | ); | 1266 | ); |
| 1266 | assert(len > 0); | 1267 | assert(len > 0); |
| 1267 | | 1268 | |
| ... | @@ -1270,9 +1271,9 @@ pub const DebugInfo = struct { | ... | @@ -1270,9 +1271,9 @@ pub const DebugInfo = struct { |
| 1270 | } | 1271 | } |
| 1271 | | 1272 | |
| 1272 | // XXX: The compiler segfaults if the slicing is done as a | 1273 | // XXX: The compiler segfaults if the slicing is done as a |
| 1273 | // parameter | 1274 | // parameter (#4423) |
| 1274 | const tmp = name_buffer[0..:0]; | 1275 | const tmp = name_buffer[0..:0]; |
| 1275 | const file_obj = try fs.cwd().openFileC(tmp, .{}); | 1276 | const file_obj = try fs.openFileAbsoluteW(tmp, .{}); |
| 1276 | errdefer file_obj.close(); | 1277 | errdefer file_obj.close(); |
| 1277 | | 1278 | |
| 1278 | const obj_di = try self.allocator.create(ObjectDebugInfo); | 1279 | const obj_di = try self.allocator.create(ObjectDebugInfo); |
| ... | @@ -1293,8 +1294,6 @@ pub const DebugInfo = struct { | ... | @@ -1293,8 +1294,6 @@ pub const DebugInfo = struct { |
| 1293 | fn lookupModuleDl(self: *DebugInfo, address: usize) !*ObjectDebugInfo { | 1294 | fn lookupModuleDl(self: *DebugInfo, address: usize) !*ObjectDebugInfo { |
| 1294 | var ctx = DIPContext{ .address = address }; | 1295 | var ctx = DIPContext{ .address = address }; |
| 1295 | | 1296 | |
| 1296 | warn("lookup {x}\n", .{address}); | | |
| 1297 | | | |
| 1298 | // XXX Locking? | 1297 | // XXX Locking? |
| 1299 | if (os.dl_iterate_phdr(DIPContext, dl_iterate_phdr_callback, &ctx) == 0) | 1298 | if (os.dl_iterate_phdr(DIPContext, dl_iterate_phdr_callback, &ctx) == 0) |
| 1300 | return error.DebugInfoNotFound; | 1299 | return error.DebugInfoNotFound; |