authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-10 20:47:07+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-20 19:41:29+01:00
logb3f728585a06d652393ca6d3feaaac5a42bfa968
tree340f7ac641112a6d10d080ffc67fd4ba26fab7ca
parent463f70443164ae602eb658c2bed557c289da020f

windows widestring


1 files changed, 8 insertions(+), 9 deletions(-)

lib/std/debug.zig+8-9
...@@ -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;
12561256
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);
12671268
...@@ -1270,9 +1271,9 @@ pub const DebugInfo = struct {...@@ -1270,9 +1271,9 @@ pub const DebugInfo = struct {
1270 }1271 }
12711272
1272 // XXX: The compiler segfaults if the slicing is done as a1273 // XXX: The compiler segfaults if the slicing is done as a
1273 // parameter1274 // 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();
12771278
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 };
12951296
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;