Skip to content

Commit

Permalink
[lldb] Rename lldb-vscode to lldb-dap (#69264)
Browse files Browse the repository at this point in the history
Rename lldb-vscode to lldb-dap. This change is largely mechanical. The
following substitutions cover the majority of the changes in this
commit:

  s/VSCODE/DAP/
  s/VSCode/DAP/
  s/vscode/dap/
  s/g_vsc/g_dap/

Discourse RFC:
https://discourse.llvm.org/t/rfc-rename-lldb-vscode-to-lldb-dap/74075/
  • Loading branch information
JDevlieghere committed Oct 19, 2023
1 parent 0446c58 commit 01263c6
Show file tree
Hide file tree
Showing 135 changed files with 1,043 additions and 1,040 deletions.
20 changes: 10 additions & 10 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Expand Up @@ -485,15 +485,15 @@ def setupSysPath():
os.environ["LLDB_SRC"] = lldbsuite.lldb_root

pluginPath = os.path.join(scriptPath, "plugins")
toolsLLDBVSCode = os.path.join(scriptPath, "tools", "lldb-vscode")
toolsLLDBDAP = os.path.join(scriptPath, "tools", "lldb-dap")
toolsLLDBServerPath = os.path.join(scriptPath, "tools", "lldb-server")
intelpt = os.path.join(scriptPath, "tools", "intelpt")

# Insert script dir, plugin dir and lldb-server dir to the sys.path.
sys.path.insert(0, pluginPath)
# Adding test/tools/lldb-vscode to the path makes it easy to
# "import lldb_vscode_testcase" from the VSCode tests
sys.path.insert(0, toolsLLDBVSCode)
# Adding test/tools/lldb-dap to the path makes it easy to
# "import lldb_dap_testcase" from the DAP tests
sys.path.insert(0, toolsLLDBDAP)
# Adding test/tools/lldb-server to the path makes it easy
# to "import lldbgdbserverutils" from the lldb-server tests
sys.path.insert(0, toolsLLDBServerPath)
Expand Down Expand Up @@ -538,15 +538,15 @@ def setupSysPath():

lldbDir = os.path.dirname(lldbtest_config.lldbExec)

lldbVSCodeExec = os.path.join(lldbDir, "lldb-vscode")
if is_exe(lldbVSCodeExec):
os.environ["LLDBVSCODE_EXEC"] = lldbVSCodeExec
lldbDAPExec = os.path.join(lldbDir, "lldb-dap")
if is_exe(lldbDAPExec):
os.environ["LLDBDAP_EXEC"] = lldbDAPExec
else:
if not configuration.shouldSkipBecauseOfCategories(["lldb-vscode"]):
if not configuration.shouldSkipBecauseOfCategories(["lldb-dap"]):
print(
"The 'lldb-vscode' executable cannot be located. The lldb-vscode tests can not be run as a result."
"The 'lldb-dap' executable cannot be located. The lldb-dap tests can not be run as a result."
)
configuration.skip_categories.append("lldb-vscode")
configuration.skip_categories.append("lldb-dap")

lldbPythonDir = None # The directory that contains 'lldb/__init__.py'

Expand Down
6 changes: 3 additions & 3 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Expand Up @@ -801,10 +801,10 @@ def setUp(self):
else:
self.libcxxPath = None

if "LLDBVSCODE_EXEC" in os.environ:
self.lldbVSCodeExec = os.environ["LLDBVSCODE_EXEC"]
if "LLDBDAP_EXEC" in os.environ:
self.lldbDAPExec = os.environ["LLDBDAP_EXEC"]
else:
self.lldbVSCodeExec = None
self.lldbDAPExec = None

self.lldbOption = " ".join("-o '" + s + "'" for s in self.setUpCommands())

Expand Down
2 changes: 1 addition & 1 deletion lldb/packages/Python/lldbsuite/test/test_categories.py
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-vscode": "Visual Studio Code debug adaptor tests",
"lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap",
"llgs": "Tests for the gdb-server functionality of lldb-server",
"objc": "Tests related to the Objective-C programming language support",
"pyapi": "Tests related to the Python API",
Expand Down
Expand Up @@ -1013,7 +1013,7 @@ def terminate(self):
# self.recv.close()


class DebugAdaptor(DebugCommunication):
class DebugAdaptorServer(DebugCommunication):
def __init__(
self, executable=None, port=None, init_commands=[], log_file=None, env=None
):
Expand All @@ -1024,7 +1024,7 @@ def __init__(
adaptor_env.update(env)

if log_file:
adaptor_env["LLDBVSCODE_LOG"] = log_file
adaptor_env["LLDBDAP_LOG"] = log_file
self.process = subprocess.Popen(
[executable],
stdin=subprocess.PIPE,
Expand All @@ -1048,7 +1048,7 @@ def get_pid(self):
return -1

def terminate(self):
super(DebugAdaptor, self).terminate()
super(DebugAdaptorServer, self).terminate()
if self.process is not None:
self.process.terminate()
self.process.wait()
Expand Down Expand Up @@ -1364,7 +1364,7 @@ def main():
"using the --port option"
)
return
dbg = DebugAdaptor(executable=options.vscode_path, port=options.port)
dbg = DebugAdaptorServer(executable=options.vscode_path, port=options.port)
if options.debug:
raw_input('Waiting for debugger to attach pid "%i"' % (dbg.get_pid()))
if options.replay:
Expand Down
@@ -1,29 +1,29 @@
import os
import time

import vscode
import dap_server
from lldbsuite.test.lldbtest import *


class VSCodeTestCaseBase(TestBase):
class DAPTestCaseBase(TestBase):
NO_DEBUG_INFO_TESTCASE = True

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

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

def set_source_breakpoints(self, source_path, lines, data=None):
"""Sets source breakpoints and returns an array of strings containing
Expand All @@ -32,7 +32,7 @@ def set_source_breakpoints(self, source_path, lines, data=None):
Each object in data is 1:1 mapping with the entry in lines.
It contains optional location/hitCondition/logMessage parameters.
"""
response = self.vscode.request_setBreakpoints(source_path, lines, data)
response = self.dap_server.request_setBreakpoints(source_path, lines, data)
if response is None:
return []
breakpoints = response["body"]["breakpoints"]
Expand All @@ -46,7 +46,7 @@ def set_function_breakpoints(self, functions, condition=None, hitCondition=None)
and returns an array of strings containing the breakpoint IDs
("1", "2") for each breakpoint that was set.
"""
response = self.vscode.request_setFunctionBreakpoints(
response = self.dap_server.request_setFunctionBreakpoints(
functions, condition=condition, hitCondition=hitCondition
)
if response is None:
Expand All @@ -70,7 +70,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
"breakpoint_ids" should be a list of breakpoint ID strings
(["1", "2"]). The return value from self.set_source_breakpoints()
or self.set_function_breakpoints() can be passed to this function"""
stopped_events = self.vscode.wait_for_stopped()
stopped_events = self.dap_server.wait_for_stopped()
for stopped_event in stopped_events:
if "body" in stopped_event:
body = stopped_event["body"]
Expand All @@ -83,7 +83,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
# Descriptions for breakpoints will be in the form
# "breakpoint 1.1", so look for any description that matches
# ("breakpoint 1.") in the description field as verification
# that one of the breakpoint locations was hit. VSCode doesn't
# that one of the breakpoint locations was hit. DAP doesn't
# allow breakpoints to have multiple locations, but LLDB does.
# So when looking at the description we just want to make sure
# the right breakpoint matches and not worry about the actual
Expand All @@ -100,7 +100,7 @@ def verify_stop_exception_info(self, expected_description):
reason is 'exception' and that the description matches
'expected_description'
"""
stopped_events = self.vscode.wait_for_stopped()
stopped_events = self.dap_server.wait_for_stopped()
for stopped_event in stopped_events:
if "body" in stopped_event:
body = stopped_event["body"]
Expand Down Expand Up @@ -150,7 +150,7 @@ def get_dict_value(self, d, key_path):
def get_stackFrames_and_totalFramesCount(
self, threadId=None, startFrame=None, levels=None, dump=False
):
response = self.vscode.request_stackTrace(
response = self.dap_server.request_stackTrace(
threadId=threadId, startFrame=startFrame, levels=levels, dump=dump
)
if response:
Expand Down Expand Up @@ -185,16 +185,16 @@ def get_source_and_line(self, threadId=None, frameIndex=0):
return ("", 0)

def get_stdout(self, timeout=0.0):
return self.vscode.get_output("stdout", timeout=timeout)
return self.dap_server.get_output("stdout", timeout=timeout)

def get_console(self, timeout=0.0):
return self.vscode.get_output("console", timeout=timeout)
return self.dap_server.get_output("console", timeout=timeout)

def collect_console(self, duration):
return self.vscode.collect_output("console", duration=duration)
return self.dap_server.collect_output("console", duration=duration)

def get_local_as_int(self, name, threadId=None):
value = self.vscode.get_local_variable_value(name, threadId=threadId)
value = self.dap_server.get_local_variable_value(name, threadId=threadId)
if value.startswith("0x"):
return int(value, 16)
elif value.startswith("0"):
Expand All @@ -204,48 +204,48 @@ def get_local_as_int(self, name, threadId=None):

def set_local(self, name, value, id=None):
"""Set a top level local variable only."""
return self.vscode.request_setVariable(1, name, str(value), id=id)
return self.dap_server.request_setVariable(1, name, str(value), id=id)

def set_global(self, name, value, id=None):
"""Set a top level global variable only."""
return self.vscode.request_setVariable(2, name, str(value), id=id)
return self.dap_server.request_setVariable(2, name, str(value), id=id)

def stepIn(self, threadId=None, waitForStop=True):
self.vscode.request_stepIn(threadId=threadId)
self.dap_server.request_stepIn(threadId=threadId)
if waitForStop:
return self.vscode.wait_for_stopped()
return self.dap_server.wait_for_stopped()
return None

def stepOver(self, threadId=None, waitForStop=True):
self.vscode.request_next(threadId=threadId)
self.dap_server.request_next(threadId=threadId)
if waitForStop:
return self.vscode.wait_for_stopped()
return self.dap_server.wait_for_stopped()
return None

def stepOut(self, threadId=None, waitForStop=True):
self.vscode.request_stepOut(threadId=threadId)
self.dap_server.request_stepOut(threadId=threadId)
if waitForStop:
return self.vscode.wait_for_stopped()
return self.dap_server.wait_for_stopped()
return None

def continue_to_next_stop(self):
self.vscode.request_continue()
return self.vscode.wait_for_stopped()
self.dap_server.request_continue()
return self.dap_server.wait_for_stopped()

def continue_to_breakpoints(self, breakpoint_ids):
self.vscode.request_continue()
self.dap_server.request_continue()
self.verify_breakpoint_hit(breakpoint_ids)

def continue_to_exception_breakpoint(self, filter_label):
self.vscode.request_continue()
self.dap_server.request_continue()
self.assertTrue(
self.verify_stop_exception_info(filter_label),
'verify we got "%s"' % (filter_label),
)

def continue_to_exit(self, exitCode=0):
self.vscode.request_continue()
stopped_events = self.vscode.wait_for_stopped()
self.dap_server.request_continue()
stopped_events = self.dap_server.wait_for_stopped()
self.assertEquals(
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
)
Expand All @@ -266,10 +266,10 @@ def disassemble(self, threadId=None, frameIndex=None):
memoryReference = stackFrames[0]["instructionPointerReference"]
self.assertIsNotNone(memoryReference)

if memoryReference not in self.vscode.disassembled_instructions:
self.vscode.request_disassemble(memoryReference=memoryReference)
if memoryReference not in self.dap_server.disassembled_instructions:
self.dap_server.request_disassemble(memoryReference=memoryReference)

return self.vscode.disassembled_instructions[memoryReference]
return self.dap_server.disassembled_instructions[memoryReference]

def attach(
self,
Expand All @@ -289,22 +289,22 @@ def attach(
sourceMap=None,
sourceInitFile=False,
):
"""Build the default Makefile target, create the VSCode debug adaptor,
"""Build the default Makefile target, create the DAP debug adaptor,
and attach to the process.
"""

# Make sure we disconnect and terminate the VSCode debug adaptor even
# Make sure we disconnect and terminate the DAP debug adaptor even
# if we throw an exception during the test case.
def cleanup():
if disconnectAutomatically:
self.vscode.request_disconnect(terminateDebuggee=True)
self.vscode.terminate()
self.dap_server.request_disconnect(terminateDebuggee=True)
self.dap_server.terminate()

# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
# Initialize and launch the program
self.vscode.request_initialize(sourceInitFile)
response = self.vscode.request_attach(
self.dap_server.request_initialize(sourceInitFile)
response = self.dap_server.request_attach(
program=program,
pid=pid,
waitFor=waitFor,
Expand Down Expand Up @@ -352,21 +352,21 @@ def launch(
enableAutoVariableSummaries=False,
enableSyntheticChildDebugging=False,
):
"""Sending launch request to vscode"""
"""Sending launch request to dap"""

# Make sure we disconnect and terminate the VSCode debug adapter,
# Make sure we disconnect and terminate the DAP debug adapter,
# if we throw an exception during the test case
def cleanup():
if disconnectAutomatically:
self.vscode.request_disconnect(terminateDebuggee=True)
self.vscode.terminate()
self.dap_server.request_disconnect(terminateDebuggee=True)
self.dap_server.terminate()

# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)

# Initialize and launch the program
self.vscode.request_initialize(sourceInitFile)
response = self.vscode.request_launch(
self.dap_server.request_initialize(sourceInitFile)
response = self.dap_server.request_launch(
program,
args=args,
cwd=cwd,
Expand Down Expand Up @@ -422,14 +422,14 @@ def build_and_launch(
runInTerminal=False,
disconnectAutomatically=True,
postRunCommands=None,
lldbVSCodeEnv=None,
lldbDAPEnv=None,
enableAutoVariableSummaries=False,
enableSyntheticChildDebugging=False,
):
"""Build the default Makefile target, create the VSCode debug adaptor,
"""Build the default Makefile target, create the DAP debug adaptor,
and launch the process.
"""
self.build_and_create_debug_adaptor(lldbVSCodeEnv)
self.build_and_create_debug_adaptor(lldbDAPEnv)
self.assertTrue(os.path.exists(program), "executable must exist")

return self.launch(
Expand Down

0 comments on commit 01263c6

Please sign in to comment.