[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)
Santhosh Kumar Ellendula via lldb-commits
lldb-commits at lists.llvm.org
Mon May 20 09:09:33 PDT 2024
================
@@ -0,0 +1,146 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+ def runTargetProgramOnPort(self, port=None, program=None):
+ server_tool = None
+ if lldbplatformutil.getPlatform() == "linux":
+ server_tool = lldbgdbserverutils.get_lldb_server_exe()
+ if server_tool is None:
+ self.dap_server.request_disconnect(terminateDebuggee=True)
+ self.assertIsNotNone(server_tool, "lldb-server not found.")
+ server_tool += " g localhost:" + port + " "
+ elif lldbplatformutil.getPlatform() == "macosx":
+ server_tool = lldbgdbserverutils.get_debugserver_exe()
+ if server_tool is None:
+ self.dap_server.request_disconnect(terminateDebuggee=True)
+ self.assertIsNotNone(server_tool, "debugserver not found.")
+ server_tool += " --listen localhost:" + port + " "
+
+ self.process = subprocess.Popen(
+ [server_tool + program],
+ shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+
+ return self.process
+
+ def set_and_hit_breakpoint(self, continueToExit=True):
+ source = "main.c"
+ main_source_path = os.path.join(os.getcwd(), source)
+ breakpoint1_line = line_number(main_source_path, "// breakpoint 1")
+ lines = [breakpoint1_line]
+ # Set breakpoint in the thread function so we can step the threads
+ breakpoint_ids = self.set_source_breakpoints(main_source_path, lines)
+ self.assertEqual(
+ len(breakpoint_ids), len(lines), "expect correct number of breakpoints"
+ )
+ self.continue_to_breakpoints(breakpoint_ids)
+ if continueToExit:
+ self.continue_to_exit()
+
+ @skipIfWindows
+ @skipIfNetBSD # Hangs on NetBSD as well
----------------
santhoshe447 wrote:
This test case is designed to be verified only on Linux and macOS.
https://github.com/llvm/llvm-project/pull/91570
More information about the lldb-commits
mailing list