[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91170)
via lldb-commits
lldb-commits at lists.llvm.org
Mon May 6 01:07:46 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r e2c89254e12e844214d02f1d12bf29ba2ca322c7...efffdf33f5f290c318ce4dd15250be5adcbed252 lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-06 07:12:22.000000 +0000
+++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-05-06 08:07:23.404889 +0000
@@ -571,11 +571,11 @@
terminateCommands=None,
coreFile=None,
postRunCommands=None,
sourceMap=None,
port=None,
- hostname=None
+ hostname=None,
):
args_dict = {}
if pid is not None:
args_dict["pid"] = pid
if program is not None:
@@ -602,13 +602,13 @@
if postRunCommands:
args_dict["postRunCommands"] = postRunCommands
if sourceMap:
args_dict["sourceMap"] = sourceMap
if port is not None:
- args_dict['port'] = port
+ args_dict["port"] = port
if hostname is not None:
- args_dict['hostname'] = hostname
+ args_dict["hostname"] = hostname
command_dict = {"command": "attach", "type": "request", "arguments": args_dict}
return self.send_recv(command_dict)
def request_configurationDone(self):
command_dict = {
--- packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 2024-05-03 09:47:05.000000 +0000
+++ packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 2024-05-06 08:07:23.562818 +0000
@@ -333,14 +333,24 @@
if not (response and response["success"]):
self.assertTrue(
response["success"], "attach failed (%s)" % (response["message"])
)
- def attach_by_port(self, program=None, pid=None, disconnectAutomatically=True, waitFor=None, sourceInitFile=False, port=None, hostname=None):
- '''Build the default Makefile target, create the VSCode debug adaptor,
- and attach to the process.
- '''
+ def attach_by_port(
+ self,
+ program=None,
+ pid=None,
+ disconnectAutomatically=True,
+ waitFor=None,
+ sourceInitFile=False,
+ port=None,
+ hostname=None,
+ ):
+ """Build the default Makefile target, create the VSCode debug adaptor,
+ and attach to the process.
+ """
+
# This overloaded function helps to request attach by port number
# Make sure we disconnect and terminate the VSCode debug adaptor even
# if we throw an exception during the test case.
def cleanup():
if disconnectAutomatically:
@@ -350,11 +360,12 @@
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
# Initialize and launch the program
self.dap_server.request_initialize(sourceInitFile)
response = self.dap_server.request_attach(
- program=program, pid=pid, waitFor=waitFor, port=port, hostname=hostname)
+ program=program, pid=pid, waitFor=waitFor, port=port, hostname=hostname
+ )
return response
def launch(
self,
program=None,
--- test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py 2024-05-03 09:47:05.000000 +0000
+++ test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py 2024-05-06 08:07:23.612153 +0000
@@ -15,106 +15,127 @@
import threading
import time
import sys
import re
+
class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
-
def runTargetProgramOnPort(self, port=None, program=None):
# sim_tool="hexagon-sim"
# if isIUTarget():
# sim_tool="iu-sim"
- target_sim_path=self.getBuiltServerTool("lldb-server")
+ target_sim_path = self.getBuiltServerTool("lldb-server")
if target_sim_path:
- target_sim_path +=' g localhost:' + port + ' '
+ target_sim_path += " g localhost:" + port + " "
- self.process = subprocess.Popen([target_sim_path + program], shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
-
+ self.process = subprocess.Popen(
+ [target_sim_path + 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'
+ source = "main.c"
main_source_path = os.path.join(os.getcwd(), source)
- breakpoint1_line = line_number(main_source_path, '// breakpoint 1')
+ 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.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
@skipIfRemote
def test_by_port(self):
- '''
- Tests attaching to a process by port.
- '''
+ """
+ Tests attaching to a process by port.
+ """
self.build_and_create_debug_adaptor()
program = self.getBuildArtifact("a.out")
- port = '2345'
+ port = "2345"
self.process = self.runTargetProgramOnPort(port=port, program=program)
- pid=self.process.pid
- response = self.attach_by_port(program=program, port=int(port), sourceInitFile=True)
- if not (response and response['success']):
- self.assertTrue(response['success'],
- 'attach failed (%s)' % (response['message']))
+ pid = self.process.pid
+ response = self.attach_by_port(
+ program=program, port=int(port), sourceInitFile=True
+ )
+ if not (response and response["success"]):
+ self.assertTrue(
+ response["success"], "attach failed (%s)" % (response["message"])
+ )
self.set_and_hit_breakpoint(continueToExit=True)
self.process.kill()
- os.system('killall hexagon-sim')
+ os.system("killall hexagon-sim")
@skipIfWindows
@skipIfNetBSD # Hangs on NetBSD as well
@skipIfRemote
def test_by_port_and_pid(self):
- '''
- Tests attaching to a process by process ID and port number.
- '''
+ """
+ Tests attaching to a process by process ID and port number.
+ """
self.build_and_create_debug_adaptor()
program = self.getBuildArtifact("a.out")
- port = '2345'
+ port = "2345"
self.process = self.runTargetProgramOnPort(port=port, program=program)
- response = self.attach_by_port(program=program,pid=1234, port=int(port), sourceInitFile=True)
- if not (response and response['success']):
- self.assertFalse(response['success'], "The user can't specify both pid and port")
+ response = self.attach_by_port(
+ program=program, pid=1234, port=int(port), sourceInitFile=True
+ )
+ if not (response and response["success"]):
+ self.assertFalse(
+ response["success"], "The user can't specify both pid and port"
+ )
self.process.kill()
@skipIfWindows
@skipIfNetBSD # Hangs on NetBSD as well
@skipIfRemote
def test_by_invalid_port(self):
- '''
- Tests attaching to a process by invalid port number 0.
- '''
+ """
+ Tests attaching to a process by invalid port number 0.
+ """
self.build_and_create_debug_adaptor()
program = self.getBuildArtifact("a.out")
- port = '0'
+ port = "0"
self.process = self.runTargetProgramOnPort(port=port, program=program)
- response = self.attach_by_port(program=program, port=int(port), sourceInitFile=True)
- if not (response and response['success']):
- self.assertFalse(response['success'], "The user can't attach with invalid port (%s)" % port)
+ response = self.attach_by_port(
+ program=program, port=int(port), sourceInitFile=True
+ )
+ if not (response and response["success"]):
+ self.assertFalse(
+ response["success"],
+ "The user can't attach with invalid port (%s)" % port,
+ )
self.process.kill()
@skipIfWindows
@skipIfNetBSD # Hangs on NetBSD as well
@skipIfRemote
def test_by_illegal_port(self):
- '''
- Tests attaching to a process by illegal/greater port number 65536
- '''
+ """
+ Tests attaching to a process by illegal/greater port number 65536
+ """
self.build_and_create_debug_adaptor()
program = self.getBuildArtifact("a.out")
- port = '65536'
+ port = "65536"
self.process = self.runTargetProgramOnPort(port=port, program=program)
- response = self.attach_by_port(program=program, port=int(port), sourceInitFile=True)
- if not (response and response['success']):
- self.assertFalse(response['success'], "The user can't attach with illegal port (%s)" % port)
+ response = self.attach_by_port(
+ program=program, port=int(port), sourceInitFile=True
+ )
+ if not (response and response["success"]):
+ self.assertFalse(
+ response["success"],
+ "The user can't attach with illegal port (%s)" % port,
+ )
self.process.kill()
``````````
</details>
https://github.com/llvm/llvm-project/pull/91170
More information about the lldb-commits
mailing list