Skip to content

[lldb-dap] Adaptor -> Adapter (NFC) #129110

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 2 commits into from
Feb 28, 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
2 changes: 1 addition & 1 deletion lldb/packages/Python/lldbsuite/test/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"libc++": "Test for libc++ data formatters",
"libstdcxx": "Test for libstdcxx data formatters",
"lldb-server": "Tests related to lldb-server",
"lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap",
"lldb-dap": "Tests for the Debug Adapter Protocol with lldb-dap",
"llgs": "Tests for the gdb-server functionality of lldb-server",
"pexpect": "Tests requiring the pexpect library to be available",
"objc": "Tests related to the Objective-C programming language support",
Expand Down
34 changes: 17 additions & 17 deletions lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def read_packet(f, verbose=False, trace_file=None):
if verbose:
print('json: "%s"' % (json_str))
if trace_file:
trace_file.write("from adaptor:\n%s\n" % (json_str))
trace_file.write("from adapter:\n%s\n" % (json_str))
# Decode the JSON bytes into a python dictionary
return json.loads(json_str)

Expand Down Expand Up @@ -259,23 +259,23 @@ def handle_recv_packet(self, packet):
def send_packet(self, command_dict, set_sequence=True):
"""Take the "command_dict" python dictionary and encode it as a JSON
string and send the contents as a packet to the VSCode debug
adaptor"""
adapter"""
# Set the sequence ID for this command automatically
if set_sequence:
command_dict["seq"] = self.sequence
self.sequence += 1
# Encode our command dictionary as a JSON string
json_str = json.dumps(command_dict, separators=(",", ":"))
if self.trace_file:
self.trace_file.write("to adaptor:\n%s\n" % (json_str))
self.trace_file.write("to adapter:\n%s\n" % (json_str))
length = len(json_str)
if length > 0:
# Send the encoded JSON packet and flush the 'send' file
self.send.write(self.encode_content(json_str))
self.send.flush()

def recv_packet(self, filter_type=None, filter_event=None, timeout=None):
"""Get a JSON packet from the VSCode debug adaptor. This function
"""Get a JSON packet from the VSCode debug adapter. This function
assumes a thread that reads packets is running and will deliver
any received packets by calling handle_recv_packet(...). This
function will wait for the packet to arrive and return it when
Expand Down Expand Up @@ -1184,7 +1184,7 @@ def request_setInstructionBreakpoints(self, memory_reference=[]):
return self.send_recv(command_dict)


class DebugAdaptorServer(DebugCommunication):
class DebugAdapterServer(DebugCommunication):
def __init__(
self,
executable=None,
Expand All @@ -1196,7 +1196,7 @@ def __init__(
self.process = None
self.connection = None
if executable is not None:
process, connection = DebugAdaptorServer.launch(
process, connection = DebugAdapterServer.launch(
executable=executable, connection=connection, env=env, log_file=log_file
)
self.process = process
Expand Down Expand Up @@ -1224,12 +1224,12 @@ def __init__(

@classmethod
def launch(cls, /, executable, env=None, log_file=None, connection=None):
adaptor_env = os.environ.copy()
adapter_env = os.environ.copy()
if env is not None:
adaptor_env.update(env)
adapter_env.update(env)

if log_file:
adaptor_env["LLDBDAP_LOG"] = log_file
adapter_env["LLDBDAP_LOG"] = log_file
args = [executable]

if connection is not None:
Expand All @@ -1241,7 +1241,7 @@ def launch(cls, /, executable, env=None, log_file=None, connection=None):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=adaptor_env,
env=adapter_env,
)

if connection is None:
Expand Down Expand Up @@ -1271,7 +1271,7 @@ def get_pid(self):
return -1

def terminate(self):
super(DebugAdaptorServer, self).terminate()
super(DebugAdapterServer, self).terminate()
if self.process is not None:
self.process.terminate()
self.process.wait()
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def run_vscode(dbg, args, options):
def main():
parser = optparse.OptionParser(
description=(
"A testing framework for the Visual Studio Code Debug Adaptor protocol"
"A testing framework for the Visual Studio Code Debug Adapter protocol"
)
)

Expand All @@ -1357,7 +1357,7 @@ def main():
dest="vscode_path",
help=(
"The path to the command line program that implements the "
"Visual Studio Code Debug Adaptor protocol."
"Visual Studio Code Debug Adapter protocol."
),
default=None,
)
Expand Down Expand Up @@ -1407,7 +1407,7 @@ def main():
dest="replay",
help=(
"Specify a file containing a packet log to replay with the "
"current Visual Studio Code Debug Adaptor executable."
"current Visual Studio Code Debug Adapter executable."
),
default=None,
)
Expand All @@ -1418,7 +1418,7 @@ def main():
action="store_true",
dest="debug",
default=False,
help="Pause waiting for a debugger to attach to the debug adaptor",
help="Pause waiting for a debugger to attach to the debug adapter",
)

parser.add_option(
Expand Down Expand Up @@ -1581,11 +1581,11 @@ def main():
if options.vscode_path is None and options.connection is None:
print(
"error: must either specify a path to a Visual Studio Code "
"Debug Adaptor vscode executable path using the --vscode "
"Debug Adapter vscode executable path using the --vscode "
"option, or using the --connection option"
)
return
dbg = DebugAdaptorServer(
dbg = DebugAdapterServer(
executable=options.vscode_path, connection=options.connection
)
if options.debug:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ class DAPTestCaseBase(TestBase):
timeoutval = 10 * (10 if ("ASAN_OPTIONS" in os.environ) else 1)
NO_DEBUG_INFO_TESTCASE = True

def create_debug_adaptor(self, lldbDAPEnv=None, connection=None):
"""Create the Visual Studio Code debug adaptor"""
def create_debug_adapter(self, lldbDAPEnv=None, connection=None):
"""Create the Visual Studio Code debug adapter"""
self.assertTrue(
is_exe(self.lldbDAPExec), "lldb-dap must exist and be executable"
)
log_file_path = self.getBuildArtifact("dap.txt")
self.dap_server = dap_server.DebugAdaptorServer(
self.dap_server = dap_server.DebugAdapterServer(
executable=self.lldbDAPExec,
connection=connection,
init_commands=self.setUpCommands(),
log_file=log_file_path,
env=lldbDAPEnv,
)

def build_and_create_debug_adaptor(self, lldbDAPEnv=None):
def build_and_create_debug_adapter(self, lldbDAPEnv=None):
self.build()
self.create_debug_adaptor(lldbDAPEnv)
self.create_debug_adapter(lldbDAPEnv)

def set_source_breakpoints(self, source_path, lines, data=None):
"""Sets source breakpoints and returns an array of strings containing
Expand Down Expand Up @@ -324,11 +324,11 @@ def attach(
gdbRemotePort=None,
gdbRemoteHostname=None,
):
"""Build the default Makefile target, create the DAP debug adaptor,
"""Build the default Makefile target, create the DAP debug adapter,
and attach to the process.
"""

# Make sure we disconnect and terminate the DAP debug adaptor even
# Make sure we disconnect and terminate the DAP debug adapter even
# if we throw an exception during the test case.
def cleanup():
if disconnectAutomatically:
Expand Down Expand Up @@ -479,10 +479,10 @@ def build_and_launch(
launchCommands=None,
expectFailure=False,
):
"""Build the default Makefile target, create the DAP debug adaptor,
"""Build the default Makefile target, create the DAP debug adapter,
and launch the process.
"""
self.build_and_create_debug_adaptor(lldbDAPEnv)
self.build_and_create_debug_adapter(lldbDAPEnv)
self.assertTrue(os.path.exists(program), "executable must exist")

