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 {
12551255 const seg_end = seg_start + info.SizeOfImage;
12561256
12571257 if (address >= seg_start and address < seg_end) {
1258 var name_buffer: [windows.MAX_PATH]u8 = undefined;
1259 // XXX: Use W variant (#534)
1260 const len = windows.kernel32.K32GetModuleFileNameExA(
1258 var name_buffer: [windows.PATH_MAX_WIDE + 4:0]u16 = undefined;
1259 // openFileAbsoluteW requires the prefix to be present
1260 mem.copy(u16, name_buffer[0..4], &[_]u16{ '\\', '?', '?', '\\' });
1261 const len = windows.kernel32.K32GetModuleFileNameExW(
12611262 process_handle,
12621263 module,
1263 @ptrCast(windows.LPSTR, &name_buffer),
1264 @sizeOf(@TypeOf(name_buffer)) / @sizeOf(u8),
1264 @ptrCast(windows.LPWSTR, &name_buffer[4]),
1265 windows.PATH_MAX_WIDE,
12651266 );
12661267 assert(len > 0);
12671268
......@@ -1270,9 +1271,9 @@ pub const DebugInfo = struct {
12701271 }
12711272
12721273 // XXX: The compiler segfaults if the slicing is done as a
1273 // parameter
1274 // parameter (#4423)
12741275 const tmp = name_buffer[0..:0];
1275 const file_obj = try fs.cwd().openFileC(tmp, .{});
1276 const file_obj = try fs.openFileAbsoluteW(tmp, .{});
12761277 errdefer file_obj.close();
12771278
12781279 const obj_di = try self.allocator.create(ObjectDebugInfo);
......@@ -1293,8 +1294,6 @@ pub const DebugInfo = struct {
12931294 fn lookupModuleDl(self: *DebugInfo, address: usize) !*ObjectDebugInfo {
12941295 var ctx = DIPContext{ .address = address };
12951296
1296 warn("lookup {x}\n", .{address});
1297
12981297 // XXX Locking?
12991298 if (os.dl_iterate_phdr(DIPContext, dl_iterate_phdr_callback, &ctx) == 0)
13001299 return error.DebugInfoNotFound;