| author | |
| committer | |
| log | 6b387585940e06eb27d1f95c0f3259f13f84a674 |
| tree | 7c45351ce7a55204336f76d1e8488eaadfee0ac0 |
| parent | 6724a524d44fdf112830ca1f549f4cfc8e47ffb9 |
3 files changed, 17 insertions(+), 19 deletions(-)
lib/std/coff.zig+4-12| ... | ... | @@ -1101,7 +1101,7 @@ pub const Coff = struct { |
| 1101 | 1101 | return coff; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | pub fn getPdbPath(self: *Coff, buffer: []u8) !?usize { | |
| 1104 | pub fn getPdbPath(self: *Coff) !?[]const u8 { | |
| 1105 | 1105 | assert(self.is_image); |
| 1106 | 1106 | |
| 1107 | 1107 | const data_dirs = self.getDataDirectories(); |
| ... | ... | @@ -1145,17 +1145,9 @@ pub const Coff = struct { |
| 1145 | 1145 | self.age = try reader.readInt(u32, .little); |
| 1146 | 1146 | |
| 1147 | 1147 | // Finally read the null-terminated string. |
| 1148 | var byte = try reader.readByte(); | |
| 1149 | i = 0; | |
| 1150 | while (byte != 0 and i < buffer.len) : (i += 1) { | |
| 1151 | buffer[i] = byte; | |
| 1152 | byte = try reader.readByte(); | |
| 1153 | } | |
| 1154 | ||
| 1155 | if (byte != 0 and i == buffer.len) | |
| 1156 | return error.NameTooLong; | |
| 1157 | ||
| 1158 | return @as(usize, i); | |
| 1148 | const start = reader.context.pos; | |
| 1149 | const len = std.mem.indexOfScalar(u8, self.data[start..], 0) orelse return null; | |
| 1150 | return self.data[start .. start + len]; | |
| 1159 | 1151 | } |
| 1160 | 1152 | |
| 1161 | 1153 | pub fn getCoffHeader(self: Coff) CoffHeader { |
lib/std/debug.zig+11-6| ... | ... | @@ -1093,12 +1093,17 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_obj: *coff.Coff) !ModuleDebu |
| 1093 | 1093 | di.dwarf = dwarf; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | var path_buf: [windows.MAX_PATH]u8 = undefined; | |
| 1097 | const len = try coff_obj.getPdbPath(path_buf[0..]) orelse return di; | |
| 1098 | const raw_path = path_buf[0..len]; | |
| 1099 | ||
| 1100 | const path = try fs.path.resolve(allocator, &[_][]const u8{raw_path}); | |
| 1101 | defer allocator.free(path); | |
| 1096 | const raw_path = try coff_obj.getPdbPath() orelse return di; | |
| 1097 | const path = blk: { | |
| 1098 | if (fs.path.isAbsolute(raw_path)) { | |
| 1099 | break :blk raw_path; | |
| 1100 | } else { | |
| 1101 | const self_dir = try fs.selfExeDirPathAlloc(allocator); | |
| 1102 | defer allocator.free(self_dir); | |
| 1103 | break :blk try fs.path.join(allocator, &.{ self_dir, raw_path }); | |
| 1104 | } | |
| 1105 | }; | |
| 1106 | defer if (path.ptr != raw_path.ptr) allocator.free(path); | |
| 1102 | 1107 | |
| 1103 | 1108 | di.pdb = pdb.Pdb.init(allocator, path) catch |err| switch (err) { |
| 1104 | 1109 | error.FileNotFound, error.IsDir => { |
src/link/Coff/lld.zig+2-1| ... | ... | @@ -184,9 +184,10 @@ pub fn linkWithLLD(self: *Coff, arena: Allocator, prog_node: *std.Progress.Node) |
| 184 | 184 | const out_pdb = self.pdb_out_path orelse try allocPrint(arena, "{s}.pdb", .{ |
| 185 | 185 | full_out_path[0 .. full_out_path.len - out_ext.len], |
| 186 | 186 | }); |
| 187 | const out_pdb_basename = std.fs.path.basename(out_pdb); | |
| 187 | 188 | |
| 188 | 189 | try argv.append(try allocPrint(arena, "-PDB:{s}", .{out_pdb})); |
| 189 | try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb})); | |
| 190 | try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename})); | |
| 190 | 191 | } |
| 191 | 192 | if (comp.version) |version| { |
| 192 | 193 | try argv.append(try allocPrint(arena, "-VERSION:{}.{}", .{ version.major, version.minor })); |