[Lldb-commits] [lldb] [lldb] Use correct path for debugserver (PR #131609)

Yuval Deutscher via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 6 00:32:10 PDT 2025


================
@@ -58,3 +59,45 @@ 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.
+        llgs_hiding_directory = self.getBuildArtifact("hiding-directory")
+        new_lldb_server_link = self.getBuildArtifact(
+            "lldb-server-with-an-unconventional-name"
+        )
+        new_lldb_server = os.path.join(llgs_hiding_directory, "lldb-server")
+        os.makedirs(llgs_hiding_directory)
+        shutil.copy(lldbgdbserverutils.get_lldb_server_exe(), new_lldb_server)
+        os.symlink(new_lldb_server, new_lldb_server_link)
+
+        proc = self.spawnSubprocess(new_lldb_server_link, 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")
+
+        # So that lldb-server doesn't crash over SIGHUP
+        os.kill(proc.pid, signal.SIGTERM)
----------------
yuvald-sweet-security wrote:

The test still passes, but you get a weird error about lldb-server crashing on SIGHUP (another bug? see below). This also happens in the other test in that file, but I didn't bother with it, I fixed it for the new test because it threw me off when debugging it.

```
SIGHUP received, exiting lldb-server...
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/user/random/llvm-project/build/lldb-test-build.noindex/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.test_platform_process_launch_gdb_server/lldb-server platform --listen [127.0.0.1]:0 --socket-file /home/user/random/llvm-project/build/lldb-test-build.noindex/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.test_platform_process_launch_gdb_server/port -- /home/user/random/llvm-project/build/lldb-test-build.noindex/commands/platform/launchgdbserver/TestPlatformLaunchGDBServer.test_platform_process_launch_gdb_server/a.out foo
 #0 0x000062736b6aea2d (+0x3f3ca2d)
 #1 0x000062736b6aeeeb (+0x3f3ceeb)
 #2 0x000062736b6ad08f (+0x3f3b08f)
 #3 0x000062736b6af5c9 (+0x3f3d5c9)
 #4 0x0000781b8f245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x0000781b8f29eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x0000781b8f24527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x0000781b8f2288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x000062736b56ca9e (+0x3dfaa9e)
 #9 0x0000781b8f245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#10 0x0000781b8f31ba00 ppoll (/lib/x86_64-linux-gnu/libc.so.6+0x11ba00)
#11 0x000062736b717281 (+0x3fa5281)
#12 0x000062736b717193 (+0x3fa5193)
#13 0x000062736b717fe8 (+0x3fa5fe8)
#14 0x000062736b56c984 (+0x3dfa984)
#15 0x000062736b5774fb (+0x3e054fb)
#16 0x0000781b8f22a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#17 0x0000781b8f22a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#18 0x000062736b55b6e5 (+0x3de96e5)
```

https://github.com/llvm/llvm-project/pull/131609


More information about the lldb-commits mailing list