Skip to content

Minor fix to connect-url to support unix-connect sockets on localhost #142875

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 1 commit into from
Jun 10, 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 @@ -800,7 +800,10 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
const char *hostname,
uint16_t port, const char *path) {
StreamString result;
result.Printf("%s://[%s]", scheme, hostname);
result.Printf("%s://", scheme);
if (strlen(hostname) > 0)
result.Printf("[%s]", hostname);

if (port != 0)
result.Printf(":%u", port);
if (path)
Expand Down
45 changes: 45 additions & 0 deletions lldb/test/API/commands/platform/connect/TestPlatformConnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,48 @@ def test_platform_process_connect(self):
self.assertEqual(frame.GetFunction().GetName(), "main")
self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
process.Continue()

@skipIfRemote
@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
@skipIfDarwin # lldb-server not found correctly
@expectedFailureAll(oslist=["windows"]) # process modules not loaded
# lldb-server platform times out waiting for the gdbserver port number to be
# written to the pipe, yet it seems the gdbserver already has written it.
@expectedFailureAll(
archs=["aarch64"],
oslist=["freebsd"],
bugnumber="https://github.com/llvm/llvm-project/issues/84327",
)
@add_test_categories(["lldb-server"])
def test_platform_process_connect_with_unix_connect(self):
self.build()
lldb_temp_dir = lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBTempSystemDir)
named_pipe = "%s/platform_server.sock" % lldb_temp_dir
port_file = self.getBuildArtifact("port")
commandline_args = [
"platform",
"--listen",
named_pipe,
"--socket-file",
port_file,
"--",
self.getBuildArtifact("a.out"),
"foo",
]
self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), commandline_args)

socket_file = lldbutil.wait_for_file_on_target(self, port_file)
new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
self.dbg.SetSelectedPlatform(new_platform)
connect_url = "unix-connect://%s" % socket_file
self.runCmd("platform connect %s" % connect_url)

lldbutil.run_break_set_by_symbol(self, "main")
process = self.process()

process.Continue()

frame = self.frame()
self.assertEqual(frame.GetFunction().GetName(), "main")
self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
process.Continue()
Loading