Skip to content

debug info: resolve relative paths to source files into absolute paths - #13843

Merged
kubkon merged 3 commits into
masterfrom
dwarf-abs-paths
Dec 9, 2022
Merged

debug info: resolve relative paths to source files into absolute paths#13843
kubkon merged 3 commits into
masterfrom
dwarf-abs-paths

Conversation

@kubkon

Copy link
Copy Markdown
Member

This change brings back stage1 behavior in that all debug info paths that are emitted in DWARF/PDB are always absolute. Note that the paths are resolved only when committing them into either a respective LLVM type (llvm.DIFile), or when emitting DWARF (as is the case with self-hosted backends).

This change will make stack traces and debugging experience more consistent in the sense that the presence of source lines in stack traces will not be dependent on the current working directory of the running process, making cases like #13831 non-existent (I am referring here to lack of source lines in submitted stack trace, not the actual linker bug which is unrelated).

Additional bonus is that we no longer need to mess with lld-links output on Windows by including special PDB path manipulating flag, -PDBSOURCEPATH as all source paths are now absolute by design.

Finally, as generating valid debug info output is important but not critical, if a call to std.os.realpath fails for whatever reason, we simply fallback to relative paths readily available.

If we merge this, this patch will obsolete #13540

cc @Vexu

This will make stack traces and debugging experience more consistent
in the sense that the presence of source lines in stack traces will
not be dependent on the current working directory of the running process.
@kubkonkubkon changed the title Resolve relative paths to source files into absolute pathsdebug info: resolve relative paths to source files into absolute pathsDec 9, 2022
Vexu
Vexu approved these changes Dec 9, 2022
@kubkon
kubkon enabled auto-merge December 9, 2022 17:52
@kubkon
kubkon merged commit bd5a8f8 into masterDec 9, 2022
@kubkon
kubkon deleted the dwarf-abs-paths branch December 9, 2022 18:18
@squeek502

Copy link
Copy Markdown
Member

Unless I'm mistaken, this will cause a compile error on some BSDs (see #13565, #13699).

@kubkon

Copy link
Copy Markdown
MemberAuthor

Unless I'm mistaken, this will cause a compile error on some BSDs (see #13565, #13699).

Happy to accept a patch that avoids realpath on those hosts. Also, please note that this is also a problem if anyone wants to crosscompile to macOS from some BSDs as we also use that primitive there. In the meantime, this is the only sane default I can think of for Linux, macOS and Windows hosts.

@semarie

Copy link
Copy Markdown
Contributor

realpath is only problematic when using std.fs.realpath() and not when using std.os.realpath(), so it is fine

@kubkon

Copy link
Copy Markdown
MemberAuthor

realpath is only problematic when using std.fs.realpath() and not when using std.os.realpath(), so it is fine

Do you mean std.fs.Dir.realpath() perhaps? Is that since it calls std.os.getFdPath() which seems to be supported by FreeBSD but not other flavours?

@semarie

Copy link
Copy Markdown
Contributor

yes, std.fs.Dir.realpath() (sorry for the confusion). and yes, due to std.os.getFdPath() which isn't widely supported

@squeek502

Copy link
Copy Markdown
Member

Thanks for clearing that up @semarie!

@andrewrk

Copy link
Copy Markdown
Member

Follow-up issue: #16571

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@kubkon@squeek502@semarie@andrewrk@Vexu