-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Use correct path for debugserver #131609
base: main
Are you sure you want to change the base?
[lldb] Use correct path for debugserver #131609
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-lldb Author: Yuval Deutscher (yuvald-sweet-security) ChangesHello, This solves an issue that arises when running lldb-server through a symlink which is not named exactly
It turns out that there is a cascade of bugs here:
Given the above information, the most logical solution seems to be just ditching Full diff: https://github.com/llvm/llvm-project/pull/131609.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index dad72a176b5fa..e754d01be3629 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -906,7 +906,7 @@ FileSpec GDBRemoteCommunication::GetDebugserverPath(Platform *platform) {
FileSystem::Instance().Exists(debugserver_file_spec);
if (!debugserver_exists) {
// The debugserver binary is in the LLDB.framework/Resources directory.
- debugserver_file_spec = HostInfo::GetSupportExeDir();
+ debugserver_file_spec.SetDirectory(HostInfo::GetProgramFileSpec().GetDirectory());
if (debugserver_file_spec) {
debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
debugserver_exists = FileSystem::Instance().Exists(debugserver_file_spec);
|
Well, looks like the tests really do check a case where lldb and lldb-server are not in the same directory. Should we just try both paths? maybe make EDIT: trying a new approach |
f47298e
to
a4e2c9f
Compare
Solves #63468 |
Hello,
This solves an issue that arises when running lldb-server through a symlink which is not named exactly
lldb-server
. For example, in many distros lldb-server is packaged as e.g./usr/lib/llvm-19/bin/lldb-server
which is then accessed through a symlink such as/usr/bin/lldb-server-19
. In such a scenario, runninglldb-server-19 platform --server --listen '*:1338' --log-channels "lldb all"
works as intended, but running the absolute path of the symlink (/usr/bin/lldb-server-19 platform --server --listen '*:1338' --log-channels "lldb all"
) fails with:It turns out that there is a cascade of bugs here:
GetShlibDir
attempts to locate the LLVM library directory by callingGetModuleFileSpecForHostAddress
on the address of the functionComputeSharedLibraryDirectory
, assuming that it is insideliblldb.so
. However, in every packaging I've seen of lldb-server the functionComputeSharedLibraryDirectory
is statically linked into thelldb-server
binary and is not inliblldb.so
.GetModuleFileSpecForHostAddress
on an address that is inlldb-server
returns the path of the symlink, not the path of the binary itself. So we get e.g./usr/bin/
and not/usr/lib/llvm-19/bin/
.GetDebugserverPath
attempts to concat"lldb-server"
to the directory we obtained, and thus fails when the symlink is not named exactlylldb-server
.GetModuleFileSpecForHostAddress
returns an incorrect path - when the server is run aslldb-server-19 ...
it returns"lldb-server-19"
which then causesComputePathRelativeToLibrary
to fail and thenComputeSupportExeDirectory
falls back to just usingGetProgramFileSpec
instead (which is the only option that actually yields a correct path).Given the above information, the most logical solution seems to be just ditching
GetSupportExeDir
in favor ofGetProgramFileSpec
, but I'm not sure what are the potential implications of this on different packaging of LLDB - perhaps there are situations where thelldb
binary is not located in the same directory withlldb-server
, and so we still want to use the follow-the-path-to-liblldb logic there? Please advise on how to proceed with this.