Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/std/dwarf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,15 @@ const LineNumberProgram = struct {
if (file_entry.dir_index >= self.include_dirs.len) return badDwarf();
const dir_name = self.include_dirs[file_entry.dir_index].path;

const file_name = try fs.path.join(allocator, &[_][]const u8{
dir_name, file_entry.path,
});
// This will break when the system running this code has different
// path separators than what generated the debug info. This was deemed
// acceptable as this code is really only designed to be used in
// combination with std.debug
const parts = if (file_entry.dir_index > 0 and !fs.path.isAbsolute(dir_name))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if it would be better stylistically to create two separate arrays and choose between them, or to just create one and pass a different slice of it to path.join depending on what behavior we want. I chose this because I think it's a bit more readable, but I'd be fine with the other option as well.

&[_][]const u8{ self.include_dirs[0].path, dir_name, file_entry.path }
else
&[_][]const u8{ dir_name, file_entry.path };
const file_name = try fs.path.join(allocator, parts);

return debug.LineInfo{
.line = if (self.prev_line >= 0) @intCast(u64, self.prev_line) else 0,
Expand Down