return self.launch(
Expand Down
10 changes: 5 additions & 5 deletions lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_by_pid(self):
"""
Tests attaching to a process by process ID.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")
self.process = subprocess.Popen(
[program],
Expand All @@ -60,7 +60,7 @@ def test_by_name(self):
"""
Tests attaching to a process by process name.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
orig_program = self.getBuildArtifact("a.out")
# Since we are going to attach by process name, we need a unique
# process name that has minimal chance to match a process that is
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_by_name_waitFor(self):
next instance of a process to be launched, ingoring all current
ones.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")
self.spawn_thread = threading.Thread(
target=spawn_and_wait,
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_commands(self):
"terminateCommands" are a list of LLDB commands that get executed when
the debugger session terminates.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")
# Here we just create a target and launch the process as a way to test
# if we are able to use attach commands to create any kind of a target
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_terminate_commands(self):
Tests that the "terminateCommands", that can be passed during
attach, are run when the debugger is disconnected.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")
# Here we just create a target and launch the process as a way to test
# if we are able to use attach commands to create any kind of a target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_by_port(self):
"""
Tests attaching to a process by port.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")

debug_server_tool = self.getBuiltinDebugServerTool()
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_by_port_and_pid(self):
"""
Tests attaching to a process by process ID and port number.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")

# It is not necessary to launch "lldb-server" to obtain the actual port and pid for attaching.
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_by_invalid_port(self):
"""
Tests attaching to a process by invalid port number 0.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")

port = 0
Expand All @@ -139,7 +139,7 @@ def test_by_illegal_port(self):
"""
Tests attaching to a process by illegal/greater port number 65536
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
program = self.getBuildArtifact("a.out")

port = 65536
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_breakpoint_events(self):
foo_bp1_line = line_number("foo.cpp", "foo breakpoint 1")
foo_bp2_line = line_number("foo.cpp", "foo breakpoint 2")

# Visual Studio Code Debug Adaptors have no way to specify the file
# Visual Studio Code Debug Adapters have no way to specify the file
# without launching or attaching to a process, so we must start a
# process in order to be able to set breakpoints.
program = self.getBuildArtifact("a.out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_source_map(self):
with the corresponding source maps to have breakpoints and frames
working.
"""
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()

other_basename = "other-copy.c"
other_path = self.getBuildArtifact(other_basename)
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_source_map(self):
@skipIfWindows
def test_set_and_clear(self):
"""Tests setting and clearing source file and line breakpoints.
This packet is a bit tricky on the debug adaptor side since there
This packet is a bit tricky on the debug adapter side since there
is no "clearBreakpoints" packet. Source file and line breakpoints
are set by sending a "setBreakpoints" packet with a source file
specified and zero or more source lines. If breakpoints have been
Expand All @@ -116,7 +116,7 @@ def test_set_and_clear(self):
third_line = line_number("main.cpp", "break 14")
lines = [first_line, third_line, second_line]

# Visual Studio Code Debug Adaptors have no way to specify the file
# Visual Studio Code Debug Adapters have no way to specify the file
# without launching or attaching to a process, so we must start a
# process in order to be able to set breakpoints.
program = self.getBuildArtifact("a.out")
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_clear_breakpoints_unset_breakpoints(self):
line_number("main.cpp", "break 13"),
]

# Visual Studio Code Debug Adaptors have no way to specify the file
# Visual Studio Code Debug Adapters have no way to specify the file
# without launching or attaching to a process, so we must start a
# process in order to be able to set breakpoints.
program = self.getBuildArtifact("a.out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestDAP_setExceptionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
@skipIfWindows
def test_functionality(self):
"""Tests setting and clearing exception breakpoints.
This packet is a bit tricky on the debug adaptor side since there
This packet is a bit tricky on the debug adapter side since there
is no "clear exception breakpoints" packet. Exception breakpoints
are set by sending a "setExceptionBreakpoints" packet with zero or
more exception filters. If exception breakpoints have been set
Expand All @@ -26,7 +26,7 @@ def test_functionality(self):
and the functionality of each breakpoint, like 'conditions' and
x'hitCondition' settings.
"""
# Visual Studio Code Debug Adaptors have no way to specify the file
# Visual Studio Code Debug Adapters have no way to specify the file
# without launching or attaching to a process, so we must start a
# process in order to be able to set breakpoints.
program = self.getBuildArtifact("a.out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestDAP_setFunctionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
@skipIfWindows
def test_set_and_clear(self):
"""Tests setting and clearing function breakpoints.
This packet is a bit tricky on the debug adaptor side since there
This packet is a bit tricky on the debug adapter side since there
is no "clearFunction Breakpoints" packet. Function breakpoints
are set by sending a "setFunctionBreakpoints" packet with zero or
more function names. If function breakpoints have been set before,
Expand All @@ -25,7 +25,7 @@ def test_set_and_clear(self):
correctly. It doesn't test hitting breakpoints and the functionality
of each breakpoint, like 'conditions' and 'hitCondition' settings.
"""
# Visual Studio Code Debug Adaptors have no way to specify the file
# Visual Studio Code Debug Adapters have no way to specify the file
# without launching or attaching to a process, so we must start a
# process in order to be able to set breakpoints.
program = self.getBuildArtifact("a.out")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_command_directive_abort_on_error_attach_commands(self):
"settings set target.show-hex-variable-values-with-leading-zeroes false"
)
command_abort_on_error = "settings set foo bar"
self.build_and_create_debug_adaptor()
self.build_and_create_debug_adapter()
self.attach(
program,
attachCommands=["?!" + command_quiet, "!" + command_abort_on_error],
Expand Down
Loading