Skip to content

Commit f4a3953

Browse files
committed
Minor fix to connect-url to support unix-connect sockets on localhost
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
1 parent 479f992 commit f4a3953

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,11 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
800800
const char *hostname,
801801
uint16_t port, const char *path) {
802802
StreamString result;
803-
result.Printf("%s://[%s]", scheme, hostname);
803+
if (strlen(hostname) > 0)
804+
result.Printf("%s://[%s]", scheme, hostname);
805+
else
806+
result.Printf("%s://", scheme);
807+
804808
if (port != 0)
805809
result.Printf(":%u", port);
806810
if (path)

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ GDBRemoteCommunicationClient::SendThreadSpecificPacketAndWaitForResponse(
538538
if (Log *log = GetLog(GDBRLog::Process | GDBRLog::Packets))
539539
LLDB_LOGF(log,
540540
"GDBRemoteCommunicationClient::%s: Didn't get sequence mutex "
541-
"for %s packet.",
542-
__FUNCTION__, payload.GetData());
541+
"for %s packet for thread %lu.",
542+
__FUNCTION__, payload.GetData(), tid);
543543
return PacketResult::ErrorNoSequenceLock;
544544
}
545545

lldb/test/API/commands/platform/connect/TestPlatformConnect.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,50 @@ def test_platform_process_connect(self):
5757
self.assertEqual(frame.GetFunction().GetName(), "main")
5858
self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
5959
process.Continue()
60+
61+
62+
@skipIfRemote
63+
@expectedFailureAll(hostoslist=["windows"], triple=".*-android")
64+
@skipIfDarwin # lldb-server not found correctly
65+
@expectedFailureAll(oslist=["windows"]) # process modules not loaded
66+
# lldb-server platform times out waiting for the gdbserver port number to be
67+
# written to the pipe, yet it seems the gdbserver already has written it.
68+
@expectedFailureAll(
69+
archs=["aarch64"],
70+
oslist=["freebsd"],
71+
bugnumber="https://github.com/llvm/llvm-project/issues/84327",
72+
)
73+
@add_test_categories(["lldb-server"])
74+
def test_platform_process_connect_with_unix_connect(self):
75+
self.build()
76+
import time
77+
timestamp = int(time.time())
78+
listen_url = "/tmp/listen_url_%s" % timestamp
79+
port_file = "/tmp/port_file_%s" % timestamp
80+
commandline_args = [
81+
"platform",
82+
"--listen",
83+
listen_url,
84+
"--socket-file",
85+
port_file,
86+
"--",
87+
self.getBuildArtifact("a.out"),
88+
"foo",
89+
]
90+
self.spawnSubprocess(lldbgdbserverutils.get_lldb_server_exe(), commandline_args)
91+
92+
socket_file = lldbutil.wait_for_file_on_target(self, port_file)
93+
new_platform = lldb.SBPlatform("remote-" + self.getPlatform())
94+
self.dbg.SetSelectedPlatform(new_platform)
95+
connect_url = "unix-connect://%s" % socket_file
96+
self.runCmd("platform connect %s" % connect_url)
97+
98+
lldbutil.run_break_set_by_symbol(self, "main")
99+
process = self.process()
100+
101+
process.Continue()
102+
103+
frame = self.frame()
104+
self.assertEqual(frame.GetFunction().GetName(), "main")
105+
self.assertEqual(frame.FindVariable("argc").GetValueAsSigned(), 2)
106+
process.Continue()

0 commit comments

Comments
 (0)