Skip to content

[lldb] Use correct path for debugserver #131609

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

Merged
merged 2 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,42 @@ def test_platform_process_launch_gdb_server(self):

self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
self.expect("run", substrs=["unable to launch a GDB server on"], error=True)

@skipIfRemote
@skipUnlessPlatform(["linux"])
@add_test_categories(["lldb-server"])
def test_lldb_server_weird_symlinks(self):
self.build()

hostname = socket.getaddrinfo("localhost", 0, proto=socket.IPPROTO_TCP)[0][4][0]
listen_url = "[%s]:0" % hostname

port_file = self.getBuildArtifact("port")
commandline_args = [
"platform",
"--listen",
listen_url,
"--socket-file",
port_file,
]

# Run lldb-server from a symlink without any binary called "lldb-server" in the directory.
new_lldb_server = self.getBuildArtifact(
"lldb-server-with-an-unconventional-name"
)
os.symlink(lldbgdbserverutils.get_lldb_server_exe(), new_lldb_server)

proc = self.spawnSubprocess(new_lldb_server, commandline_args)
socket_id = lldbutil.wait_for_file_on_target(self, port_file)

new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
self.dbg.SetSelectedPlatform(new_platform)

connect_url = "connect://[%s]:%s" % (hostname, socket_id)
self.runCmd("platform connect %s" % connect_url)
self.runCmd("target create {}".format(self.getBuildArtifact("a.out")))
self.runCmd("run")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would feel better if there was some positive acknowledgement that the process was running, rather than just a lack of error. Would adding something like

        self.expect(
            "process status",
            patterns=["Process .* exited with status = 0"],
        )

work?

self.expect(
"process status",
patterns=["Process .* exited with status = 0"],
)
9 changes: 8 additions & 1 deletion lldb/tools/lldb-server/SystemInitializerLLGS.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@

#include "lldb/Initialization/SystemInitializer.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
#include "lldb/Utility/FileSpec.h"

class SystemInitializerLLGS : public lldb_private::SystemInitializerCommon {
public:
SystemInitializerLLGS() : SystemInitializerCommon(nullptr) {}
SystemInitializerLLGS()
: SystemInitializerCommon(
// Finding the shared libraries directory on lldb-server is broken
// since lldb-server isn't dynamically linked with liblldb.so.
// Clearing the filespec here causes GetShlibDir to fail and
// GetSupportExeDir to fall-back to using the binary path instead.
[](lldb_private::FileSpec &file) { file.Clear(); }) {}

llvm::Error Initialize() override;
void Terminate() override;
Expand Down