diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index a27d8cf321f82..a639714480cf4 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -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) @@ -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' diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index c8670b208ec3f..6d736a56ecb89 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -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()) diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py index 3883c4de5e199..3f8de175e29df 100644 --- a/lldb/packages/Python/lldbsuite/test/test_categories.py +++ b/lldb/packages/Python/lldbsuite/test/test_categories.py @@ -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", diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py similarity index 99% rename from lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py rename to lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 5ee0800b27a56..ca11f34be450c 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -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 ): @@ -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, @@ -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() @@ -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: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py similarity index 82% rename from lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py rename to lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 8cd4e8454c890..3094b66af4792 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -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 @@ -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"] @@ -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: @@ -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"] @@ -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 @@ -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"] @@ -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: @@ -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"): @@ -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) ) @@ -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, @@ -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, @@ -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, @@ -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( diff --git a/lldb/test/API/tools/lldb-vscode/attach/Makefile b/lldb/test/API/tools/lldb-dap/attach/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/attach/Makefile rename to lldb/test/API/tools/lldb-dap/attach/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py similarity index 96% rename from lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py rename to lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index a53dac77e39d3..04017a0521e95 100644 --- a/lldb/test/API/tools/lldb-vscode/attach/TestVSCode_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -1,13 +1,13 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os import shutil import subprocess @@ -25,7 +25,7 @@ def spawn_and_wait(program, delay): process.wait() -class TestVSCode_attach(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_attach(lldbdap_testcase.DAPTestCaseBase): def set_and_hit_breakpoint(self, continueToExit=True): source = "main.c" breakpoint1_line = line_number(source, "// breakpoint 1") @@ -190,10 +190,10 @@ def test_commands(self): # Continue after launch and hit the "pause()" call and stop the target. # Get output from the console. This should contain both the # "stopCommands" that were run after we stop. - self.vscode.request_continue() + self.dap_server.request_continue() time.sleep(0.5) - self.vscode.request_pause() - self.vscode.wait_for_stopped() + self.dap_server.request_pause() + self.dap_server.wait_for_stopped() output = self.get_console(timeout=1.0) self.verify_commands("stopCommands", output, stopCommands) @@ -236,6 +236,6 @@ def test_terminate_commands(self): self.get_console() # Once it's disconnected the console should contain the # "terminateCommands" - self.vscode.request_disconnect(terminateDebuggee=True) + self.dap_server.request_disconnect(terminateDebuggee=True) output = self.collect_console(duration=1.0) self.verify_commands("terminateCommands", output, terminateCommands) diff --git a/lldb/test/API/tools/lldb-vscode/attach/main.c b/lldb/test/API/tools/lldb-dap/attach/main.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/attach/main.c rename to lldb/test/API/tools/lldb-dap/attach/main.c diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint-events/Makefile b/lldb/test/API/tools/lldb-dap/breakpoint-events/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/breakpoint-events/Makefile rename to lldb/test/API/tools/lldb-dap/breakpoint-events/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py b/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py similarity index 83% rename from lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py rename to lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py index 51996d03d9b17..a20384b75f5c0 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_breakpointEvents(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_breakpointEvents(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipUnlessDarwin @expectedFailureAll(macos_version=[">=", "13.0"]) @@ -48,7 +48,7 @@ def test_breakpoint_events(self): # Set a breakpoint after creating the target by running a command line # command. It will eventually resolve and cause a breakpoint changed - # event to be sent to lldb-vscode. We want to make sure we don't send a + # event to be sent to lldb-dap. We want to make sure we don't send a # breakpoint any breakpoints that were set from the command line. # Breakpoints that are set via the VS code DAP packets will be # registered and marked with a special keyword to ensure we deliver @@ -59,24 +59,28 @@ def test_breakpoint_events(self): main_bp_id = 0 foo_bp_id = 0 # Set breakpoints and verify that they got set correctly - vscode_breakpoint_ids = [] - response = self.vscode.request_setBreakpoints(main_source_path, [main_bp_line]) + dap_breakpoint_ids = [] + response = self.dap_server.request_setBreakpoints( + main_source_path, [main_bp_line] + ) if response: breakpoints = response["body"]["breakpoints"] for breakpoint in breakpoints: main_bp_id = breakpoint["id"] - vscode_breakpoint_ids.append("%i" % (main_bp_id)) + dap_breakpoint_ids.append("%i" % (main_bp_id)) # line = breakpoint['line'] self.assertTrue( breakpoint["verified"], "expect main breakpoint to be verified" ) - response = self.vscode.request_setBreakpoints(foo_source_path, [foo_bp1_line]) + response = self.dap_server.request_setBreakpoints( + foo_source_path, [foo_bp1_line] + ) if response: breakpoints = response["body"]["breakpoints"] for breakpoint in breakpoints: foo_bp_id = breakpoint["id"] - vscode_breakpoint_ids.append("%i" % (foo_bp_id)) + dap_breakpoint_ids.append("%i" % (foo_bp_id)) self.assertFalse( breakpoint["verified"], "expect foo breakpoint to not be verified" ) @@ -88,21 +92,23 @@ def test_breakpoint_events(self): # libraries are not loaded yet (at least on macOS they aren't) and any # breakpoints set in foo.cpp should not be resolved. self.assertEqual( - len(self.vscode.breakpoint_events), + len(self.dap_server.breakpoint_events), 0, "no breakpoint events when stopped at entry point", ) # Continue to the breakpoint - self.continue_to_breakpoints(vscode_breakpoint_ids) + self.continue_to_breakpoints(dap_breakpoint_ids) # Make sure we only get an event for the breakpoint we set via a call - # to self.vscode.request_setBreakpoints(...), not the breakpoint + # to self.dap_server.request_setBreakpoints(...), not the breakpoint # we set with with a LLDB command in preRunCommands. self.assertEqual( - len(self.vscode.breakpoint_events), 1, "make sure we got a breakpoint event" + len(self.dap_server.breakpoint_events), + 1, + "make sure we got a breakpoint event", ) - event = self.vscode.breakpoint_events[0] + event = self.dap_server.breakpoint_events[0] # Verify the details of the breakpoint changed notification. body = event["body"] self.assertEqual( diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint-events/foo.cpp b/lldb/test/API/tools/lldb-dap/breakpoint-events/foo.cpp similarity index 91% rename from lldb/test/API/tools/lldb-vscode/breakpoint-events/foo.cpp rename to lldb/test/API/tools/lldb-dap/breakpoint-events/foo.cpp index fa4f5657e69b2..7a4f90d7dd581 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint-events/foo.cpp +++ b/lldb/test/API/tools/lldb-dap/breakpoint-events/foo.cpp @@ -7,5 +7,5 @@ static void unique_function_name() { int foo(int x) { // foo breakpoint 1 unique_function_name(); - return x+42; + return x + 42; } diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint-events/foo.h b/lldb/test/API/tools/lldb-dap/breakpoint-events/foo.h similarity index 100% rename from lldb/test/API/tools/lldb-vscode/breakpoint-events/foo.h rename to lldb/test/API/tools/lldb-dap/breakpoint-events/foo.h diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint-events/main.cpp b/lldb/test/API/tools/lldb-dap/breakpoint-events/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/breakpoint-events/main.cpp rename to lldb/test/API/tools/lldb-dap/breakpoint-events/main.cpp diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/Makefile b/lldb/test/API/tools/lldb-dap/breakpoint/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/breakpoint/Makefile rename to lldb/test/API/tools/lldb-dap/breakpoint/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py similarity index 94% rename from lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py rename to lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py index f530542749f7d..25e794a49d3ac 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_logpoints.py @@ -1,20 +1,20 @@ """ -Test lldb-vscode logpoints feature. +Test lldb-dap logpoints feature. """ -import vscode +import dap_server import shutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_logpoints(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_logpoints(lldbdap_testcase.DAPTestCaseBase): def setUp(self): - lldbvscode_testcase.VSCodeTestCaseBase.setUp(self) + lldbdap_testcase.DAPTestCaseBase.setUp(self) self.main_basename = "main-copy.cpp" self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename)) @@ -36,7 +36,7 @@ def test_logmessage_basic(self): ) self.assertEquals(len(before_loop_breakpoint_ids), 1, "expect one breakpoint") - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint before loop line self.verify_breakpoint_hit(before_loop_breakpoint_ids) @@ -56,7 +56,7 @@ def test_logmessage_basic(self): ) # Continue to trigger the breakpoint with log messages - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint after loop line self.verify_breakpoint_hit([post_loop_breakpoint_id]) @@ -94,7 +94,7 @@ def test_logmessage_advanced(self): ) self.assertEquals(len(before_loop_breakpoint_ids), 1, "expect one breakpoint") - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint before loop line self.verify_breakpoint_hit(before_loop_breakpoint_ids) @@ -117,7 +117,7 @@ def test_logmessage_advanced(self): ) # Continue to trigger the breakpoint with log messages - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint after loop line self.verify_breakpoint_hit([post_loop_breakpoint_id]) @@ -157,7 +157,7 @@ def test_logmessage_format(self): ) self.assertEquals(len(before_loop_breakpoint_ids), 1, "expect one breakpoint") - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint before loop line self.verify_breakpoint_hit(before_loop_breakpoint_ids) @@ -179,7 +179,7 @@ def test_logmessage_format(self): ) # Continue to trigger the breakpoint with log messages - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint after loop line self.verify_breakpoint_hit([post_loop_breakpoint_id]) @@ -222,7 +222,7 @@ def test_logmessage_format_failure(self): ) self.assertEquals(len(before_loop_breakpoint_ids), 1, "expect one breakpoint") - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint before loop line self.verify_breakpoint_hit(before_loop_breakpoint_ids) @@ -244,7 +244,7 @@ def test_logmessage_format_failure(self): ) # Continue to trigger the breakpoint with log messages - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit logpoint breakpoint if it's format has error. self.verify_breakpoint_hit([loop_breakpoint_id]) diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py similarity index 89% rename from lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py rename to lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py index a918ed42f5a07..3d3252a78b19a 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setBreakpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py @@ -1,20 +1,20 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server import shutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase): def setUp(self): - lldbvscode_testcase.VSCodeTestCaseBase.setUp(self) + lldbdap_testcase.DAPTestCaseBase.setUp(self) self.main_basename = "main-copy.cpp" self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename)) @@ -58,7 +58,7 @@ def test_source_map(self): self.launch(program, sourceMap=source_map) # breakpoint in main.cpp - response = self.vscode.request_setBreakpoints(new_main_path, [main_line]) + response = self.dap_server.request_setBreakpoints(new_main_path, [main_line]) breakpoints = response["body"]["breakpoints"] self.assertEquals(len(breakpoints), 1) breakpoint = breakpoints[0] @@ -68,7 +68,7 @@ def test_source_map(self): self.assertEqual(new_main_path, breakpoint["source"]["path"]) # 2nd breakpoint, which is from a dynamically loaded library - response = self.vscode.request_setBreakpoints(new_other_path, [other_line]) + response = self.dap_server.request_setBreakpoints(new_other_path, [other_line]) breakpoints = response["body"]["breakpoints"] breakpoint = breakpoints[0] self.assertEqual(breakpoint["line"], other_line) @@ -77,11 +77,11 @@ def test_source_map(self): self.assertEqual(new_other_path, breakpoint["source"]["path"]) other_breakpoint_id = breakpoint["id"] - self.vscode.request_continue() + self.dap_server.request_continue() self.verify_breakpoint_hit([other_breakpoint_id]) # 2nd breakpoint again, which should be valid at this point - response = self.vscode.request_setBreakpoints(new_other_path, [other_line]) + response = self.dap_server.request_setBreakpoints(new_other_path, [other_line]) breakpoints = response["body"]["breakpoints"] breakpoint = breakpoints[0] self.assertEqual(breakpoint["line"], other_line) @@ -90,7 +90,7 @@ def test_source_map(self): self.assertEqual(new_other_path, breakpoint["source"]["path"]) # now we check the stack trace making sure that we got mapped source paths - frames = self.vscode.request_stackTrace()["body"]["stackFrames"] + frames = self.dap_server.request_stackTrace()["body"]["stackFrames"] self.assertEqual(frames[0]["source"]["name"], other_basename) self.assertEqual(frames[0]["source"]["path"], new_other_path) @@ -125,7 +125,7 @@ def test_set_and_clear(self): self.build_and_launch(program) # Set 3 breakpoints and verify that they got set correctly - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) line_to_id = {} if response: breakpoints = response["body"]["breakpoints"] @@ -152,7 +152,7 @@ def test_set_and_clear(self): lines.remove(second_line) # Set 2 breakpoints and verify that the previous breakpoints that were # set above are still set. - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -179,7 +179,7 @@ def test_set_and_clear(self): # we have only 2 breakpoints set. The response above could have told # us about 2 breakpoints, but we want to make sure we don't have the # third one still set in the target - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -204,7 +204,7 @@ def test_set_and_clear(self): # Now clear all breakpoints for the source file by passing down an # empty lines array lines = [] - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -214,7 +214,7 @@ def test_set_and_clear(self): ) # Verify with the target that all breakpoints have been cleared - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -226,7 +226,7 @@ def test_set_and_clear(self): # Now set a breakpoint again in the same source file and verify it # was added. lines = [second_line] - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -245,7 +245,7 @@ def test_set_and_clear(self): # we have only 2 breakpoints set. The response above could have told # us about 2 breakpoints, but we want to make sure we don't have the # third one still set in the target - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -278,7 +278,7 @@ def test_clear_breakpoints_unset_breakpoints(self): self.build_and_launch(program) # Set one breakpoint and verify that it got set correctly. - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) line_to_id = {} breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -295,12 +295,12 @@ def test_clear_breakpoints_unset_breakpoints(self): # Now clear all breakpoints for the source file by not setting the # lines array. lines = None - response = self.vscode.request_setBreakpoints(self.main_path, lines) + response = self.dap_server.request_setBreakpoints(self.main_path, lines) breakpoints = response["body"]["breakpoints"] self.assertEquals(len(breakpoints), 0, "expect no source breakpoints") # Verify with the target that all breakpoints have been cleared. - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() breakpoints = response["body"]["breakpoints"] self.assertEquals(len(breakpoints), 0, "expect no source breakpoints") @@ -317,13 +317,13 @@ def test_functionality(self): # hitCondition breakpoint_ids = self.set_source_breakpoints(self.main_path, [loop_line]) self.assertEquals(len(breakpoint_ids), 1, "expect one breakpoint") - self.vscode.request_continue() + self.dap_server.request_continue() # Verify we hit the breakpoint we just set self.verify_breakpoint_hit(breakpoint_ids) # Make sure i is zero at first breakpoint - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 0, "i != 0 after hitting breakpoint") # Update the condition on our breakpoint @@ -337,7 +337,7 @@ def test_functionality(self): ) self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 4, "i != 4 showing conditional works") new_breakpoint_ids = self.set_source_breakpoints( @@ -352,11 +352,11 @@ def test_functionality(self): # Continue with a hitCondition of 2 and expect it to skip 1 value self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 6, "i != 6 showing hitCondition works") # continue after hitting our hitCondition and make sure it only goes # up by 1 self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 7, "i != 7 showing post hitCondition hits every time") diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py similarity index 86% rename from lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py rename to lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py index 9ce9b1144d04c..84d3f12490f3e 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setExceptionBreakpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py @@ -1,16 +1,16 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_setExceptionBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_setExceptionBreakpoints(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_functionality(self): @@ -34,7 +34,7 @@ def test_functionality(self): self.build_and_launch(program) filters = ["cpp_throw", "cpp_catch"] - response = self.vscode.request_setExceptionBreakpoints(filters) + response = self.dap_server.request_setExceptionBreakpoints(filters) if response: self.assertTrue(response["success"]) diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py similarity index 88% rename from lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py rename to lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py index 8748d0526a0e1..f90dc0f041ecb 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_setFunctionBreakpoints.py +++ b/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py @@ -1,16 +1,16 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_setFunctionBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_setFunctionBreakpoints(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_set_and_clear(self): @@ -34,7 +34,7 @@ def test_set_and_clear(self): bp_id_12 = None functions = ["twelve"] # Set a function breakpoint at 'twelve' - response = self.vscode.request_setFunctionBreakpoints(functions) + response = self.dap_server.request_setFunctionBreakpoints(functions) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -48,7 +48,7 @@ def test_set_and_clear(self): # Add an extra name and make sure we have two breakpoints after this functions.append("thirteen") - response = self.vscode.request_setFunctionBreakpoints(functions) + response = self.dap_server.request_setFunctionBreakpoints(functions) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -62,7 +62,7 @@ def test_set_and_clear(self): # There is no breakpoint delete packet, clients just send another # setFunctionBreakpoints packet with the different function names. functions.remove("thirteen") - response = self.vscode.request_setFunctionBreakpoints(functions) + response = self.dap_server.request_setFunctionBreakpoints(functions) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -83,7 +83,7 @@ def test_set_and_clear(self): # we have only 1 breakpoints set. The response above could have told # us about 1 breakpoints, but we want to make sure we don't have the # second one still set in the target - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -103,7 +103,7 @@ def test_set_and_clear(self): # Now clear all breakpoints for the source file by passing down an # empty lines array functions = [] - response = self.vscode.request_setFunctionBreakpoints(functions) + response = self.dap_server.request_setFunctionBreakpoints(functions) if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -113,7 +113,7 @@ def test_set_and_clear(self): ) # Verify with the target that all breakpoints have been cleared - response = self.vscode.request_testGetTargetBreakpoints() + response = self.dap_server.request_testGetTargetBreakpoints() if response: breakpoints = response["body"]["breakpoints"] self.assertEquals( @@ -140,7 +140,7 @@ def test_functionality(self): self.continue_to_breakpoints(breakpoint_ids) # Make sure i is zero at first breakpoint - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 0, "i != 0 after hitting breakpoint") # Update the condition on our breakpoint @@ -152,7 +152,7 @@ def test_functionality(self): ) self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 4, "i != 4 showing conditional works") new_breakpoint_ids = self.set_function_breakpoints(functions, hitCondition="2") @@ -164,11 +164,11 @@ def test_functionality(self): # Continue with a hitCondition of 2 and expect it to skip 1 value self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 6, "i != 6 showing hitCondition works") # continue after hitting our hitCondition and make sure it only goes # up by 1 self.continue_to_breakpoints(breakpoint_ids) - i = int(self.vscode.get_local_variable_value("i")) + i = int(self.dap_server.get_local_variable_value("i")) self.assertEquals(i, 7, "i != 7 showing post hitCondition hits every time") diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp b/lldb/test/API/tools/lldb-dap/breakpoint/main.cpp similarity index 82% rename from lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp rename to lldb/test/API/tools/lldb-dap/breakpoint/main.cpp index d4e0ac26dd11a..935a63fab6d0c 100644 --- a/lldb/test/API/tools/lldb-vscode/breakpoint/main.cpp +++ b/lldb/test/API/tools/lldb-dap/breakpoint/main.cpp @@ -11,10 +11,10 @@ int thirteen(int i) { } namespace a { - int fourteen(int i) { - return 14 + i; // break 14 - } +int fourteen(int i) { + return 14 + i; // break 14 } +} // namespace a int main(int argc, char const *argv[]) { #if defined(__APPLE__) const char *libother_name = "libother.dylib"; @@ -35,11 +35,11 @@ int main(int argc, char const *argv[]) { } foo(12); // before loop - for (int i=0; i<10; ++i) { + for (int i = 0; i < 10; ++i) { int x = twelve(i) + thirteen(i) + a::fourteen(i); // break loop } try { - throw std::invalid_argument( "throwing exception for testing" ); + throw std::invalid_argument("throwing exception for testing"); } catch (...) { puts("caught exception..."); } diff --git a/lldb/test/API/tools/lldb-vscode/breakpoint/other.c b/lldb/test/API/tools/lldb-dap/breakpoint/other.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/breakpoint/other.c rename to lldb/test/API/tools/lldb-dap/breakpoint/other.c diff --git a/lldb/test/API/tools/lldb-dap/categories b/lldb/test/API/tools/lldb-dap/categories new file mode 100644 index 0000000000000..0902bbb595aa6 --- /dev/null +++ b/lldb/test/API/tools/lldb-dap/categories @@ -0,0 +1 @@ +lldb-dap diff --git a/lldb/test/API/tools/lldb-vscode/completions/Makefile b/lldb/test/API/tools/lldb-dap/completions/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/completions/Makefile rename to lldb/test/API/tools/lldb-dap/completions/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py similarity index 81% rename from lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py rename to lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py index 1b44c3c99361e..5f6d63392f4d5 100644 --- a/lldb/test/API/tools/lldb-vscode/completions/TestVSCode_completions.py +++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py @@ -1,16 +1,16 @@ """ -Test lldb-vscode completions request +Test lldb-dap completions request """ -import lldbvscode_testcase -import vscode +import lldbdap_testcase +import dap_server from lldbsuite.test import lldbutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -class TestVSCode_completions(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase): def verify_completions(self, actual_list, expected_list, not_expected_list=[]): for expected_item in expected_list: self.assertIn(expected_item, actual_list) @@ -36,7 +36,7 @@ def test_completions(self): # shouldn't see variables inside main self.verify_completions( - self.vscode.get_completions("var"), + self.dap_server.get_completions("var"), [ { "text": "var", @@ -54,7 +54,7 @@ def test_completions(self): # should see global keywords but not variables inside main self.verify_completions( - self.vscode.get_completions("str"), + self.dap_server.get_completions("str"), [{"text": "struct", "label": "struct"}], [{"text": "str1", "label": "str1 -- std::string &"}], ) @@ -63,7 +63,7 @@ def test_completions(self): # should see variables from main but not from the other function self.verify_completions( - self.vscode.get_completions("var"), + self.dap_server.get_completions("var"), [ {"text": "var1", "label": "var1 -- int &"}, {"text": "var2", "label": "var2 -- int &"}, @@ -77,7 +77,7 @@ def test_completions(self): ) self.verify_completions( - self.vscode.get_completions("str"), + self.dap_server.get_completions("str"), [ {"text": "struct", "label": "struct"}, {"text": "str1", "label": "str1 -- string &"}, @@ -86,19 +86,19 @@ def test_completions(self): # should complete arbitrary commands including word starts self.verify_completions( - self.vscode.get_completions("`log enable "), + self.dap_server.get_completions("`log enable "), [{"text": "gdb-remote", "label": "gdb-remote"}], ) # should complete expressions with quotes inside self.verify_completions( - self.vscode.get_completions('`expr " "; typed'), + self.dap_server.get_completions('`expr " "; typed'), [{"text": "typedef", "label": "typedef"}], ) # should complete an incomplete quoted token self.verify_completions( - self.vscode.get_completions('`setting "se'), + self.dap_server.get_completions('`setting "se'), [ { "text": "set", @@ -107,7 +107,7 @@ def test_completions(self): ], ) self.verify_completions( - self.vscode.get_completions("`'comm"), + self.dap_server.get_completions("`'comm"), [ { "text": "command", @@ -117,34 +117,34 @@ def test_completions(self): ) self.verify_completions( - self.vscode.get_completions("foo1.v"), + self.dap_server.get_completions("foo1.v"), [{"text": "var1", "label": "foo1.var1 -- int"}], ) self.verify_completions( - self.vscode.get_completions("foo1.my_bar_object.v"), + self.dap_server.get_completions("foo1.my_bar_object.v"), [{"text": "var1", "label": "foo1.my_bar_object.var1 -- int"}], ) self.verify_completions( - self.vscode.get_completions("foo1.var1 + foo1.v"), + self.dap_server.get_completions("foo1.var1 + foo1.v"), [{"text": "var1", "label": "foo1.var1 -- int"}], ) self.verify_completions( - self.vscode.get_completions("foo1.var1 + v"), + self.dap_server.get_completions("foo1.var1 + v"), [{"text": "var1", "label": "var1 -- int &"}], ) # should correctly handle spaces between objects and member operators self.verify_completions( - self.vscode.get_completions("foo1 .v"), + self.dap_server.get_completions("foo1 .v"), [{"text": "var1", "label": ".var1 -- int"}], [{"text": "var2", "label": ".var2 -- int"}], ) self.verify_completions( - self.vscode.get_completions("foo1 . v"), + self.dap_server.get_completions("foo1 . v"), [{"text": "var1", "label": "var1 -- int"}], [{"text": "var2", "label": "var2 -- int"}], ) diff --git a/lldb/test/API/tools/lldb-vscode/completions/main.cpp b/lldb/test/API/tools/lldb-dap/completions/main.cpp similarity index 81% rename from lldb/test/API/tools/lldb-vscode/completions/main.cpp rename to lldb/test/API/tools/lldb-dap/completions/main.cpp index dccf43ff6feb8..4314067cfe951 100644 --- a/lldb/test/API/tools/lldb-vscode/completions/main.cpp +++ b/lldb/test/API/tools/lldb-dap/completions/main.cpp @@ -7,9 +7,9 @@ struct bar { struct foo { int var1; - bar* my_bar_pointer; + bar *my_bar_pointer; bar my_bar_object; - foo* next_foo; + foo *next_foo; }; struct baz { @@ -28,7 +28,7 @@ int main(int argc, char const *argv[]) { std::vector vec; fun(vec); bar bar1 = {2}; - bar* bar2 = &bar1; - foo foo1 = {3,&bar1, bar1, NULL}; + bar *bar2 = &bar1; + foo foo1 = {3, &bar1, bar1, NULL}; return 0; // breakpoint 2 } diff --git a/lldb/test/API/tools/lldb-vscode/console/Makefile b/lldb/test/API/tools/lldb-dap/console/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/console/Makefile rename to lldb/test/API/tools/lldb-dap/console/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py similarity index 83% rename from lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py rename to lldb/test/API/tools/lldb-dap/console/TestDAP_console.py index d28e98b37c589..47c706f2ca721 100644 --- a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_console.py +++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py @@ -1,17 +1,19 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_console(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_console(lldbdap_testcase.DAPTestCaseBase): def check_lldb_command(self, lldb_command, contains_string, assert_msg): - response = self.vscode.request_evaluate("`%s" % (lldb_command), context="repl") + response = self.dap_server.request_evaluate( + "`%s" % (lldb_command), context="repl" + ) output = response["body"]["result"] self.assertIn( contains_string, @@ -29,8 +31,8 @@ def test_scopes_variables_setVariable_evaluate(self): """ Tests that the "scopes" request causes the currently selected thread and frame to be updated. There are no DAP packets that tell - lldb-vscode which thread and frame are selected other than the - "scopes" request. lldb-vscode will now select the thread and frame + lldb-dap which thread and frame are selected other than the + "scopes" request. lldb-dap will now select the thread and frame for the latest "scopes" request that it receives. The LLDB command interpreter needs to have the right thread and @@ -52,7 +54,7 @@ def test_scopes_variables_setVariable_evaluate(self): self.continue_to_breakpoints(breakpoint_ids) # Cause a "scopes" to be sent for frame zero which should update the # selected thread and frame to frame 0. - self.vscode.get_local_variables(frameIndex=0) + self.dap_server.get_local_variables(frameIndex=0) # Verify frame #0 is selected in the command interpreter by running # the "frame select" command with no frame index which will print the # currently selected frame. @@ -60,7 +62,7 @@ def test_scopes_variables_setVariable_evaluate(self): # Cause a "scopes" to be sent for frame one which should update the # selected thread and frame to frame 1. - self.vscode.get_local_variables(frameIndex=1) + self.dap_server.get_local_variables(frameIndex=1) # Verify frame #1 is selected in the command interpreter by running # the "frame select" command with no frame index which will print the # currently selected frame. diff --git a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_redirection_to_console.py b/lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py similarity index 66% rename from lldb/test/API/tools/lldb-vscode/console/TestVSCode_redirection_to_console.py rename to lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py index 27b0215c54430..85911a449efef 100644 --- a/lldb/test/API/tools/lldb-vscode/console/TestVSCode_redirection_to_console.py +++ b/lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py @@ -1,12 +1,12 @@ -import vscode +import dap_server import json from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_redirection_to_console(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_redirection_to_console(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test(self): @@ -14,11 +14,11 @@ def test(self): Without proper stderr and stdout redirection, the following code would throw an exception, like the following: - Exception: unexpected malformed message from lldb-vscode + Exception: unexpected malformed message from lldb-dap """ program = self.getBuildArtifact("a.out") self.build_and_launch( - program, lldbVSCodeEnv={"LLDB_VSCODE_TEST_STDOUT_STDERR_REDIRECTION": ""} + program, lldbDAPEnv={"LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION": ""} ) source = "main.cpp" @@ -29,4 +29,6 @@ def test(self): self.assertEqual(len(breakpoint_ids), 1, "expect correct number of breakpoints") self.continue_to_breakpoints(breakpoint_ids) - self.assertIn("argc", json.dumps(self.vscode.get_local_variables(frameIndex=1))) + self.assertIn( + "argc", json.dumps(self.dap_server.get_local_variables(frameIndex=1)) + ) diff --git a/lldb/test/API/tools/lldb-vscode/console/main.cpp b/lldb/test/API/tools/lldb-dap/console/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/console/main.cpp rename to lldb/test/API/tools/lldb-dap/console/main.cpp diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py similarity index 92% rename from lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py rename to lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py index 8cbdb8fa7e98a..2ac1f39772bbc 100644 --- a/lldb/test/API/tools/lldb-vscode/coreFile/TestVSCode_coreFile.py +++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode coreFile attaching +Test lldb-dap coreFile attaching """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_coreFile(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote @skipIfLLVMTargetMissing("X86") @@ -53,7 +53,7 @@ def test_core_file(self): self.continue_to_next_stop() self.assertEquals(self.get_stackFrames(), expected_frames) - self.vscode.request_next(threadId=32259) + self.dap_server.request_next(threadId=32259) self.assertEquals(self.get_stackFrames(), expected_frames) @skipIfWindows diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/linux-x86_64.core b/lldb/test/API/tools/lldb-dap/coreFile/linux-x86_64.core similarity index 100% rename from lldb/test/API/tools/lldb-vscode/coreFile/linux-x86_64.core rename to lldb/test/API/tools/lldb-dap/coreFile/linux-x86_64.core diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/linux-x86_64.out b/lldb/test/API/tools/lldb-dap/coreFile/linux-x86_64.out similarity index 100% rename from lldb/test/API/tools/lldb-vscode/coreFile/linux-x86_64.out rename to lldb/test/API/tools/lldb-dap/coreFile/linux-x86_64.out diff --git a/lldb/test/API/tools/lldb-vscode/coreFile/main.c b/lldb/test/API/tools/lldb-dap/coreFile/main.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/coreFile/main.c rename to lldb/test/API/tools/lldb-dap/coreFile/main.c diff --git a/lldb/test/API/tools/lldb-vscode/correct-thread/Makefile b/lldb/test/API/tools/lldb-dap/correct-thread/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/correct-thread/Makefile rename to lldb/test/API/tools/lldb-dap/correct-thread/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/correct-thread/TestVSCode_correct_thread.py b/lldb/test/API/tools/lldb-dap/correct-thread/TestDAP_correct_thread.py similarity index 86% rename from lldb/test/API/tools/lldb-vscode/correct-thread/TestVSCode_correct_thread.py rename to lldb/test/API/tools/lldb-dap/correct-thread/TestDAP_correct_thread.py index 5318163465e4e..43d3b02e408c7 100644 --- a/lldb/test/API/tools/lldb-vscode/correct-thread/TestVSCode_correct_thread.py +++ b/lldb/test/API/tools/lldb-dap/correct-thread/TestDAP_correct_thread.py @@ -1,15 +1,15 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_correct_thread(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_correct_thread(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_correct_thread(self): @@ -33,8 +33,8 @@ def test_correct_thread(self): # We're now stopped at the breakpoint in the first thread, thread #2. # Continue to join the first thread and hit the breakpoint in the # second thread, thread #3. - self.vscode.request_continue() - stopped_event = self.vscode.wait_for_stopped() + self.dap_server.request_continue() + stopped_event = self.dap_server.wait_for_stopped() # Verify that the description is the relevant breakpoint, # preserveFocusHint is False and threadCausedFocus is True self.assertTrue( diff --git a/lldb/test/API/tools/lldb-vscode/correct-thread/main.c b/lldb/test/API/tools/lldb-dap/correct-thread/main.c similarity index 84% rename from lldb/test/API/tools/lldb-vscode/correct-thread/main.c rename to lldb/test/API/tools/lldb-dap/correct-thread/main.c index 157c3f994db1e..3eeb1ef02cb87 100644 --- a/lldb/test/API/tools/lldb-vscode/correct-thread/main.c +++ b/lldb/test/API/tools/lldb-dap/correct-thread/main.c @@ -3,14 +3,12 @@ int state_var; -void *thread (void *in) -{ +void *thread(void *in) { state_var++; // break here return NULL; } -int main(int argc, char **argv) -{ +int main(int argc, char **argv) { pthread_t t1, t2; pthread_create(&t1, NULL, *thread, NULL); diff --git a/lldb/test/API/tools/lldb-vscode/disassemble/Makefile b/lldb/test/API/tools/lldb-dap/disassemble/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/disassemble/Makefile rename to lldb/test/API/tools/lldb-dap/disassemble/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/disassemble/TestVSCode_disassemble.py b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py similarity index 89% rename from lldb/test/API/tools/lldb-vscode/disassemble/TestVSCode_disassemble.py rename to lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py index 521e8bf56a1d4..cb4e946c52112 100644 --- a/lldb/test/API/tools/lldb-vscode/disassemble/TestVSCode_disassemble.py +++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode disassemble request +Test lldb-dap disassemble request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_disassemble(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_disassemble(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_disassemble(self): diff --git a/lldb/test/API/tools/lldb-dap/disassemble/main.c b/lldb/test/API/tools/lldb-dap/disassemble/main.c new file mode 100644 index 0000000000000..6609a4c37a70f --- /dev/null +++ b/lldb/test/API/tools/lldb-dap/disassemble/main.c @@ -0,0 +1,30 @@ +#include +#include +#include + +int compare_ints(const void *a, const void *b) { + int arg1 = *(const int *)a; + int arg2 = *(const int *)b; + + // breakpoint 1 + + if (arg1 < arg2) + return -1; + if (arg1 > arg2) + return 1; + return 0; +} + +int main(void) { + int ints[] = {-2, 99, 0, -743, 2, INT_MIN, 4}; + int size = sizeof ints / sizeof *ints; + + qsort(ints, size, sizeof(int), compare_ints); + + for (int i = 0; i < size; i++) { + printf("%d ", ints[i]); + } + + printf("\n"); + return 0; +} \ No newline at end of file diff --git a/lldb/test/API/tools/lldb-vscode/disconnect/Makefile b/lldb/test/API/tools/lldb-dap/disconnect/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/disconnect/Makefile rename to lldb/test/API/tools/lldb-dap/disconnect/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py b/lldb/test/API/tools/lldb-dap/disconnect/TestDAP_disconnect.py similarity index 87% rename from lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py rename to lldb/test/API/tools/lldb-dap/disconnect/TestDAP_disconnect.py index bc7b74e5039b4..e5aab88c7fa46 100644 --- a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py +++ b/lldb/test/API/tools/lldb-dap/disconnect/TestDAP_disconnect.py @@ -1,23 +1,23 @@ """ -Test lldb-vscode disconnect request +Test lldb-dap disconnect request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import subprocess import time import os -class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase): source = "main.cpp" def disconnect_and_assert_no_output_printed(self): - self.vscode.request_disconnect() + self.dap_server.request_disconnect() # verify we didn't get any input after disconnect time.sleep(2) output = self.get_stdout() @@ -40,7 +40,7 @@ def test_launch(self): ) self.continue_to_next_stop() - self.vscode.request_disconnect() + self.dap_server.request_disconnect() # verify we didn't produce the side effect file time.sleep(1) self.assertFalse(os.path.exists(program + ".side_effect")) @@ -69,13 +69,13 @@ def test_attach(self): lldbutil.wait_for_file_on_target(self, sync_file_path) self.attach(pid=self.process.pid, disconnectAutomatically=False) - response = self.vscode.request_evaluate("wait_for_attach = false;") + response = self.dap_server.request_evaluate("wait_for_attach = false;") self.assertTrue(response["success"]) # verify we haven't produced the side effect file yet self.assertFalse(os.path.exists(program + ".side_effect")) - self.vscode.request_disconnect() + self.dap_server.request_disconnect() time.sleep(2) # verify we produced the side effect file, as the program continued after disconnecting self.assertTrue(os.path.exists(program + ".side_effect")) diff --git a/lldb/test/API/tools/lldb-vscode/disconnect/main.cpp b/lldb/test/API/tools/lldb-dap/disconnect/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/disconnect/main.cpp rename to lldb/test/API/tools/lldb-dap/disconnect/main.cpp diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/Makefile b/lldb/test/API/tools/lldb-dap/evaluate/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/evaluate/Makefile rename to lldb/test/API/tools/lldb-dap/evaluate/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py similarity index 95% rename from lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py rename to lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py index d1b73e1a057e1..de9d2c93a1109 100644 --- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py +++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py @@ -1,19 +1,19 @@ """ -Test lldb-vscode completions request +Test lldb-dap completions request """ -import lldbvscode_testcase -import vscode +import lldbdap_testcase +import dap_server from lldbsuite.test import lldbutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase): def assertEvaluate(self, expression, regex): self.assertRegexpMatches( - self.vscode.request_evaluate(expression, context=self.context)["body"][ + self.dap_server.request_evaluate(expression, context=self.context)["body"][ "result" ], regex, @@ -22,7 +22,7 @@ def assertEvaluate(self, expression, regex): def assertEvaluateFailure(self, expression): self.assertNotIn( "result", - self.vscode.request_evaluate(expression, context=self.context)["body"], + self.dap_server.request_evaluate(expression, context=self.context)["body"], ) def isExpressionParsedExpected(self): diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/foo.cpp b/lldb/test/API/tools/lldb-dap/evaluate/foo.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/evaluate/foo.cpp rename to lldb/test/API/tools/lldb-dap/evaluate/foo.cpp diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/foo.h b/lldb/test/API/tools/lldb-dap/evaluate/foo.h similarity index 100% rename from lldb/test/API/tools/lldb-vscode/evaluate/foo.h rename to lldb/test/API/tools/lldb-dap/evaluate/foo.h diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp b/lldb/test/API/tools/lldb-dap/evaluate/main.cpp similarity index 94% rename from lldb/test/API/tools/lldb-vscode/evaluate/main.cpp rename to lldb/test/API/tools/lldb-dap/evaluate/main.cpp index f09d00e6444bb..ca27b5ba5ca19 100644 --- a/lldb/test/API/tools/lldb-vscode/evaluate/main.cpp +++ b/lldb/test/API/tools/lldb-dap/evaluate/main.cpp @@ -1,7 +1,7 @@ #include "foo.h" -#include #include +#include static int static_int = 42; @@ -43,7 +43,7 @@ int main(int argc, char const *argv[]) { std::vector my_bool_vec; my_bool_vec.push_back(true); my_bool_vec.push_back(false); // breakpoint 6 - my_bool_vec.push_back(true); // breakpoint 7 + my_bool_vec.push_back(true); // breakpoint 7 return 0; } diff --git a/lldb/test/API/tools/lldb-vscode/exception/Makefile b/lldb/test/API/tools/lldb-dap/exception/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/exception/Makefile rename to lldb/test/API/tools/lldb-dap/exception/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py b/lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py similarity index 74% rename from lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py rename to lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py index f52daaa713a6b..8c2c0154ba65c 100644 --- a/lldb/test/API/tools/lldb-vscode/exception/TestVSCode_exception.py +++ b/lldb/test/API/tools/lldb-dap/exception/TestDAP_exception.py @@ -1,14 +1,14 @@ """ -Test exception behavior in VSCode +Test exception behavior in DAP """ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_exception(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_exception(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows def test_stopped_description(self): """ @@ -19,5 +19,5 @@ def test_stopped_description(self): print("test_stopped_description called", flush=True) self.build_and_launch(program) - self.vscode.request_continue() + self.dap_server.request_continue() self.assertTrue(self.verify_stop_exception_info("signal SIGABRT")) diff --git a/lldb/test/API/tools/lldb-vscode/exception/main.cpp b/lldb/test/API/tools/lldb-dap/exception/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/exception/main.cpp rename to lldb/test/API/tools/lldb-dap/exception/main.cpp diff --git a/lldb/test/API/tools/lldb-vscode/launch/Makefile b/lldb/test/API/tools/lldb-dap/launch/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/launch/Makefile rename to lldb/test/API/tools/lldb-dap/launch/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py similarity index 94% rename from lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py rename to lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 39845468888fb..7895861225369 100644 --- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -1,18 +1,18 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import time import os -class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_default(self): @@ -33,22 +33,22 @@ def test_default(self): @skipIfRemote def test_termination(self): """ - Tests the correct termination of lldb-vscode upon a 'disconnect' + Tests the correct termination of lldb-dap upon a 'disconnect' request. """ self.create_debug_adaptor() - # The underlying lldb-vscode process must be alive - self.assertEqual(self.vscode.process.poll(), None) + # The underlying lldb-dap process must be alive + self.assertEqual(self.dap_server.process.poll(), None) - # The lldb-vscode process should finish even though + # The lldb-dap process should finish even though # we didn't close the communication socket explicitly - self.vscode.request_disconnect() + self.dap_server.request_disconnect() - # Wait until the underlying lldb-vscode process dies. - self.vscode.process.wait(timeout=10) + # Wait until the underlying lldb-dap process dies. + self.dap_server.process.wait(timeout=10) # Check the return code - self.assertEqual(self.vscode.process.poll(), 0) + self.assertEqual(self.dap_server.process.poll(), 0) @skipIfWindows @skipIfRemote @@ -102,7 +102,7 @@ def test_cwd(self): def test_debuggerRoot(self): """ Tests the "debuggerRoot" will change the working directory of - the lldb-vscode debug adaptor. + the lldb-dap debug adaptor. """ program = self.getBuildArtifact("a.out") program_parent_dir = os.path.realpath(os.path.dirname(os.path.dirname(program))) @@ -121,10 +121,10 @@ def test_debuggerRoot(self): self.assertEquals( program_parent_dir, line[len(prefix) :], - "lldb-vscode working dir '%s' == '%s'" + "lldb-dap working dir '%s' == '%s'" % (program_parent_dir, line[6:]), ) - self.assertTrue(found, "verified lldb-vscode working directory") + self.assertTrue(found, "verified lldb-dap working directory") self.continue_to_exit() @skipIfWindows @@ -148,7 +148,7 @@ def test_sourcePath(self): self.assertEquals( quoted_path, line[len(prefix) :], - "lldb-vscode working dir %s == %s" % (quoted_path, line[6:]), + "lldb-dap working dir %s == %s" % (quoted_path, line[6:]), ) self.assertTrue(found, 'found "sourcePath" in console output') self.continue_to_exit() @@ -440,6 +440,6 @@ def test_terminate_commands(self): self.get_console() # Once it's disconnected the console should contain the # "terminateCommands" - self.vscode.request_disconnect(terminateDebuggee=True) + self.dap_server.request_disconnect(terminateDebuggee=True) output = self.collect_console(duration=1.0) self.verify_commands("terminateCommands", output, terminateCommands) diff --git a/lldb/test/API/tools/lldb-vscode/launch/main.c b/lldb/test/API/tools/lldb-dap/launch/main.c similarity index 77% rename from lldb/test/API/tools/lldb-vscode/launch/main.c rename to lldb/test/API/tools/lldb-dap/launch/main.c index aed2af9828f34..01e209ac12c66 100644 --- a/lldb/test/API/tools/lldb-vscode/launch/main.c +++ b/lldb/test/API/tools/lldb-dap/launch/main.c @@ -3,13 +3,13 @@ #include int main(int argc, char const *argv[], char const *envp[]) { - for (int i=0; i 0) # We verify we were able to set the launch arguments - argc = int(self.vscode.get_local_variable_value("argc")) + argc = int(self.dap_server.get_local_variable_value("argc")) self.assertEqual(argc, 2) - argv1 = self.vscode.request_evaluate("argv[1]")["body"]["result"] + argv1 = self.dap_server.request_evaluate("argv[1]")["body"]["result"] self.assertIn("foobar", argv1) # We verify we were able to set the environment - env = self.vscode.request_evaluate("foo")["body"]["result"] + env = self.dap_server.request_evaluate("foo")["body"]["result"] self.assertIn("bar", env) @skipIfWindows @@ -116,7 +118,7 @@ def test_missingArgInRunInTerminalLauncher(self): if not self.isTestSupported(): return proc = subprocess.run( - [self.lldbVSCodeExec, "--launch-target", "INVALIDPROGRAM"], + [self.lldbDAPExec, "--launch-target", "INVALIDPROGRAM"], capture_output=True, universal_newlines=True, ) @@ -136,7 +138,7 @@ def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self): proc = subprocess.Popen( [ - self.lldbVSCodeExec, + self.lldbDAPExec, "--comm-file", comm_file, "--launch-target", @@ -164,7 +166,7 @@ def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self): proc = subprocess.Popen( [ - self.lldbVSCodeExec, + self.lldbDAPExec, "--comm-file", comm_file, "--launch-target", @@ -191,7 +193,7 @@ def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self): os.mkfifo(comm_file) proc = subprocess.Popen( - [self.lldbVSCodeExec, "--comm-file", comm_file, "--launch-target", "env"], + [self.lldbDAPExec, "--comm-file", comm_file, "--launch-target", "env"], universal_newlines=True, stdout=subprocess.PIPE, env={**os.environ, "FOO": "BAR"}, @@ -214,7 +216,7 @@ def test_NonAttachedRunInTerminalLauncher(self): proc = subprocess.Popen( [ - self.lldbVSCodeExec, + self.lldbDAPExec, "--comm-file", comm_file, "--launch-target", @@ -223,7 +225,7 @@ def test_NonAttachedRunInTerminalLauncher(self): ], universal_newlines=True, stderr=subprocess.PIPE, - env={**os.environ, "LLDB_VSCODE_RIT_TIMEOUT_IN_MS": "1000"}, + env={**os.environ, "LLDB_DAP_RIT_TIMEOUT_IN_MS": "1000"}, ) self.readPidMessage(comm_file) diff --git a/lldb/test/API/tools/lldb-vscode/runInTerminal/main.c b/lldb/test/API/tools/lldb-dap/runInTerminal/main.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/runInTerminal/main.c rename to lldb/test/API/tools/lldb-dap/runInTerminal/main.c diff --git a/lldb/test/API/tools/lldb-vscode/stackTrace/Makefile b/lldb/test/API/tools/lldb-dap/stackTrace/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/stackTrace/Makefile rename to lldb/test/API/tools/lldb-dap/stackTrace/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py similarity index 97% rename from lldb/test/API/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py rename to lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py index fa9e9f30cef2f..245b3f34b70c8 100644 --- a/lldb/test/API/tools/lldb-vscode/stackTrace/TestVSCode_stackTrace.py +++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import os -class TestVSCode_stackTrace(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_stackTrace(lldbdap_testcase.DAPTestCaseBase): name_key_path = ["name"] source_key_path = ["source", "path"] line_key_path = ["line"] diff --git a/lldb/test/API/tools/lldb-vscode/stackTrace/main.c b/lldb/test/API/tools/lldb-dap/stackTrace/main.c similarity index 65% rename from lldb/test/API/tools/lldb-vscode/stackTrace/main.c rename to lldb/test/API/tools/lldb-dap/stackTrace/main.c index 85b41c492817f..862473a3e6ac8 100644 --- a/lldb/test/API/tools/lldb-vscode/stackTrace/main.c +++ b/lldb/test/API/tools/lldb-dap/stackTrace/main.c @@ -3,8 +3,8 @@ int recurse(int x) { if (x <= 1) - return 1; // recurse end - return recurse(x-1) + x; // recurse call + return 1; // recurse end + return recurse(x - 1) + x; // recurse call } int main(int argc, char const *argv[]) { diff --git a/lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/Makefile b/lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/Makefile rename to lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/TestVSCode_stackTraceMissingFunctionName.py b/lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py similarity index 77% rename from lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/TestVSCode_stackTraceMissingFunctionName.py rename to lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py index 8e7da6386d8e5..344629c1d5dad 100644 --- a/lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/TestVSCode_stackTraceMissingFunctionName.py +++ b/lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/TestDAP_stackTraceMissingFunctionName.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode stack trace response +Test lldb-dap stack trace response """ -import vscode +import dap_server from lldbsuite.test.decorators import * import os -import lldbvscode_testcase +import lldbdap_testcase from lldbsuite.test import lldbtest, lldbutil -class TestVSCode_stackTraceMissingFunctionName(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_stackTraceMissingFunctionName(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_missingFunctionName(self): diff --git a/lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/main.cpp b/lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/stackTraceMissingFunctionName/main.cpp rename to lldb/test/API/tools/lldb-dap/stackTraceMissingFunctionName/main.cpp diff --git a/lldb/test/API/tools/lldb-vscode/startDebugging/Makefile b/lldb/test/API/tools/lldb-dap/startDebugging/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/startDebugging/Makefile rename to lldb/test/API/tools/lldb-dap/startDebugging/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/startDebugging/TestVSCode_startDebugging.py b/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py similarity index 64% rename from lldb/test/API/tools/lldb-vscode/startDebugging/TestVSCode_startDebugging.py rename to lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py index d8bc910c35233..fd48e69cae5e2 100644 --- a/lldb/test/API/tools/lldb-vscode/startDebugging/TestVSCode_startDebugging.py +++ b/lldb/test/API/tools/lldb-dap/startDebugging/TestDAP_startDebugging.py @@ -1,16 +1,16 @@ """ -Test lldb-vscode startDebugging reverse request +Test lldb-dap startDebugging reverse request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_startDebugging(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_startDebugging(lldbdap_testcase.DAPTestCaseBase): def test_startDebugging(self): """ Tests the "startDebugging" reverse request. It makes sure that the IDE can @@ -24,16 +24,18 @@ def test_startDebugging(self): self.set_source_breakpoints(source, [breakpoint_line]) self.continue_to_next_stop() - self.vscode.request_evaluate( - "`lldb-vscode startDebugging attach '{\"pid\":321}'", context="repl" + self.dap_server.request_evaluate( + "`lldb-dap startDebugging attach '{\"pid\":321}'", context="repl" ) self.continue_to_exit() self.assertEqual( - len(self.vscode.reverse_requests), 1, "make sure we got a reverse request" + len(self.dap_server.reverse_requests), + 1, + "make sure we got a reverse request", ) - request = self.vscode.reverse_requests[0] + request = self.dap_server.reverse_requests[0] self.assertEqual(request["arguments"]["configuration"]["pid"], 321) self.assertEqual(request["arguments"]["request"], "attach") diff --git a/lldb/test/API/tools/lldb-vscode/startDebugging/main.c b/lldb/test/API/tools/lldb-dap/startDebugging/main.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/startDebugging/main.c rename to lldb/test/API/tools/lldb-dap/startDebugging/main.c diff --git a/lldb/test/API/tools/lldb-vscode/step/Makefile b/lldb/test/API/tools/lldb-dap/step/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/step/Makefile rename to lldb/test/API/tools/lldb-dap/step/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/step/TestVSCode_step.py b/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py similarity index 94% rename from lldb/test/API/tools/lldb-vscode/step/TestVSCode_step.py rename to lldb/test/API/tools/lldb-dap/step/TestDAP_step.py index 14dd20d0b8af3..578e64e36ea05 100644 --- a/lldb/test/API/tools/lldb-vscode/step/TestVSCode_step.py +++ b/lldb/test/API/tools/lldb-dap/step/TestDAP_step.py @@ -1,16 +1,16 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_step(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_step(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_step(self): @@ -29,7 +29,7 @@ def test_step(self): len(breakpoint_ids), len(lines), "expect correct number of breakpoints" ) self.continue_to_breakpoints(breakpoint_ids) - threads = self.vscode.get_threads() + threads = self.dap_server.get_threads() for thread in threads: if "reason" in thread: reason = thread["reason"] diff --git a/lldb/test/API/tools/lldb-dap/step/main.cpp b/lldb/test/API/tools/lldb-dap/step/main.cpp new file mode 100644 index 0000000000000..8905beb5e7eff --- /dev/null +++ b/lldb/test/API/tools/lldb-dap/step/main.cpp @@ -0,0 +1,8 @@ +int function(int x) { + if ((x % 2) == 0) + return function(x - 1) + x; // breakpoint 1 + else + return x; +} + +int main(int argc, char const *argv[]) { return function(2); } diff --git a/lldb/test/API/tools/lldb-vscode/stop-hooks/Makefile b/lldb/test/API/tools/lldb-dap/stop-hooks/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/stop-hooks/Makefile rename to lldb/test/API/tools/lldb-dap/stop-hooks/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/stop-hooks/TestVSCode_stop_hooks.py b/lldb/test/API/tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py similarity index 82% rename from lldb/test/API/tools/lldb-vscode/stop-hooks/TestVSCode_stop_hooks.py rename to lldb/test/API/tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py index 16a09f9d14840..c538e8002a032 100644 --- a/lldb/test/API/tools/lldb-vscode/stop-hooks/TestVSCode_stop_hooks.py +++ b/lldb/test/API/tools/lldb-dap/stop-hooks/TestDAP_stop_hooks.py @@ -5,14 +5,14 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * -import lldbvscode_testcase +import lldbdap_testcase -class TestVSCode_stop_hooks(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_stop_hooks(lldbdap_testcase.DAPTestCaseBase): @skipIfRemote def test_stop_hooks_before_run(self): """ - Test that there is no race condition between lldb-vscode and + Test that there is no race condition between lldb-dap and stop hooks executor """ program = self.getBuildArtifact("a.out") @@ -24,9 +24,9 @@ def test_stop_hooks_before_run(self): breakpoint_ids = self.set_function_breakpoints(["main"]) # This request hangs if the race happens, because, in that case, the - # command interpreter is in synchronous mode while lldb-vscode expects + # command interpreter is in synchronous mode while lldb-dap expects # it to be in asynchronous mode, so, the process doesn't send the stop - # event to "lldb.Debugger" listener (which is monitored by lldb-vscode). + # event to "lldb.Debugger" listener (which is monitored by lldb-dap). self.continue_to_breakpoints(breakpoint_ids) self.continue_to_exit() diff --git a/lldb/test/API/tools/lldb-vscode/stop-hooks/main.c b/lldb/test/API/tools/lldb-dap/stop-hooks/main.c similarity index 100% rename from lldb/test/API/tools/lldb-vscode/stop-hooks/main.c rename to lldb/test/API/tools/lldb-dap/stop-hooks/main.c diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/Makefile b/lldb/test/API/tools/lldb-dap/terminated-event/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/terminated-event/Makefile rename to lldb/test/API/tools/lldb-dap/terminated-event/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py similarity index 89% rename from lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py rename to lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py index 525de0b1201c4..78bc14c380f96 100644 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/TestVSCode_terminatedEvent.py +++ b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py @@ -1,17 +1,17 @@ """ -Test lldb-vscode terminated event +Test lldb-dap terminated event """ -import vscode +import dap_server from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -import lldbvscode_testcase +import lldbdap_testcase import re import json -class TestVSCode_terminatedEvent(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_terminatedEvent(lldbdap_testcase.DAPTestCaseBase): @skipIfWindows @skipIfRemote def test_terminated_event(self): @@ -44,7 +44,7 @@ def test_terminated_event(self): self.continue_to_breakpoints(breakpoint_ids) self.continue_to_exit() - statistics = self.vscode.wait_for_terminated()["statistics"] + statistics = self.dap_server.wait_for_terminated()["statistics"] self.assertTrue(statistics["totalDebugInfoByteSize"] > 0) self.assertTrue(statistics["totalDebugInfoEnabled"] > 0) self.assertTrue(statistics["totalModuleCountHasDebugInfo"] > 0) @@ -52,7 +52,7 @@ def test_terminated_event(self): self.assertIsNotNone(statistics["memory"]) self.assertNotIn("modules", statistics.keys()) - # lldb-vscode debugs one target at a time + # lldb-dap debugs one target at a time target = json.loads(statistics["targets"])[0] self.assertTrue(target["totalBreakpointResolveTime"] > 0) diff --git a/lldb/test/API/tools/lldb-dap/terminated-event/foo.cpp b/lldb/test/API/tools/lldb-dap/terminated-event/foo.cpp new file mode 100644 index 0000000000000..b6f33b8e070a4 --- /dev/null +++ b/lldb/test/API/tools/lldb-dap/terminated-event/foo.cpp @@ -0,0 +1 @@ +int foo() { return 12; } diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.h b/lldb/test/API/tools/lldb-dap/terminated-event/foo.h similarity index 100% rename from lldb/test/API/tools/lldb-vscode/terminated-event/foo.h rename to lldb/test/API/tools/lldb-dap/terminated-event/foo.h diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp b/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp similarity index 100% rename from lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp rename to lldb/test/API/tools/lldb-dap/terminated-event/main.cpp index cd984e560e0d2..50dd77c0a9c1d 100644 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/main.cpp +++ b/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp @@ -1,5 +1,5 @@ -#include #include "foo.h" +#include int main(int argc, char const *argv[]) { std::cout << "Hello World!" << std::endl; // main breakpoint 1 diff --git a/lldb/test/API/tools/lldb-vscode/variables/Makefile b/lldb/test/API/tools/lldb-dap/variables/Makefile similarity index 100% rename from lldb/test/API/tools/lldb-vscode/variables/Makefile rename to lldb/test/API/tools/lldb-dap/variables/Makefile diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py similarity index 89% rename from lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py rename to lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py index fc24b3b34e702..11d9bf18db7a6 100644 --- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py +++ b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py @@ -1,11 +1,11 @@ """ -Test lldb-vscode setBreakpoints request +Test lldb-dap setBreakpoints request """ import os -import lldbvscode_testcase -import vscode +import lldbdap_testcase +import dap_server from lldbsuite.test import lldbutil from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -18,7 +18,7 @@ def make_buffer_verify_dict(start_idx, count, offset=0): return verify_dict -class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase): +class TestDAP_variables(lldbdap_testcase.DAPTestCaseBase): def verify_values(self, verify_dict, actual, varref_dict=None, expression=None): if "equals" in verify_dict: verify = verify_dict["equals"] @@ -79,7 +79,7 @@ def verify_values(self, verify_dict, actual, varref_dict=None, expression=None): ("children verify values specified for " "variable without children"), ) - response = self.vscode.request_variables(varRef) + response = self.dap_server.request_variables(varRef) self.verify_variables( verify_dict["children"], response["body"]["variables"], varref_dict ) @@ -111,7 +111,7 @@ def darwin_dwarf_missing_obj(self, initCommands): self.assertEquals(len(breakpoint_ids), len(functions), "expect one breakpoint") self.continue_to_breakpoints(breakpoint_ids) - locals = self.vscode.get_local_variables() + locals = self.dap_server.get_local_variables() verify_locals = { "": { @@ -147,8 +147,8 @@ def do_test_scopes_variables_setVariable_evaluate( len(breakpoint_ids), len(lines), "expect correct number of breakpoints" ) self.continue_to_breakpoints(breakpoint_ids) - locals = self.vscode.get_local_variables() - globals = self.vscode.get_global_variables() + locals = self.dap_server.get_local_variables() + globals = self.dap_server.get_global_variables() buffer_children = make_buffer_verify_dict(0, 32) verify_locals = { "argc": {"equals": {"type": "int", "value": "1"}}, @@ -181,28 +181,28 @@ def do_test_scopes_variables_setVariable_evaluate( # has optional parameters like "start" and "count" to limit the number # of variables that are fetched varRef = varref_dict["pt.buffer"] - response = self.vscode.request_variables(varRef) + response = self.dap_server.request_variables(varRef) self.verify_variables(buffer_children, response["body"]["variables"]) # Verify setting start=0 in the arguments still gets all children - response = self.vscode.request_variables(varRef, start=0) + response = self.dap_server.request_variables(varRef, start=0) self.verify_variables(buffer_children, response["body"]["variables"]) # Verify setting count=0 in the arguments still gets all children. # If count is zero, it means to get all children. - response = self.vscode.request_variables(varRef, count=0) + response = self.dap_server.request_variables(varRef, count=0) self.verify_variables(buffer_children, response["body"]["variables"]) # Verify setting count to a value that is too large in the arguments # still gets all children, and no more - response = self.vscode.request_variables(varRef, count=1000) + response = self.dap_server.request_variables(varRef, count=1000) self.verify_variables(buffer_children, response["body"]["variables"]) # Verify setting the start index and count gets only the children we # want - response = self.vscode.request_variables(varRef, start=5, count=5) + response = self.dap_server.request_variables(varRef, start=5, count=5) self.verify_variables( make_buffer_verify_dict(5, 5), response["body"]["variables"] ) # Verify setting the start index to a value that is out of range # results in an empty list - response = self.vscode.request_variables(varRef, start=32, count=1) + response = self.dap_server.request_variables(varRef, start=32, count=1) self.assertEqual( len(response["body"]["variables"]), 0, @@ -253,7 +253,7 @@ def do_test_scopes_variables_setVariable_evaluate( }, } for expression in expressions: - response = self.vscode.request_evaluate(expression) + response = self.dap_server.request_evaluate(expression) self.verify_values(expressions[expression], response["body"]) # Test setting variables @@ -269,8 +269,8 @@ def do_test_scopes_variables_setVariable_evaluate( # Set a variable value whose name is synthetic, like a variable index # and verify the value by reading it - self.vscode.request_setVariable(varRef, "[0]", 100) - response = self.vscode.request_variables(varRef, start=0, count=1) + self.dap_server.request_setVariable(varRef, "[0]", 100) + response = self.dap_server.request_variables(varRef, start=0, count=1) self.verify_variables( make_buffer_verify_dict(0, 1, 100), response["body"]["variables"] ) @@ -278,8 +278,8 @@ def do_test_scopes_variables_setVariable_evaluate( # Set a variable value whose name is a real child value, like "pt.x" # and verify the value by reading it varRef = varref_dict["pt"] - self.vscode.request_setVariable(varRef, "x", 111) - response = self.vscode.request_variables(varRef, start=0, count=1) + self.dap_server.request_setVariable(varRef, "x", 111) + response = self.dap_server.request_variables(varRef, start=0, count=1) value = response["body"]["variables"][0]["value"] self.assertEqual( value, "111", "verify pt.x got set to 111 (111 != %s)" % (value) @@ -301,40 +301,42 @@ def do_test_scopes_variables_setVariable_evaluate( verify_locals["x @ main.cpp:19"] = {"equals": {"type": "int", "value": "42"}} verify_locals["x @ main.cpp:21"] = {"equals": {"type": "int", "value": "72"}} - self.verify_variables(verify_locals, self.vscode.get_local_variables()) + self.verify_variables(verify_locals, self.dap_server.get_local_variables()) # Now we verify that we correctly change the name of a variable with and without differentiator suffix - self.assertFalse(self.vscode.request_setVariable(1, "x2", 9)["success"]) + self.assertFalse(self.dap_server.request_setVariable(1, "x2", 9)["success"]) self.assertFalse( - self.vscode.request_setVariable(1, "x @ main.cpp:0", 9)["success"] + self.dap_server.request_setVariable(1, "x @ main.cpp:0", 9)["success"] ) self.assertTrue( - self.vscode.request_setVariable(1, "x @ main.cpp:17", 17)["success"] + self.dap_server.request_setVariable(1, "x @ main.cpp:17", 17)["success"] ) self.assertTrue( - self.vscode.request_setVariable(1, "x @ main.cpp:19", 19)["success"] + self.dap_server.request_setVariable(1, "x @ main.cpp:19", 19)["success"] ) self.assertTrue( - self.vscode.request_setVariable(1, "x @ main.cpp:21", 21)["success"] + self.dap_server.request_setVariable(1, "x @ main.cpp:21", 21)["success"] ) # The following should have no effect self.assertFalse( - self.vscode.request_setVariable(1, "x @ main.cpp:21", "invalid")["success"] + self.dap_server.request_setVariable(1, "x @ main.cpp:21", "invalid")[ + "success" + ] ) verify_locals["x @ main.cpp:17"]["equals"]["value"] = "17" verify_locals["x @ main.cpp:19"]["equals"]["value"] = "19" verify_locals["x @ main.cpp:21"]["equals"]["value"] = "21" - self.verify_variables(verify_locals, self.vscode.get_local_variables()) + self.verify_variables(verify_locals, self.dap_server.get_local_variables()) # The plain x variable shold refer to the innermost x - self.assertTrue(self.vscode.request_setVariable(1, "x", 22)["success"]) + self.assertTrue(self.dap_server.request_setVariable(1, "x", 22)["success"]) verify_locals["x @ main.cpp:21"]["equals"]["value"] = "22" - self.verify_variables(verify_locals, self.vscode.get_local_variables()) + self.verify_variables(verify_locals, self.dap_server.get_local_variables()) # In breakpoint 3, there should be no shadowed variables breakpoint3_line = line_number(source, "// breakpoint 3") @@ -345,7 +347,7 @@ def do_test_scopes_variables_setVariable_evaluate( ) self.continue_to_breakpoints(breakpoint_ids) - locals = self.vscode.get_local_variables() + locals = self.dap_server.get_local_variables() names = [var["name"] for var in locals] # The first shadowed x shouldn't have a suffix anymore verify_locals["x"] = {"equals": {"type": "int", "value": "17"}} @@ -389,7 +391,7 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo self.continue_to_breakpoints(breakpoint_ids) # Verify locals - locals = self.vscode.get_local_variables() + locals = self.dap_server.get_local_variables() buffer_children = make_buffer_verify_dict(0, 32) verify_locals = { "argc": { @@ -451,7 +453,7 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo # Evaluate from permanent UI. permanent_expr_varref_dict = {} - response = self.vscode.request_evaluate( + response = self.dap_server.request_evaluate( expandable_expression["name"], frameIndex=0, threadId=None, context="repl" ) self.verify_values( @@ -463,7 +465,7 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo # Evaluate from temporary UI. temporary_expr_varref_dict = {} - response = self.vscode.request_evaluate(expandable_expression["name"]) + response = self.dap_server.request_evaluate(expandable_expression["name"]) self.verify_values( expandable_expression["response"], response["body"], @@ -472,13 +474,13 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo ) # Evaluate locals again. - locals = self.vscode.get_local_variables() + locals = self.dap_server.get_local_variables() self.verify_variables(verify_locals, locals) # Verify the evaluated expressions before second locals evaluation # can be expanded. var_ref = temporary_expr_varref_dict[expandable_expression["name"]] - response = self.vscode.request_variables(var_ref) + response = self.dap_server.request_variables(var_ref) self.verify_variables( expandable_expression["children"], response["body"]["variables"] ) @@ -494,14 +496,14 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo self.continue_to_breakpoints(breakpoint_ids) var_ref = permanent_expr_varref_dict[expandable_expression["name"]] - response = self.vscode.request_variables(var_ref) + response = self.dap_server.request_variables(var_ref) self.verify_variables( expandable_expression["children"], response["body"]["variables"] ) # Test that frame scopes have corresponding presentation hints. - frame_id = self.vscode.get_stackFrame()["id"] - scopes = self.vscode.request_scopes(frame_id)["body"]["scopes"] + frame_id = self.dap_server.get_stackFrame()["id"] + scopes = self.dap_server.request_scopes(frame_id)["body"]["scopes"] scope_names = [scope["name"] for scope in scopes] self.assertIn("Locals", scope_names) @@ -544,7 +546,7 @@ def do_test_indexedVariables(self, enableSyntheticChildDebugging: bool): self.continue_to_breakpoints(breakpoint_ids) # Verify locals - locals = self.vscode.get_local_variables() + locals = self.dap_server.get_local_variables() # The vector variables might have one additional entry from the fake # "[raw]" child. raw_child_count = 1 if enableSyntheticChildDebugging else 0 @@ -569,7 +571,7 @@ def do_test_indexedVariables(self, enableSyntheticChildDebugging: bool): if enableSyntheticChildDebugging: verify_children["[raw]"] = ({"contains": {"type": ["vector"]}},) - children = self.vscode.request_variables(locals[2]["variablesReference"])[ + children = self.dap_server.request_variables(locals[2]["variablesReference"])[ "body" ]["variables"] self.verify_variables(verify_children, children) @@ -620,11 +622,11 @@ def test_registers(self): if pc_name is None: return # Verify locals - reg_sets = self.vscode.get_registers() + reg_sets = self.dap_server.get_registers() for reg_set in reg_sets: if reg_set["name"] == "General Purpose Registers": varRef = reg_set["variablesReference"] - regs = self.vscode.request_variables(varRef)["body"]["variables"] + regs = self.dap_server.request_variables(varRef)["body"]["variables"] for reg in regs: if reg["name"] == pc_name: value = reg["value"] diff --git a/lldb/test/API/tools/lldb-vscode/variables/main.cpp b/lldb/test/API/tools/lldb-dap/variables/main.cpp similarity index 90% rename from lldb/test/API/tools/lldb-vscode/variables/main.cpp rename to lldb/test/API/tools/lldb-dap/variables/main.cpp index d81a9a20544a8..da09ecb474f3b 100644 --- a/lldb/test/API/tools/lldb-vscode/variables/main.cpp +++ b/lldb/test/API/tools/lldb-dap/variables/main.cpp @@ -11,8 +11,8 @@ static int s_global = 234; int test_indexedVariables(); int main(int argc, char const *argv[]) { static float s_local = 2.25; - PointType pt = { 11,22, {0}}; - for (int i=0; i -#include -#include - -int compare_ints(const void* a, const void* b) -{ - int arg1 = *(const int*)a; - int arg2 = *(const int*)b; - - // breakpoint 1 - - if (arg1 < arg2) return -1; - if (arg1 > arg2) return 1; - return 0; -} - -int main(void) -{ - int ints[] = { -2, 99, 0, -743, 2, INT_MIN, 4 }; - int size = sizeof ints / sizeof *ints; - - qsort(ints, size, sizeof(int), compare_ints); - - for (int i = 0; i < size; i++) { - printf("%d ", ints[i]); - } - - printf("\n"); - return 0; -} \ No newline at end of file diff --git a/lldb/test/API/tools/lldb-vscode/module/foo.cpp b/lldb/test/API/tools/lldb-vscode/module/foo.cpp deleted file mode 100644 index 9dba85a9cccab..0000000000000 --- a/lldb/test/API/tools/lldb-vscode/module/foo.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int foo() { - return 12; -} diff --git a/lldb/test/API/tools/lldb-vscode/step/main.cpp b/lldb/test/API/tools/lldb-vscode/step/main.cpp deleted file mode 100644 index 3027551972fcc..0000000000000 --- a/lldb/test/API/tools/lldb-vscode/step/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -int function(int x) { - if ((x % 2) == 0) - return function(x-1) + x; // breakpoint 1 - else - return x; -} - -int main(int argc, char const *argv[]) { - return function(2); -} diff --git a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp b/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp deleted file mode 100644 index 9dba85a9cccab..0000000000000 --- a/lldb/test/API/tools/lldb-vscode/terminated-event/foo.cpp +++ /dev/null @@ -1,3 +0,0 @@ -int foo() { - return 12; -} diff --git a/lldb/test/Shell/VSCode/TestOptions.test b/lldb/test/Shell/DAP/TestOptions.test similarity index 70% rename from lldb/test/Shell/VSCode/TestOptions.test rename to lldb/test/Shell/DAP/TestOptions.test index 05588ecd9df6c..e37e9116e3cdd 100644 --- a/lldb/test/Shell/VSCode/TestOptions.test +++ b/lldb/test/Shell/DAP/TestOptions.test @@ -1,4 +1,4 @@ -# RUN: lldb-vscode --help | FileCheck %s +# RUN: lldb-dap --help | FileCheck %s # CHECK: -g # CHECK: --help # CHECK: -h diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index 8b56c659b13bf..255955fc70d8c 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -90,7 +90,7 @@ def use_lldb_substitutions(config): unresolved="ignore", ), "lldb-test", - "lldb-vscode", + "lldb-dap", ToolSubst( "%build", command="'" + sys.executable + "'", extra_args=build_script_args ), diff --git a/lldb/tools/CMakeLists.txt b/lldb/tools/CMakeLists.txt index 16a2c7956aeff..6804dc234555b 100644 --- a/lldb/tools/CMakeLists.txt +++ b/lldb/tools/CMakeLists.txt @@ -9,7 +9,7 @@ add_subdirectory(lldb-test EXCLUDE_FROM_ALL) add_subdirectory(lldb-fuzzer EXCLUDE_FROM_ALL) add_lldb_tool_subdirectory(lldb-instr) -add_lldb_tool_subdirectory(lldb-vscode) +add_lldb_tool_subdirectory(lldb-dap) if (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_lldb_tool_subdirectory(darwin-debug) diff --git a/lldb/tools/lldb-vscode/BreakpointBase.cpp b/lldb/tools/lldb-dap/BreakpointBase.cpp similarity index 97% rename from lldb/tools/lldb-vscode/BreakpointBase.cpp rename to lldb/tools/lldb-dap/BreakpointBase.cpp index 9ec392c9afe47..cd12f97fb13df 100644 --- a/lldb/tools/lldb-vscode/BreakpointBase.cpp +++ b/lldb/tools/lldb-dap/BreakpointBase.cpp @@ -7,10 +7,10 @@ //===----------------------------------------------------------------------===// #include "BreakpointBase.h" -#include "VSCode.h" +#include "DAP.h" #include "llvm/ADT/StringExtras.h" -using namespace lldb_vscode; +using namespace lldb_dap; BreakpointBase::BreakpointBase(const llvm::json::Object &obj) : condition(std::string(GetString(obj, "condition"))), @@ -270,7 +270,7 @@ void BreakpointBase::SetLogMessage() { void BreakpointBase::NotifyLogMessageError(llvm::StringRef error) { std::string message = "Log message has error: "; message += error; - g_vsc.SendOutput(OutputType::Console, message); + g_dap.SendOutput(OutputType::Console, message); } /*static*/ @@ -304,7 +304,7 @@ bool BreakpointBase::BreakpointHitCallback( } if (!output.empty() && output.back() != '\n') output.push_back('\n'); // Ensure log message has line break. - g_vsc.SendOutput(OutputType::Console, output.c_str()); + g_dap.SendOutput(OutputType::Console, output.c_str()); // Do not stop. return false; @@ -328,7 +328,7 @@ void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) { const char *BreakpointBase::GetBreakpointLabel() { // Breakpoints in LLDB can have names added to them which are kind of like // labels or categories. All breakpoints that are set through the IDE UI get - // sent through the various VS code DAP set*Breakpoint packets, and these + // sent through the various DAP set*Breakpoint packets, and these // breakpoints will be labeled with this name so if breakpoint update events // come in for breakpoints that the IDE doesn't know about, like if a // breakpoint is set manually using the debugger console, we won't report any @@ -338,5 +338,5 @@ const char *BreakpointBase::GetBreakpointLabel() { // in via LLDB breakpoint changed events and check the breakpoint by calling // "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a // breakpoint in one of the UI breakpoints that we should report changes for. - return "vscode"; + return "dap"; } diff --git a/lldb/tools/lldb-vscode/BreakpointBase.h b/lldb/tools/lldb-dap/BreakpointBase.h similarity index 93% rename from lldb/tools/lldb-vscode/BreakpointBase.h rename to lldb/tools/lldb-dap/BreakpointBase.h index 91e0dd600163c..41787f7861021 100644 --- a/lldb/tools/lldb-vscode/BreakpointBase.h +++ b/lldb/tools/lldb-dap/BreakpointBase.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_BREAKPOINTBASE_H -#define LLDB_TOOLS_LLDB_VSCODE_BREAKPOINTBASE_H +#ifndef LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H +#define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H #include "JSONUtils.h" #include "lldb/API/SBBreakpoint.h" @@ -15,7 +15,7 @@ #include #include -namespace lldb_vscode { +namespace lldb_dap { struct BreakpointBase { // logMessage part can be either a raw text or an expression. @@ -58,6 +58,6 @@ struct BreakpointBase { lldb::SBBreakpointLocation &location); }; -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/CMakeLists.txt b/lldb/tools/lldb-dap/CMakeLists.txt similarity index 79% rename from lldb/tools/lldb-vscode/CMakeLists.txt rename to lldb/tools/lldb-dap/CMakeLists.txt index b68a4f3f67ab9..c71c80981890b 100644 --- a/lldb/tools/lldb-vscode/CMakeLists.txt +++ b/lldb/tools/lldb-dap/CMakeLists.txt @@ -9,11 +9,11 @@ endif () if(APPLE) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/lldb-vscode-Info.plist.in - ${CMAKE_CURRENT_BINARY_DIR}/lldb-vscode-Info.plist + ${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in + ${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist ) # Inline info plist in binary (use target_link_options for this as soon as CMake 3.13 is available) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-vscode-Info.plist") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist") endif() # We need to include the llvm components we depend on manually, as liblldb does @@ -21,9 +21,9 @@ endif() set(LLVM_LINK_COMPONENTS Support) set(LLVM_TARGET_DEFINITIONS Options.td) tablegen(LLVM Options.inc -gen-opt-parser-defs) -add_public_tablegen_target(LLDBVSCodeOptionsTableGen) -add_lldb_tool(lldb-vscode - lldb-vscode.cpp +add_public_tablegen_target(LLDBDAPOptionsTableGen) +add_lldb_tool(lldb-dap + lldb-dap.cpp BreakpointBase.cpp ExceptionBreakpoint.cpp FifoFiles.cpp @@ -35,7 +35,7 @@ add_lldb_tool(lldb-vscode ProgressEvent.cpp RunInTerminal.cpp SourceBreakpoint.cpp - VSCode.cpp + DAP.cpp LINK_LIBS liblldb @@ -49,7 +49,7 @@ add_lldb_tool(lldb-vscode if(LLDB_BUILD_FRAMEWORK) # In the build-tree, we know the exact path to the framework directory. # The installed framework can be in different locations. - lldb_setup_rpaths(lldb-vscode + lldb_setup_rpaths(lldb-dap BUILD_RPATH "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}" INSTALL_RPATH diff --git a/lldb/tools/lldb-vscode/VSCode.cpp b/lldb/tools/lldb-dap/DAP.cpp similarity index 86% rename from lldb/tools/lldb-vscode/VSCode.cpp rename to lldb/tools/lldb-dap/DAP.cpp index 1384604c48371..af20e6460685e 100644 --- a/lldb/tools/lldb-vscode/VSCode.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -1,4 +1,4 @@ -//===-- VSCode.cpp ----------------------------------------------*- C++ -*-===// +//===-- DAP.cpp -------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -12,8 +12,8 @@ #include #include +#include "DAP.h" #include "LLDBUtils.h" -#include "VSCode.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/FormatVariadic.h" @@ -24,14 +24,14 @@ #include #endif -using namespace lldb_vscode; +using namespace lldb_dap; -namespace lldb_vscode { +namespace lldb_dap { -VSCode g_vsc; +DAP g_dap; -VSCode::VSCode() - : broadcaster("lldb-vscode"), +DAP::DAP() + : broadcaster("lldb-dap"), exception_breakpoints( {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, @@ -49,7 +49,7 @@ VSCode::VSCode() [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }), reverse_request_seq(0), repl_mode(ReplMode::Auto), auto_repl_mode_collision_warning(false) { - const char *log_file_path = getenv("LLDBVSCODE_LOG"); + const char *log_file_path = getenv("LLDBDAP_LOG"); #if defined(_WIN32) // Windows opens stdout and stdin in text mode which converts \n to 13,10 // while the value is just 10 on Darwin/Linux. Setting the file mode to binary @@ -64,9 +64,9 @@ VSCode::VSCode() log.reset(new std::ofstream(log_file_path)); } -VSCode::~VSCode() = default; +DAP::~DAP() = default; -ExceptionBreakpoint *VSCode::GetExceptionBreakpoint(const std::string &filter) { +ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) { for (auto &bp : exception_breakpoints) { if (bp.filter == filter) return &bp; @@ -74,8 +74,7 @@ ExceptionBreakpoint *VSCode::GetExceptionBreakpoint(const std::string &filter) { return nullptr; } -ExceptionBreakpoint * -VSCode::GetExceptionBreakpoint(const lldb::break_id_t bp_id) { +ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const lldb::break_id_t bp_id) { for (auto &bp : exception_breakpoints) { if (bp.bp.GetID() == bp_id) return &bp; @@ -86,7 +85,7 @@ VSCode::GetExceptionBreakpoint(const lldb::break_id_t bp_id) { // Send the JSON in "json_str" to the "out" stream. Correctly send the // "Content-Length:" field followed by the length, followed by the raw // JSON bytes. -void VSCode::SendJSON(const std::string &json_str) { +void DAP::SendJSON(const std::string &json_str) { output.write_full("Content-Length: "); output.write_full(llvm::utostr(json_str.size())); output.write_full("\r\n\r\n"); @@ -95,7 +94,7 @@ void VSCode::SendJSON(const std::string &json_str) { // Serialize the JSON value into a string and send the JSON packet to // the "out" stream. -void VSCode::SendJSON(const llvm::json::Value &json) { +void DAP::SendJSON(const llvm::json::Value &json) { std::string s; llvm::raw_string_ostream strm(s); strm << json; @@ -112,7 +111,7 @@ void VSCode::SendJSON(const llvm::json::Value &json) { } // Read a JSON packet from the "in" stream. -std::string VSCode::ReadJSON() { +std::string DAP::ReadJSON() { std::string length_str; std::string json_str; int length; @@ -198,7 +197,7 @@ std::string VSCode::ReadJSON() { // "required": [ "event", "body" ] // }] // } -void VSCode::SendOutput(OutputType o, const llvm::StringRef output) { +void DAP::SendOutput(OutputType o, const llvm::StringRef output) { if (output.empty()) return; @@ -318,13 +317,13 @@ void VSCode::SendOutput(OutputType o, const llvm::StringRef output) { // }; // } -void VSCode::SendProgressEvent(uint64_t progress_id, const char *message, - uint64_t completed, uint64_t total) { +void DAP::SendProgressEvent(uint64_t progress_id, const char *message, + uint64_t completed, uint64_t total) { progress_event_reporter.Push(progress_id, message, completed, total); } void __attribute__((format(printf, 3, 4))) -VSCode::SendFormattedOutput(OutputType o, const char *format, ...) { +DAP::SendFormattedOutput(OutputType o, const char *format, ...) { char buffer[1024]; va_list args; va_start(args, format); @@ -334,8 +333,7 @@ VSCode::SendFormattedOutput(OutputType o, const char *format, ...) { o, llvm::StringRef(buffer, std::min(actual_length, sizeof(buffer)))); } -ExceptionBreakpoint * -VSCode::GetExceptionBPFromStopReason(lldb::SBThread &thread) { +ExceptionBreakpoint *DAP::GetExceptionBPFromStopReason(lldb::SBThread &thread) { const auto num = thread.GetStopReasonDataCount(); // Check to see if have hit an exception breakpoint and change the // reason to "exception", but only do so if all breakpoints that were @@ -356,12 +354,12 @@ VSCode::GetExceptionBPFromStopReason(lldb::SBThread &thread) { return exc_bp; } -lldb::SBThread VSCode::GetLLDBThread(const llvm::json::Object &arguments) { +lldb::SBThread DAP::GetLLDBThread(const llvm::json::Object &arguments) { auto tid = GetSigned(arguments, "threadId", LLDB_INVALID_THREAD_ID); return target.GetProcess().GetThreadByID(tid); } -lldb::SBFrame VSCode::GetLLDBFrame(const llvm::json::Object &arguments) { +lldb::SBFrame DAP::GetLLDBFrame(const llvm::json::Object &arguments) { const uint64_t frame_id = GetUnsigned(arguments, "frameId", UINT64_MAX); lldb::SBProcess process = target.GetProcess(); // Upper 32 bits is the thread index ID @@ -371,19 +369,19 @@ lldb::SBFrame VSCode::GetLLDBFrame(const llvm::json::Object &arguments) { return thread.GetFrameAtIndex(GetLLDBFrameID(frame_id)); } -llvm::json::Value VSCode::CreateTopLevelScopes() { +llvm::json::Value DAP::CreateTopLevelScopes() { llvm::json::Array scopes; scopes.emplace_back(CreateScope("Locals", VARREF_LOCALS, - g_vsc.variables.locals.GetSize(), false)); + g_dap.variables.locals.GetSize(), false)); scopes.emplace_back(CreateScope("Globals", VARREF_GLOBALS, - g_vsc.variables.globals.GetSize(), false)); + g_dap.variables.globals.GetSize(), false)); scopes.emplace_back(CreateScope("Registers", VARREF_REGS, - g_vsc.variables.registers.GetSize(), false)); + g_dap.variables.registers.GetSize(), false)); return llvm::json::Value(std::move(scopes)); } -ExpressionContext VSCode::DetectExpressionContext(lldb::SBFrame &frame, - std::string &text) { +ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, + std::string &text) { // Include ` as an escape hatch. if (!text.empty() && text[0] == '`') { text = text.substr(1); @@ -433,35 +431,35 @@ ExpressionContext VSCode::DetectExpressionContext(lldb::SBFrame &frame, return ExpressionContext::Variable; } -void VSCode::RunLLDBCommands(llvm::StringRef prefix, - const std::vector &commands) { +void DAP::RunLLDBCommands(llvm::StringRef prefix, + const std::vector &commands) { SendOutput(OutputType::Console, llvm::StringRef(::RunLLDBCommands(prefix, commands))); } -void VSCode::RunInitCommands() { +void DAP::RunInitCommands() { RunLLDBCommands("Running initCommands:", init_commands); } -void VSCode::RunPreRunCommands() { +void DAP::RunPreRunCommands() { RunLLDBCommands("Running preRunCommands:", pre_run_commands); } -void VSCode::RunStopCommands() { +void DAP::RunStopCommands() { RunLLDBCommands("Running stopCommands:", stop_commands); } -void VSCode::RunExitCommands() { +void DAP::RunExitCommands() { RunLLDBCommands("Running exitCommands:", exit_commands); } -void VSCode::RunTerminateCommands() { +void DAP::RunTerminateCommands() { RunLLDBCommands("Running terminateCommands:", terminate_commands); } lldb::SBTarget -VSCode::CreateTargetFromArguments(const llvm::json::Object &arguments, - lldb::SBError &error) { +DAP::CreateTargetFromArguments(const llvm::json::Object &arguments, + lldb::SBError &error) { // Grab the name of the program we need to debug and create a target using // the given program as an argument. Executable file can be a source of target // architecture and platform, if they differ from the host. Setting exe path @@ -490,7 +488,7 @@ VSCode::CreateTargetFromArguments(const llvm::json::Object &arguments, return target; } -void VSCode::SetTarget(const lldb::SBTarget target) { +void DAP::SetTarget(const lldb::SBTarget target) { this->target = target; if (target.IsValid()) { @@ -504,7 +502,7 @@ void VSCode::SetTarget(const lldb::SBTarget target) { } } -PacketStatus VSCode::GetNextObject(llvm::json::Object &object) { +PacketStatus DAP::GetNextObject(llvm::json::Object &object) { std::string json = ReadJSON(); if (json.empty()) return PacketStatus::EndOfFile; @@ -538,7 +536,7 @@ PacketStatus VSCode::GetNextObject(llvm::json::Object &object) { return PacketStatus::Success; } -bool VSCode::HandleObject(const llvm::json::Object &object) { +bool DAP::HandleObject(const llvm::json::Object &object) { const auto packet_type = GetString(object, "type"); if (packet_type == "request") { const auto command = GetString(object, "command"); @@ -591,16 +589,16 @@ bool VSCode::HandleObject(const llvm::json::Object &object) { return false; } -llvm::Error VSCode::Loop() { +llvm::Error DAP::Loop() { while (!sent_terminated_event) { llvm::json::Object object; - lldb_vscode::PacketStatus status = GetNextObject(object); + lldb_dap::PacketStatus status = GetNextObject(object); - if (status == lldb_vscode::PacketStatus::EndOfFile) { + if (status == lldb_dap::PacketStatus::EndOfFile) { break; } - if (status != lldb_vscode::PacketStatus::Success) { + if (status != lldb_dap::PacketStatus::Success) { return llvm::createStringError(llvm::inconvertibleErrorCode(), "failed to send packet"); } @@ -614,9 +612,9 @@ llvm::Error VSCode::Loop() { return llvm::Error::success(); } -void VSCode::SendReverseRequest(llvm::StringRef command, - llvm::json::Value arguments, - ResponseCallback callback) { +void DAP::SendReverseRequest(llvm::StringRef command, + llvm::json::Value arguments, + ResponseCallback callback) { int64_t id; { std::lock_guard locker(call_mutex); @@ -632,12 +630,12 @@ void VSCode::SendReverseRequest(llvm::StringRef command, }); } -void VSCode::RegisterRequestCallback(std::string request, - RequestCallback callback) { +void DAP::RegisterRequestCallback(std::string request, + RequestCallback callback) { request_handlers[request] = callback; } -lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds) { +lldb::SBError DAP::WaitForProcessToStop(uint32_t seconds) { lldb::SBError error; lldb::SBProcess process = target.GetProcess(); if (!process.IsValid()) { @@ -649,26 +647,26 @@ lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds) { while (std::chrono::steady_clock::now() < timeout_time) { const auto state = process.GetState(); switch (state) { - case lldb::eStateAttaching: - case lldb::eStateConnected: - case lldb::eStateInvalid: - case lldb::eStateLaunching: - case lldb::eStateRunning: - case lldb::eStateStepping: - case lldb::eStateSuspended: - break; - case lldb::eStateDetached: - error.SetErrorString("process detached during launch or attach"); - return error; - case lldb::eStateExited: - error.SetErrorString("process exited during launch or attach"); - return error; - case lldb::eStateUnloaded: - error.SetErrorString("process unloaded during launch or attach"); - return error; - case lldb::eStateCrashed: - case lldb::eStateStopped: - return lldb::SBError(); // Success! + case lldb::eStateAttaching: + case lldb::eStateConnected: + case lldb::eStateInvalid: + case lldb::eStateLaunching: + case lldb::eStateRunning: + case lldb::eStateStepping: + case lldb::eStateSuspended: + break; + case lldb::eStateDetached: + error.SetErrorString("process detached during launch or attach"); + return error; + case lldb::eStateExited: + error.SetErrorString("process exited during launch or attach"); + return error; + case lldb::eStateUnloaded: + error.SetErrorString("process unloaded during launch or attach"); + return error; + case lldb::eStateCrashed: + case lldb::eStateStopped: + return lldb::SBError(); // Success! } std::this_thread::sleep_for(std::chrono::microseconds(250)); } @@ -759,7 +757,7 @@ bool StartDebuggingRequestHandler::DoExecute( return false; } - g_vsc.SendReverseRequest( + g_dap.SendReverseRequest( "startDebugging", llvm::json::Object{{"request", request}, {"configuration", std::move(*configuration)}}, @@ -783,7 +781,7 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger debugger, // If a new mode is not specified report the current mode. if (!command || llvm::StringRef(command[0]).empty()) { std::string mode; - switch (g_vsc.repl_mode) { + switch (g_dap.repl_mode) { case ReplMode::Variable: mode = "variable"; break; @@ -795,7 +793,7 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger debugger, break; } - result.Printf("lldb-vscode repl-mode %s.\n", mode.c_str()); + result.Printf("lldb-dap repl-mode %s.\n", mode.c_str()); result.SetStatus(lldb::eReturnStatusSuccessFinishResult); return true; @@ -804,11 +802,11 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger debugger, llvm::StringRef new_mode{command[0]}; if (new_mode == "variable") { - g_vsc.repl_mode = ReplMode::Variable; + g_dap.repl_mode = ReplMode::Variable; } else if (new_mode == "command") { - g_vsc.repl_mode = ReplMode::Command; + g_dap.repl_mode = ReplMode::Command; } else if (new_mode == "auto") { - g_vsc.repl_mode = ReplMode::Auto; + g_dap.repl_mode = ReplMode::Auto; } else { lldb::SBStream error_message; error_message.Printf("Invalid repl-mode '%s'. Expected one of 'variable', " @@ -818,9 +816,9 @@ bool ReplModeRequestHandler::DoExecute(lldb::SBDebugger debugger, return false; } - result.Printf("lldb-vscode repl-mode %s set.\n", new_mode.data()); + result.Printf("lldb-dap repl-mode %s set.\n", new_mode.data()); result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult); return true; } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/VSCode.h b/lldb/tools/lldb-dap/DAP.h similarity index 96% rename from lldb/tools/lldb-vscode/VSCode.h rename to lldb/tools/lldb-dap/DAP.h index 59bb11c71e672..e13d91a9df5d2 100644 --- a/lldb/tools/lldb-vscode/VSCode.h +++ b/lldb/tools/lldb-dap/DAP.h @@ -1,4 +1,4 @@ -//===-- VSCode.h ------------------------------------------------*- C++ -*-===// +//===-- DAP.h ---------------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_VSCODE_H -#define LLDB_TOOLS_LLDB_VSCODE_VSCODE_H +#ifndef LLDB_TOOLS_LLDB_DAP_DAP_H +#define LLDB_TOOLS_LLDB_DAP_DAP_H #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX @@ -62,13 +62,13 @@ #define VARREF_FIRST_VAR_IDX (int64_t)4 #define NO_TYPENAME "" -namespace lldb_vscode { +namespace lldb_dap { typedef llvm::DenseMap SourceBreakpointMap; typedef llvm::StringMap FunctionBreakpointMap; enum class OutputType { Console, Stdout, Stderr, Telemetry }; -enum VSCodeBroadcasterBits { +enum DAPBroadcasterBits { eBroadcastBitStopEventThread = 1u << 0, eBroadcastBitStopProgressThread = 1u << 1 }; @@ -141,7 +141,7 @@ struct ReplModeRequestHandler : public lldb::SBCommandPluginInterface { lldb::SBCommandReturnObject &result) override; }; -struct VSCode { +struct DAP { std::string debug_adaptor_path; InputStream input; OutputStream output; @@ -189,10 +189,10 @@ struct VSCode { ReplMode repl_mode; bool auto_repl_mode_collision_warning; - VSCode(); - ~VSCode(); - VSCode(const VSCode &rhs) = delete; - void operator=(const VSCode &rhs) = delete; + DAP(); + ~DAP(); + DAP(const DAP &rhs) = delete; + void operator=(const DAP &rhs) = delete; ExceptionBreakpoint *GetExceptionBreakpoint(const std::string &filter); ExceptionBreakpoint *GetExceptionBreakpoint(const lldb::break_id_t bp_id); @@ -245,7 +245,7 @@ struct VSCode { lldb::SBTarget CreateTargetFromArguments(const llvm::json::Object &arguments, lldb::SBError &error); - /// Set given target object as a current target for lldb-vscode and start + /// Set given target object as a current target for lldb-dap and start /// listeing for its breakpoint events. void SetTarget(const lldb::SBTarget target); @@ -311,8 +311,8 @@ struct VSCode { void SendJSON(const std::string &json_str); }; -extern VSCode g_vsc; +extern DAP g_dap; -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/VSCodeForward.h b/lldb/tools/lldb-dap/DAPForward.h similarity index 81% rename from lldb/tools/lldb-vscode/VSCodeForward.h rename to lldb/tools/lldb-dap/DAPForward.h index 92eb5757d1803..fffff1e3f7902 100644 --- a/lldb/tools/lldb-vscode/VSCodeForward.h +++ b/lldb/tools/lldb-dap/DAPForward.h @@ -1,4 +1,4 @@ -//===-- VSCodeForward.h -----------------------------------------*- C++ -*-===// +//===-- DAPForward.h --------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_VSCODEFORWARD_H -#define LLDB_TOOLS_LLDB_VSCODE_VSCODEFORWARD_H +#ifndef LLDB_TOOLS_LLDB_DAP_DAPFORWARD_H +#define LLDB_TOOLS_LLDB_DAP_DAPFORWARD_H -namespace lldb_vscode { +namespace lldb_dap { struct BreakpointBase; struct ExceptionBreakpoint; struct FunctionBreakpoint; struct SourceBreakpoint; -} // namespace lldb_vscode +} // namespace lldb_dap namespace lldb { class SBAttachInfo; diff --git a/lldb/tools/lldb-vscode/ExceptionBreakpoint.cpp b/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp similarity index 84% rename from lldb/tools/lldb-vscode/ExceptionBreakpoint.cpp rename to lldb/tools/lldb-dap/ExceptionBreakpoint.cpp index 9324e66d8bd7e..130c237e65441 100644 --- a/lldb/tools/lldb-vscode/ExceptionBreakpoint.cpp +++ b/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp @@ -8,16 +8,16 @@ #include "ExceptionBreakpoint.h" #include "BreakpointBase.h" -#include "VSCode.h" +#include "DAP.h" -namespace lldb_vscode { +namespace lldb_dap { void ExceptionBreakpoint::SetBreakpoint() { if (bp.IsValid()) return; bool catch_value = filter.find("_catch") != std::string::npos; bool throw_value = filter.find("_throw") != std::string::npos; - bp = g_vsc.target.BreakpointCreateForException(language, catch_value, + bp = g_dap.target.BreakpointCreateForException(language, catch_value, throw_value); // See comments in BreakpointBase::GetBreakpointLabel() for details of why // we add a label to our breakpoints. @@ -27,8 +27,8 @@ void ExceptionBreakpoint::SetBreakpoint() { void ExceptionBreakpoint::ClearBreakpoint() { if (!bp.IsValid()) return; - g_vsc.target.BreakpointDelete(bp.GetID()); + g_dap.target.BreakpointDelete(bp.GetID()); bp = lldb::SBBreakpoint(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/ExceptionBreakpoint.h b/lldb/tools/lldb-dap/ExceptionBreakpoint.h similarity index 83% rename from lldb/tools/lldb-vscode/ExceptionBreakpoint.h rename to lldb/tools/lldb-dap/ExceptionBreakpoint.h index 203630ccf40ab..7b81d845cb26b 100644 --- a/lldb/tools/lldb-vscode/ExceptionBreakpoint.h +++ b/lldb/tools/lldb-dap/ExceptionBreakpoint.h @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_EXCEPTIONBREAKPOINT_H -#define LLDB_TOOLS_LLDB_VSCODE_EXCEPTIONBREAKPOINT_H +#ifndef LLDB_TOOLS_LLDB_DAP_EXCEPTIONBREAKPOINT_H +#define LLDB_TOOLS_LLDB_DAP_EXCEPTIONBREAKPOINT_H #include #include "lldb/API/SBBreakpoint.h" -namespace lldb_vscode { +namespace lldb_dap { struct ExceptionBreakpoint { std::string filter; @@ -29,6 +29,6 @@ struct ExceptionBreakpoint { void ClearBreakpoint(); }; -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/FifoFiles.cpp b/lldb/tools/lldb-dap/FifoFiles.cpp similarity index 98% rename from lldb/tools/lldb-vscode/FifoFiles.cpp rename to lldb/tools/lldb-dap/FifoFiles.cpp index a5330d58c36c6..9a6423f79471a 100644 --- a/lldb/tools/lldb-vscode/FifoFiles.cpp +++ b/lldb/tools/lldb-dap/FifoFiles.cpp @@ -26,7 +26,7 @@ using namespace llvm; -namespace lldb_vscode { +namespace lldb_dap { FifoFile::FifoFile(StringRef path) : m_path(path) {} @@ -102,4 +102,4 @@ Error FifoFileIO::SendJSON(const json::Value &json, return Error::success(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/FifoFiles.h b/lldb/tools/lldb-dap/FifoFiles.h similarity index 93% rename from lldb/tools/lldb-vscode/FifoFiles.h rename to lldb/tools/lldb-dap/FifoFiles.h index a0c4562b5a6b7..02a97cd5cbbd2 100644 --- a/lldb/tools/lldb-vscode/FifoFiles.h +++ b/lldb/tools/lldb-dap/FifoFiles.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_FIFOFILES_H -#define LLDB_TOOLS_LLDB_VSCODE_FIFOFILES_H +#ifndef LLDB_TOOLS_LLDB_DAP_FIFOFILES_H +#define LLDB_TOOLS_LLDB_DAP_FIFOFILES_H #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #include "llvm/Support/Error.h" @@ -16,7 +16,7 @@ #include -namespace lldb_vscode { +namespace lldb_dap { /// Struct that controls the life of a fifo file in the filesystem. /// @@ -82,6 +82,6 @@ class FifoFileIO { std::string m_other_endpoint_name; }; -} // namespace lldb_vscode +} // namespace lldb_dap -#endif // LLDB_TOOLS_LLDB_VSCODE_FIFOFILES_H +#endif // LLDB_TOOLS_LLDB_DAP_FIFOFILES_H diff --git a/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp b/lldb/tools/lldb-dap/FunctionBreakpoint.cpp similarity index 87% rename from lldb/tools/lldb-vscode/FunctionBreakpoint.cpp rename to lldb/tools/lldb-dap/FunctionBreakpoint.cpp index b7a8705d854c8..d4bdb976500ec 100644 --- a/lldb/tools/lldb-vscode/FunctionBreakpoint.cpp +++ b/lldb/tools/lldb-dap/FunctionBreakpoint.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "FunctionBreakpoint.h" -#include "VSCode.h" +#include "DAP.h" -namespace lldb_vscode { +namespace lldb_dap { FunctionBreakpoint::FunctionBreakpoint(const llvm::json::Object &obj) : BreakpointBase(obj), functionName(std::string(GetString(obj, "name"))) {} @@ -17,7 +17,7 @@ FunctionBreakpoint::FunctionBreakpoint(const llvm::json::Object &obj) void FunctionBreakpoint::SetBreakpoint() { if (functionName.empty()) return; - bp = g_vsc.target.BreakpointCreateByName(functionName.c_str()); + bp = g_dap.target.BreakpointCreateByName(functionName.c_str()); // See comments in BreakpointBase::GetBreakpointLabel() for details of why // we add a label to our breakpoints. bp.AddName(GetBreakpointLabel()); @@ -29,4 +29,4 @@ void FunctionBreakpoint::SetBreakpoint() { SetLogMessage(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/FunctionBreakpoint.h b/lldb/tools/lldb-dap/FunctionBreakpoint.h similarity index 80% rename from lldb/tools/lldb-vscode/FunctionBreakpoint.h rename to lldb/tools/lldb-dap/FunctionBreakpoint.h index 82eec89cd18d2..fc23e94e12876 100644 --- a/lldb/tools/lldb-vscode/FunctionBreakpoint.h +++ b/lldb/tools/lldb-dap/FunctionBreakpoint.h @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_FUNCTIONBREAKPOINT_H -#define LLDB_TOOLS_LLDB_VSCODE_FUNCTIONBREAKPOINT_H +#ifndef LLDB_TOOLS_LLDB_DAP_FUNCTIONBREAKPOINT_H +#define LLDB_TOOLS_LLDB_DAP_FUNCTIONBREAKPOINT_H #include "BreakpointBase.h" -namespace lldb_vscode { +namespace lldb_dap { struct FunctionBreakpoint : public BreakpointBase { std::string functionName; @@ -23,6 +23,6 @@ struct FunctionBreakpoint : public BreakpointBase { void SetBreakpoint(); }; -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/IOStream.cpp b/lldb/tools/lldb-dap/IOStream.cpp similarity index 99% rename from lldb/tools/lldb-vscode/IOStream.cpp rename to lldb/tools/lldb-dap/IOStream.cpp index 6e2a89c5df9e0..897ab791ed062 100644 --- a/lldb/tools/lldb-vscode/IOStream.cpp +++ b/lldb/tools/lldb-dap/IOStream.cpp @@ -20,7 +20,7 @@ #include #include -using namespace lldb_vscode; +using namespace lldb_dap; StreamDescriptor::StreamDescriptor() = default; diff --git a/lldb/tools/lldb-vscode/IOStream.h b/lldb/tools/lldb-dap/IOStream.h similarity index 93% rename from lldb/tools/lldb-vscode/IOStream.h rename to lldb/tools/lldb-dap/IOStream.h index 0eb9b6fefb0dc..b62502419182c 100644 --- a/lldb/tools/lldb-vscode/IOStream.h +++ b/lldb/tools/lldb-dap/IOStream.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_IOSTREAM_H -#define LLDB_TOOLS_LLDB_VSCODE_IOSTREAM_H +#ifndef LLDB_TOOLS_LLDB_DAP_IOSTREAM_H +#define LLDB_TOOLS_LLDB_DAP_IOSTREAM_H #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX @@ -32,7 +32,7 @@ typedef int SOCKET; // types of files, so we can't simply have one code path that just uses read // and write everywhere. So we need an abstraction in order to allow us to // treat them identically. -namespace lldb_vscode { +namespace lldb_dap { struct StreamDescriptor { StreamDescriptor(); ~StreamDescriptor(); @@ -66,6 +66,6 @@ struct OutputStream { bool write_full(llvm::StringRef str); }; -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp similarity index 98% rename from lldb/tools/lldb-vscode/JSONUtils.cpp rename to lldb/tools/lldb-dap/JSONUtils.cpp index 6cf753170d842..0daa8c11c1fa6 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -24,12 +24,12 @@ #include "lldb/API/SBValue.h" #include "lldb/Host/PosixApi.h" +#include "DAP.h" #include "ExceptionBreakpoint.h" #include "JSONUtils.h" #include "LLDBUtils.h" -#include "VSCode.h" -namespace lldb_vscode { +namespace lldb_dap { void EmplaceSafeString(llvm::json::Object &obj, llvm::StringRef key, llvm::StringRef str) { @@ -140,7 +140,7 @@ TryCreateAutoSummaryForContainer(lldb::SBValue &v) { // We gate this feature because it performs GetNumChildren(), which can // cause performance issues because LLDB needs to complete possibly huge // types. - if (!g_vsc.enable_auto_variable_summaries) + if (!g_dap.enable_auto_variable_summaries) return std::nullopt; if (!v.MightHaveChildren()) @@ -197,7 +197,7 @@ TryCreateAutoSummaryForContainer(lldb::SBValue &v) { /// Try to create a summary string for the given value that doesn't have a /// summary of its own. static std::optional TryCreateAutoSummary(lldb::SBValue value) { - if (!g_vsc.enable_auto_variable_summaries) + if (!g_dap.enable_auto_variable_summaries) return std::nullopt; // We use the dereferenced value for generating the summary. @@ -326,7 +326,7 @@ llvm::json::Value CreateScope(const llvm::StringRef name, llvm::json::Object object; EmplaceSafeString(object, "name", name.str()); - // TODO: Support "arguments" scope. At the moment lldb-vscode includes the + // TODO: Support "arguments" scope. At the moment lldb-dap includes the // arguments into the "locals" scope. if (variablesReference == VARREF_LOCALS) { object.try_emplace("presentationHint", "locals"); @@ -425,7 +425,7 @@ llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp, if (bp_addr.IsValid()) { std::string formatted_addr = - "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(g_vsc.target)); + "0x" + llvm::utohexstr(bp_addr.GetLoadAddress(g_dap.target)); object.try_emplace("instructionReference", formatted_addr); auto line_entry = bp_addr.GetLineEntry(); const auto line = line_entry.GetLine(); @@ -513,7 +513,7 @@ llvm::json::Value CreateModule(lldb::SBModule &module) { object.try_emplace("symbolStatus", "Symbols not found."); } std::string loaded_addr = std::to_string( - module.GetObjectFileHeaderAddress().GetLoadAddress(g_vsc.target)); + module.GetObjectFileHeaderAddress().GetLoadAddress(g_dap.target)); object.try_emplace("addressRange", loaded_addr); std::string version_str; uint32_t version_nums[3]; @@ -775,7 +775,7 @@ std::optional CreateSource(lldb::SBFrame &frame) { // } llvm::json::Value CreateStackFrame(lldb::SBFrame &frame) { llvm::json::Object object; - int64_t frame_id = MakeVSCodeFrameID(frame); + int64_t frame_id = MakeDAPFrameID(frame); object.try_emplace("id", frame_id); // `function_name` can be a nullptr, which throws an error when assigned to an @@ -932,7 +932,7 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread &thread, body.try_emplace("reason", "step"); break; case lldb::eStopReasonBreakpoint: { - ExceptionBreakpoint *exc_bp = g_vsc.GetExceptionBPFromStopReason(thread); + ExceptionBreakpoint *exc_bp = g_dap.GetExceptionBPFromStopReason(thread); if (exc_bp) { body.try_emplace("reason", "exception"); EmplaceSafeString(body, "description", exc_bp->label); @@ -990,10 +990,10 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread &thread, } } // "threadCausedFocus" is used in tests to validate breaking behavior. - if (tid == g_vsc.focus_tid) { + if (tid == g_dap.focus_tid) { body.try_emplace("threadCausedFocus", true); } - body.try_emplace("preserveFocusHint", tid != g_vsc.focus_tid); + body.try_emplace("preserveFocusHint", tid != g_dap.focus_tid); body.try_emplace("allThreadsStopped", true); event.try_emplace("body", std::move(body)); return llvm::json::Value(std::move(event)); @@ -1119,7 +1119,7 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference, // We create a "[raw]" fake child for each synthetic type, so we have to // account for it when returning indexed variables. We don't need to do this // for non-indexed ones. - bool has_raw_child = is_synthetic && g_vsc.enable_synthetic_child_debugging; + bool has_raw_child = is_synthetic && g_dap.enable_synthetic_child_debugging; int actual_num_children = num_children + (has_raw_child ? 1 : 0); if (is_array) { object.try_emplace("indexedVariables", actual_num_children); @@ -1170,8 +1170,8 @@ CreateRunInTerminalReverseRequest(const llvm::json::Object &launch_request, auto launch_request_arguments = launch_request.getObject("arguments"); // The program path must be the first entry in the "args" field - std::vector args = { - debug_adaptor_path.str(), "--comm-file", comm_file.str()}; + std::vector args = {debug_adaptor_path.str(), "--comm-file", + comm_file.str()}; if (debugger_pid != LLDB_INVALID_PROCESS_ID) { args.push_back("--debugger-pid"); args.push_back(std::to_string(debugger_pid)); @@ -1248,7 +1248,7 @@ void FilterAndGetValueForKey(const lldb::SBStructuredData data, const char *key, } void addStatistic(llvm::json::Object &event) { - lldb::SBStructuredData statistics = g_vsc.target.GetStatistics(); + lldb::SBStructuredData statistics = g_dap.target.GetStatistics(); bool is_dictionary = statistics.GetType() == lldb::eStructuredDataTypeDictionary; if (!is_dictionary) @@ -1279,4 +1279,4 @@ std::string JSONToString(const llvm::json::Value &json) { return data; } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-dap/JSONUtils.h similarity index 94% rename from lldb/tools/lldb-vscode/JSONUtils.h rename to lldb/tools/lldb-dap/JSONUtils.h index 2013147f5d353..ade8ed6822691 100644 --- a/lldb/tools/lldb-vscode/JSONUtils.h +++ b/lldb/tools/lldb-dap/JSONUtils.h @@ -6,17 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_JSONUTILS_H -#define LLDB_TOOLS_LLDB_VSCODE_JSONUTILS_H +#ifndef LLDB_TOOLS_LLDB_DAP_JSONUTILS_H +#define LLDB_TOOLS_LLDB_DAP_JSONUTILS_H -#include "VSCodeForward.h" +#include "DAPForward.h" #include "lldb/API/SBModule.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/JSON.h" #include #include -namespace lldb_vscode { +namespace lldb_dap { /// Emplace a StringRef in a json::Object after enusring that the /// string is valid UTF8. If not, first call llvm::json::fixUTF8 @@ -154,7 +154,7 @@ std::vector GetStrings(const llvm::json::Object *obj, /// and "success" set to true. /// /// \param[in] request -/// The request object received from a call to VSCode::ReadJSON(). +/// The request object received from a call to DAP::ReadJSON(). /// /// \param[in,out] response /// An empty llvm::json::Object object that will be filled @@ -214,7 +214,7 @@ void AppendBreakpoint( std::optional request_path = std::nullopt, std::optional request_line = std::nullopt); -/// Converts breakpoint location to a Visual Studio Code "Breakpoint" +/// Converts breakpoint location to a debug adaptor protocol "Breakpoint". /// /// \param[in] bp /// A LLDB breakpoint object to convert into a JSON value @@ -233,11 +233,10 @@ void AppendBreakpoint( /// fallback. /// /// \param[in] request_column -/// An optional column to use when creating the resulting "Breakpoint" object. -/// It is used if the breakpoint has no valid locations. -/// It is useful to ensure the same column -/// provided by the setBreakpoints request are returned to the IDE as a -/// fallback. +/// An optional column to use when creating the resulting "Breakpoint" +/// object. It is used if the breakpoint has no valid locations. It is +/// useful to ensure the same column provided by the setBreakpoints request +/// are returned to the IDE as a fallback. /// /// \return /// A "Breakpoint" JSON object with that follows the formal JSON @@ -269,7 +268,7 @@ llvm::json::Value CreateModule(lldb::SBModule &module); llvm::json::Object CreateEventObject(const llvm::StringRef event_name); /// Create a "ExceptionBreakpointsFilter" JSON object as described in -/// the Visual Studio Code debug adaptor definition. +/// the debug adaptor definition. /// /// \param[in] bp /// The exception breakpoint object to use @@ -280,8 +279,7 @@ llvm::json::Object CreateEventObject(const llvm::StringRef event_name); llvm::json::Value CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp); -/// Create a "Scope" JSON object as described in the Visual Studio Code -/// debug adaptor definition. +/// Create a "Scope" JSON object as described in the debug adaptor definition. /// /// \param[in] name /// The value to place into the "name" key @@ -302,8 +300,7 @@ llvm::json::Value CreateScope(const llvm::StringRef name, int64_t variablesReference, int64_t namedVariables, bool expensive); -/// Create a "Source" JSON object as described in the Visual Studio Code -/// debug adaptor definition. +/// Create a "Source" JSON object as described in the debug adaptor definition. /// /// \param[in] line_entry /// The LLDB line table to use when populating out the "Source" @@ -330,7 +327,7 @@ llvm::json::Value CreateSource(llvm::StringRef source_path); /// object: /// "id" - the stack frame ID as an integer /// "name" - the function name as a string -/// "source" - source file information as a "Source" VSCode object +/// "source" - source file information as a "Source" DAP object /// "line" - the source file line number as an integer /// "column" - the source file column number as an integer /// @@ -404,7 +401,7 @@ std::string CreateUniqueVariableNameForDisplay(lldb::SBValue v, /// "value" - the value of the variable as a string /// "type" - the typename of the variable as a string /// "id" - a unique identifier for a value in case there are multiple -/// variables with the same name. Other parts of the VSCode +/// variables with the same name. Other parts of the DAP /// protocol refer to values by name so this can help /// disambiguate such cases if a IDE passes this "id" value /// back down. @@ -468,7 +465,7 @@ llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit); /// The fifo file used to communicate the with the target launcher. /// /// \param[in] debugger_pid -/// The PID of the lldb-vscode instance that will attach to the target. The +/// The PID of the lldb-dap instance that will attach to the target. The /// launcher uses it on Linux tell the kernel that it should allow the /// debugger process to attach. /// @@ -490,6 +487,6 @@ llvm::json::Object CreateTerminatedEventObject(); /// Convert a given JSON object to a string. std::string JSONToString(const llvm::json::Value &json); -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/LLDBUtils.cpp b/lldb/tools/lldb-dap/LLDBUtils.cpp similarity index 92% rename from lldb/tools/lldb-vscode/LLDBUtils.cpp rename to lldb/tools/lldb-dap/LLDBUtils.cpp index 464195bdc6444..955c11f636895 100644 --- a/lldb/tools/lldb-vscode/LLDBUtils.cpp +++ b/lldb/tools/lldb-dap/LLDBUtils.cpp @@ -7,16 +7,16 @@ //===----------------------------------------------------------------------===// #include "LLDBUtils.h" -#include "VSCode.h" +#include "DAP.h" -namespace lldb_vscode { +namespace lldb_dap { void RunLLDBCommands(llvm::StringRef prefix, const llvm::ArrayRef &commands, llvm::raw_ostream &strm) { if (commands.empty()) return; - lldb::SBCommandInterpreter interp = g_vsc.debugger.GetCommandInterpreter(); + lldb::SBCommandInterpreter interp = g_dap.debugger.GetCommandInterpreter(); if (!prefix.empty()) strm << prefix << "\n"; for (const auto &command : commands) { @@ -78,9 +78,9 @@ uint32_t GetLLDBFrameID(uint64_t dap_frame_id) { return dap_frame_id & ((1u << THREAD_INDEX_SHIFT) - 1); } -int64_t MakeVSCodeFrameID(lldb::SBFrame &frame) { +int64_t MakeDAPFrameID(lldb::SBFrame &frame) { return ((int64_t)frame.GetThread().GetIndexID() << THREAD_INDEX_SHIFT) | frame.GetFrameID(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/LLDBUtils.h b/lldb/tools/lldb-dap/LLDBUtils.h similarity index 82% rename from lldb/tools/lldb-vscode/LLDBUtils.h rename to lldb/tools/lldb-dap/LLDBUtils.h index 8867589b18a08..a99f798835370 100644 --- a/lldb/tools/lldb-vscode/LLDBUtils.h +++ b/lldb/tools/lldb-dap/LLDBUtils.h @@ -6,17 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_LLDBUTILS_H -#define LLDB_TOOLS_LLDB_VSCODE_LLDBUTILS_H +#ifndef LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H +#define LLDB_TOOLS_LLDB_DAP_LLDBUTILS_H -#include "VSCodeForward.h" +#include "DAPForward.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include #include -namespace lldb_vscode { +namespace lldb_dap { /// Run a list of LLDB commands in the LLDB command interpreter. /// @@ -68,7 +68,7 @@ bool ThreadHasStopReason(lldb::SBThread &thread); /// Given a LLDB frame, make a frame ID that is unique to a specific /// thread and frame. /// -/// VSCode requires a Stackframe "id" to be unique, so we use the frame +/// DAP requires a Stackframe "id" to be unique, so we use the frame /// index in the lower 32 bits and the thread index ID in the upper 32 /// bits. /// @@ -78,34 +78,34 @@ bool ThreadHasStopReason(lldb::SBThread &thread); /// \return /// A unique integer that allows us to easily find the right /// stack frame within a thread on subsequent VS code requests. -int64_t MakeVSCodeFrameID(lldb::SBFrame &frame); +int64_t MakeDAPFrameID(lldb::SBFrame &frame); -/// Given a VSCode frame ID, convert to a LLDB thread index id. +/// Given a DAP frame ID, convert to a LLDB thread index id. /// -/// VSCode requires a Stackframe "id" to be unique, so we use the frame +/// DAP requires a Stackframe "id" to be unique, so we use the frame /// index in the lower THREAD_INDEX_SHIFT bits and the thread index ID in /// the upper 32 - THREAD_INDEX_SHIFT bits. /// /// \param[in] dap_frame_id -/// The VSCode frame ID to convert to a thread index ID. +/// The DAP frame ID to convert to a thread index ID. /// /// \return /// The LLDB thread index ID. uint32_t GetLLDBThreadIndexID(uint64_t dap_frame_id); -/// Given a VSCode frame ID, convert to a LLDB frame ID. +/// Given a DAP frame ID, convert to a LLDB frame ID. /// -/// VSCode requires a Stackframe "id" to be unique, so we use the frame +/// DAP requires a Stackframe "id" to be unique, so we use the frame /// index in the lower THREAD_INDEX_SHIFT bits and the thread index ID in /// the upper 32 - THREAD_INDEX_SHIFT bits. /// /// \param[in] dap_frame_id -/// The VSCode frame ID to convert to a frame ID. +/// The DAP frame ID to convert to a frame ID. /// /// \return /// The LLDB frame index ID. uint32_t GetLLDBFrameID(uint64_t dap_frame_id); -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/Options.td b/lldb/tools/lldb-dap/Options.td similarity index 85% rename from lldb/tools/lldb-vscode/Options.td rename to lldb/tools/lldb-dap/Options.td index a6ba0a318f388..571967b232b4a 100644 --- a/lldb/tools/lldb-vscode/Options.td +++ b/lldb/tools/lldb-dap/Options.td @@ -6,7 +6,7 @@ class R prefixes, string name> : Option; def help: F<"help">, - HelpText<"Prints out the usage information for the LLDB VSCode tool.">; + HelpText<"Prints out the usage information for the lldb-dap tool.">; def: Flag<["-"], "h">, Alias, HelpText<"Alias for --help">; @@ -19,7 +19,7 @@ def: Flag<["-"], "g">, def port: S<"port">, MetaVarName<"">, - HelpText<"Communicate with the lldb-vscode tool over the defined port.">; + HelpText<"Communicate with the lldb-dap tool over the defined port.">; def: Separate<["-"], "p">, Alias, HelpText<"Alias for --port">; @@ -37,7 +37,7 @@ def comm_file: S<"comm-file">, def debugger_pid: S<"debugger-pid">, MetaVarName<"">, - HelpText<"The PID of the lldb-vscode instance that sent the launchInTerminal " + HelpText<"The PID of the lldb-dap instance that sent the launchInTerminal " "request when using --launch-target.">; def repl_mode: S<"repl-mode">, diff --git a/lldb/tools/lldb-vscode/OutputRedirector.cpp b/lldb/tools/lldb-dap/OutputRedirector.cpp similarity index 96% rename from lldb/tools/lldb-vscode/OutputRedirector.cpp rename to lldb/tools/lldb-dap/OutputRedirector.cpp index 9243915f7d787..4e6907ce6c780 100644 --- a/lldb/tools/lldb-vscode/OutputRedirector.cpp +++ b/lldb/tools/lldb-dap/OutputRedirector.cpp @@ -18,7 +18,7 @@ using namespace llvm; -namespace lldb_vscode { +namespace lldb_dap { Error RedirectFd(int fd, std::function callback) { int new_fd[2]; @@ -59,4 +59,4 @@ Error RedirectFd(int fd, std::function callback) { return Error::success(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/OutputRedirector.h b/lldb/tools/lldb-dap/OutputRedirector.h similarity index 77% rename from lldb/tools/lldb-vscode/OutputRedirector.h rename to lldb/tools/lldb-dap/OutputRedirector.h index c728367a21855..dba51016775bf 100644 --- a/lldb/tools/lldb-vscode/OutputRedirector.h +++ b/lldb/tools/lldb-dap/OutputRedirector.h @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===/ -#ifndef LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H -#define LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H +#ifndef LLDB_TOOLS_LLDB_DAP_OUTPUT_REDIRECTOR_H +#define LLDB_TOOLS_LLDB_DAP_OUTPUT_REDIRECTOR_H #include #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" -namespace lldb_vscode { +namespace lldb_dap { /// Redirects the output of a given file descriptor to a callback. /// @@ -23,6 +23,6 @@ namespace lldb_vscode { /// otherwise. llvm::Error RedirectFd(int fd, std::function callback); -} // namespace lldb_vscode +} // namespace lldb_dap -#endif // LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H +#endif // LLDB_TOOLS_LLDB_DAP_OUTPUT_REDIRECTOR_H diff --git a/lldb/tools/lldb-vscode/ProgressEvent.cpp b/lldb/tools/lldb-dap/ProgressEvent.cpp similarity index 99% rename from lldb/tools/lldb-vscode/ProgressEvent.cpp rename to lldb/tools/lldb-dap/ProgressEvent.cpp index 2930b5c1e24e9..8a660b50af120 100644 --- a/lldb/tools/lldb-vscode/ProgressEvent.cpp +++ b/lldb/tools/lldb-dap/ProgressEvent.cpp @@ -12,7 +12,7 @@ #include "llvm/Support/ErrorHandling.h" #include -using namespace lldb_vscode; +using namespace lldb_dap; using namespace llvm; // The minimum duration of an event for it to be reported diff --git a/lldb/tools/lldb-vscode/ProgressEvent.h b/lldb/tools/lldb-dap/ProgressEvent.h similarity index 97% rename from lldb/tools/lldb-vscode/ProgressEvent.h rename to lldb/tools/lldb-dap/ProgressEvent.h index 85006e4c0a810..dac21977add2d 100644 --- a/lldb/tools/lldb-vscode/ProgressEvent.h +++ b/lldb/tools/lldb-dap/ProgressEvent.h @@ -12,17 +12,13 @@ #include #include -#include "VSCodeForward.h" +#include "DAPForward.h" #include "llvm/Support/JSON.h" -namespace lldb_vscode { +namespace lldb_dap { -enum ProgressEventType { - progressStart, - progressUpdate, - progressEnd -}; +enum ProgressEventType { progressStart, progressUpdate, progressEnd }; class ProgressEvent; using ProgressEventReportCallback = std::function; @@ -157,4 +153,4 @@ class ProgressEventReporter { std::mutex m_mutex; }; -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/README.md b/lldb/tools/lldb-dap/README.md similarity index 83% rename from lldb/tools/lldb-vscode/README.md rename to lldb/tools/lldb-dap/README.md index 078129026cb0c..00ceb0bedc40a 100644 --- a/lldb/tools/lldb-vscode/README.md +++ b/lldb/tools/lldb-dap/README.md @@ -18,9 +18,10 @@ # Introduction -The `lldb-vscode` tool creates a command line tool that implements the [Visual -Studio Code Debug API](https://code.visualstudio.com/docs/extensionAPI/api-debugging). -It can be installed as an extension for the Visual Studio Code and Nuclide IDE. +The `lldb-dap` tool (formerly `lldb-vscode`) creates a command line tool that +implements the [Debug Adapter +Protocol](https://microsoft.github.io/debug-adapter-protocol/). It can be +installed as an extension for Visual Studio Code and other IDEs supporting DAP. The protocol is easy to run remotely and also can allow other tools and IDEs to get a full featured debugger with a well defined protocol. @@ -30,7 +31,7 @@ Installing the plug-in involves creating a directory in any location outside of `~/.vscode/extensions`. For example, `~/vscode-lldb` is a valid one. You'll also need a subfolder `bin`, e.g. `~/vscode-lldb/bin`. Then copy the `package.json` file that is in the same directory as this documentation into it, and symlink -the `lldb-vscode` binary into the `bin` directory inside the plug-in directory. +the `lldb-dap` binary into the `bin` directory inside the plug-in directory. Finally, on VS Code, execute the command `Developer: Install Extension from Location` and pick the folder you just @@ -40,10 +41,10 @@ If you want to make a stand alone plug-in that you can send to others on UNIX systems: ```bash -mkdir -p ~/llvm-org.lldb-vscode-0.1.0/bin -cp package.json ~/llvm-org.lldb-vscode-0.1.0 -cd ~/llvm-org.lldb-vscode-0.1.0/bin -cp /path/to/a/built/lldb-vscode . +mkdir -p ~/llvm-org.lldb-dap-0.1.0/bin +cp package.json ~/llvm-org.lldb-dap-0.1.0 +cd ~/llvm-org.lldb-dap-0.1.0/bin +cp /path/to/a/built/lldb-dap . cp /path/to/a/built/liblldb.so . ``` @@ -51,48 +52,48 @@ If you want to make a stand alone plug-in that you can send to others on macOS systems: ```bash -mkdir -p ~/llvm-org.lldb-vscode-0.1.0/bin -cp package.json ~/llvm-org.lldb-vscode-0.1.0 -cd ~/llvm-org.lldb-vscode-0.1.0/bin -cp /path/to/a/built/lldb-vscode . +mkdir -p ~/llvm-org.lldb-dap-0.1.0/bin +cp package.json ~/llvm-org.lldb-dap-0.1.0 +cd ~/llvm-org.lldb-dap-0.1.0/bin +cp /path/to/a/built/lldb-dap . rsync -av /path/to/a/built/LLDB.framework LLDB.framework ``` You might need to create additional directories for the `liblldb.so` or `LLDB.framework` inside or next to the `bin` folder depending on how the -[rpath](https://en.wikipedia.org/wiki/Rpath) is set in your `lldb-vscode` +[rpath](https://en.wikipedia.org/wiki/Rpath) is set in your `lldb-dap` binary. By default the `Debug` builds of LLDB usually includes the current executable directory in the rpath, so these steps should work for most people. -To create a plug-in that symlinks into your `lldb-vscode` in your build +To create a plug-in that symlinks into your `lldb-dap` in your build directory: ```bash -mkdir -p ~/llvm-org.lldb-vscode-0.1.0/bin -cp package.json ~/llvm-org.lldb-vscode-0.1.0 -cd ~/llvm-org.lldb-vscode-0.1.0/bin -ln -s /path/to/a/built/lldb-vscode +mkdir -p ~/llvm-org.lldb-dap-0.1.0/bin +cp package.json ~/llvm-org.lldb-dap-0.1.0 +cd ~/llvm-org.lldb-dap-0.1.0/bin +ln -s /path/to/a/built/lldb-dap ``` -This is handy if you want to debug and develope the `lldb-vscode` executable +This is handy if you want to debug and develop the `lldb-dap` executable when adding features or fixing bugs. # Configurations Launching to attaching require you to create a [launch configuration](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations). This file -defines arguments that get passed to `lldb-vscode` and the configuration settings +defines arguments that get passed to `lldb-dap` and the configuration settings control how the launch or attach happens. ## Launch Configuration Settings When you launch a program with Visual Studio Code you will need to create a [launch.json](https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations) -file that defines how your program will be run. The JSON configuration file can contain the following `lldb-vscode` specific launch key/value pairs: +file that defines how your program will be run. The JSON configuration file can contain the following `lldb-dap` specific launch key/value pairs: |parameter |type|req | | |-------------------|----|:--:|---------| |**name** |string|Y| A configuration name that will be displayed in the IDE. -|**type** |string|Y| Must be "lldb-vscode". +|**type** |string|Y| Must be "lldb-dap". |**request** |string|Y| Must be "launch". |**program** |string|Y| Path to the executable to launch. |**args** |[string]|| An array of command line argument strings to be passed to the program being launched. @@ -106,7 +107,7 @@ file that defines how your program will be run. The JSON configuration file can |**exitCommands** |[string]| | LLDB commands executed when the program exits. Commands and command output will be sent to the debugger console when they are executed. |**terminateCommands** |[string]| | LLDB commands executed when the debugging session ends. Commands and command output will be sent to the debugger console when they are executed. |**sourceMap** |[string[2]]| | Specify an array of path re-mappings. Each element in the array must be a two element array containing a source and destination pathname. -|**debuggerRoot** | string| |Specify a working directory to use when launching lldb-vscode. If the debug information in your executable contains relative paths, this option can be used so that `lldb-vscode` can find source files and object files that have relative paths. +|**debuggerRoot** | string| |Specify a working directory to use when launching lldb-dap. If the debug information in your executable contains relative paths, this option can be used so that `lldb-dap` can find source files and object files that have relative paths. ## Attaching Settings @@ -116,12 +117,12 @@ When attaching to a process using LLDB you can attach in a few ways 2. Attach to an existing process by name 3. Attach by name by waiting for the next instance of a process to launch -The JSON configuration file can contain the following `lldb-vscode` specific launch key/value pairs: +The JSON configuration file can contain the following `lldb-dap` specific launch key/value pairs: |parameter |type |req | | |-------------------|--------|:--:|---------| |**name** |string |Y| A configuration name that will be displayed in the IDE. -|**type** |string |Y| Must be "lldb-vscode". +|**type** |string |Y| Must be "lldb-dap". |**request** |string |Y| Must be "attach". |**program** |string | | Path to the executable to attach to. This value is optional but can help to resolve breakpoints prior the attaching to the program. |**pid** |number | | The process id of the process you wish to attach to. If **pid** is omitted, the debugger will attempt to attach to the program by finding a process whose file name matches the file name from **porgram**. Setting this value to `${command:pickMyProcess}` will allow interactive process selection in the IDE. @@ -143,7 +144,7 @@ adds `FOO=1` and `bar` to the environment: ```javascript { - "type": "lldb-vscode", + "type": "lldb-dap", "request": "launch", "name": "Debug", "program": "/tmp/a.out", @@ -158,7 +159,7 @@ This will attach to a process `a.out` whose process ID is 123: ```javascript { - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "name": "Attach to PID", "program": "/tmp/a.out", @@ -175,7 +176,7 @@ above configuration: ```javascript { "name": "Attach to Name", - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "program": "/tmp/a.out", } @@ -187,7 +188,7 @@ to be launched you can add the "waitFor" key value pair: ```javascript { "name": "Attach to Name (wait)", - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "program": "/tmp/a.out", "waitFor": true @@ -205,7 +206,7 @@ This loads the coredump file `/cores/123.core` associated with the program ```javascript { "name": "Load coredump", - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "coreFile": "/cores/123.core", "program": "/tmp/a.out" @@ -221,7 +222,7 @@ locally on port `2345`. ```javascript { "name": "Local Debug Server", - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "program": "/tmp/a.out", "attachCommands": ["gdb-remote 2345"], @@ -237,7 +238,7 @@ port `5678` of that other machine. ```javascript { "name": "Remote Debug Server", - "type": "lldb-vscode", + "type": "lldb-dap", "request": "attach", "program": "/tmp/a.out", "attachCommands": ["gdb-remote hostname:5678"], @@ -246,12 +247,12 @@ port `5678` of that other machine. # Custom debugger commands -The `lldb-vscode` tool includes additional custom commands to support the Debug +The `lldb-dap` tool includes additional custom commands to support the Debug Adapter Protocol features. ## startDebugging -Using the command `lldb-vscode startDebugging` it is possible to trigger a +Using the command `lldb-dap startDebugging` it is possible to trigger a reverse request to the client requesting a child debug session with the specified configuration. For example, this can be used to attached to forked or spawned processes. For more information see @@ -260,7 +261,7 @@ spawned processes. For more information see The custom command has the following format: ``` -lldb-vscode startDebugging +lldb-dap startDebugging ``` This will launch a server and then request a child debug session for a client. @@ -269,14 +270,14 @@ This will launch a server and then request a child debug session for a client. { "program": "server", "postRunCommand": [ - "lldb-vscode startDebugging launch '{\"program\":\"client\"}'" + "lldb-dap startDebugging launch '{\"program\":\"client\"}'" ] } ``` ## repl-mode -Inspect or adjust the behavior of lldb-vscode repl evaluation requests. The +Inspect or adjust the behavior of lldb-dap repl evaluation requests. The supported modes are `variable`, `command` and `auto`. - `variable` - Variable mode expressions are evaluated in the context of the @@ -291,4 +292,4 @@ supported modes are `variable`, `command` and `auto`. The initial repl-mode can be configured with the cli flag `--repl-mode=` and may also be adjusted at runtime using the lldb command -`lldb-vscode repl-mode `. +`lldb-dap repl-mode `. diff --git a/lldb/tools/lldb-vscode/RunInTerminal.cpp b/lldb/tools/lldb-dap/RunInTerminal.cpp similarity index 98% rename from lldb/tools/lldb-vscode/RunInTerminal.cpp rename to lldb/tools/lldb-dap/RunInTerminal.cpp index 25260afa64be3..ad019b8a56a4f 100644 --- a/lldb/tools/lldb-vscode/RunInTerminal.cpp +++ b/lldb/tools/lldb-dap/RunInTerminal.cpp @@ -25,7 +25,7 @@ using namespace llvm; -namespace lldb_vscode { +namespace lldb_dap { const RunInTerminalMessagePid *RunInTerminalMessage::GetAsPidMessage() const { return static_cast(this); @@ -163,11 +163,11 @@ std::string RunInTerminalDebugAdapterCommChannel::GetLauncherError() { Expected> CreateRunInTerminalCommFile() { SmallString<256> comm_file; if (std::error_code EC = sys::fs::getPotentiallyUniqueTempFileName( - "lldb-vscode-run-in-terminal-comm", "", comm_file)) + "lldb-dap-run-in-terminal-comm", "", comm_file)) return createStringError(EC, "Error making unique file name for " "runInTerminal communication files"); return CreateFifoFile(comm_file.str()); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/RunInTerminal.h b/lldb/tools/lldb-dap/RunInTerminal.h similarity index 94% rename from lldb/tools/lldb-vscode/RunInTerminal.h rename to lldb/tools/lldb-dap/RunInTerminal.h index cdccdd6bcf9b9..2fbe3acbb4084 100644 --- a/lldb/tools/lldb-vscode/RunInTerminal.h +++ b/lldb/tools/lldb-dap/RunInTerminal.h @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_RUNINTERMINAL_H -#define LLDB_TOOLS_LLDB_VSCODE_RUNINTERMINAL_H +#ifndef LLDB_TOOLS_LLDB_DAP_RUNINTERMINAL_H +#define LLDB_TOOLS_LLDB_DAP_RUNINTERMINAL_H #include "FifoFiles.h" #include #include -namespace lldb_vscode { +namespace lldb_dap { enum RunInTerminalMessageKind { eRunInTerminalMessageKindPID = 0, @@ -124,6 +124,6 @@ class RunInTerminalDebugAdapterCommChannel { /// the runInTerminal launcher. llvm::Expected> CreateRunInTerminalCommFile(); -} // namespace lldb_vscode +} // namespace lldb_dap -#endif // LLDB_TOOLS_LLDB_VSCODE_RUNINTERMINAL_H +#endif // LLDB_TOOLS_LLDB_DAP_RUNINTERMINAL_H diff --git a/lldb/tools/lldb-vscode/SourceBreakpoint.cpp b/lldb/tools/lldb-dap/SourceBreakpoint.cpp similarity index 88% rename from lldb/tools/lldb-vscode/SourceBreakpoint.cpp rename to lldb/tools/lldb-dap/SourceBreakpoint.cpp index 7c57bf7d7c4f5..3bd83c0a6874d 100644 --- a/lldb/tools/lldb-vscode/SourceBreakpoint.cpp +++ b/lldb/tools/lldb-dap/SourceBreakpoint.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "SourceBreakpoint.h" -#include "VSCode.h" +#include "DAP.h" -namespace lldb_vscode { +namespace lldb_dap { SourceBreakpoint::SourceBreakpoint(const llvm::json::Object &obj) : BreakpointBase(obj), line(GetUnsigned(obj, "line", 0)), @@ -17,7 +17,7 @@ SourceBreakpoint::SourceBreakpoint(const llvm::json::Object &obj) void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) { lldb::SBFileSpecList module_list; - bp = g_vsc.target.BreakpointCreateByLocation(source_path.str().c_str(), line, + bp = g_dap.target.BreakpointCreateByLocation(source_path.str().c_str(), line, column, 0, module_list); // See comments in BreakpointBase::GetBreakpointLabel() for details of why // we add a label to our breakpoints. @@ -30,4 +30,4 @@ void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) { SetLogMessage(); } -} // namespace lldb_vscode +} // namespace lldb_dap diff --git a/lldb/tools/lldb-vscode/SourceBreakpoint.h b/lldb/tools/lldb-dap/SourceBreakpoint.h similarity index 87% rename from lldb/tools/lldb-vscode/SourceBreakpoint.h rename to lldb/tools/lldb-dap/SourceBreakpoint.h index 2891d57ee8ad0..f4b54a44fc687 100644 --- a/lldb/tools/lldb-vscode/SourceBreakpoint.h +++ b/lldb/tools/lldb-dap/SourceBreakpoint.h @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_TOOLS_LLDB_VSCODE_SOURCEBREAKPOINT_H -#define LLDB_TOOLS_LLDB_VSCODE_SOURCEBREAKPOINT_H +#ifndef LLDB_TOOLS_LLDB_DAP_SOURCEBREAKPOINT_H +#define LLDB_TOOLS_LLDB_DAP_SOURCEBREAKPOINT_H #include "BreakpointBase.h" #include "llvm/ADT/StringRef.h" -namespace lldb_vscode { +namespace lldb_dap { struct SourceBreakpoint : public BreakpointBase { @@ -33,6 +33,6 @@ inline bool operator<(const SourceBreakpoint &lhs, return lhs.line < rhs.line; } -} // namespace lldb_vscode +} // namespace lldb_dap #endif diff --git a/lldb/tools/lldb-vscode/lldb-vscode-Info.plist.in b/lldb/tools/lldb-dap/lldb-dap-Info.plist.in similarity index 88% rename from lldb/tools/lldb-vscode/lldb-vscode-Info.plist.in rename to lldb/tools/lldb-dap/lldb-dap-Info.plist.in index 2098e190d6ba7..7d01d3145d929 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode-Info.plist.in +++ b/lldb/tools/lldb-dap/lldb-dap-Info.plist.in @@ -5,11 +5,11 @@ CFBundleDevelopmentRegion English CFBundleIdentifier - com.apple.lldb-vscode + com.apple.lldb-dap CFBundleInfoDictionaryVersion 6.0 CFBundleName - lldb-vscode + lldb-dap CFBundleVersion ${LLDB_VERSION} SecTaskAccess diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp similarity index 88% rename from lldb/tools/lldb-vscode/lldb-vscode.cpp rename to lldb/tools/lldb-dap/lldb-dap.cpp index 3904d430c49b4..d8d81647e8100 100644 --- a/lldb/tools/lldb-vscode/lldb-vscode.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -1,4 +1,4 @@ -//===-- lldb-vscode.cpp -----------------------------------------*- C++ -*-===// +//===-- lldb-dap.cpp -----------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "VSCode.h" +#include "DAP.h" #include #include @@ -73,7 +73,7 @@ typedef int socklen_t; #endif -using namespace lldb_vscode; +using namespace lldb_dap; namespace { using namespace llvm::opt; @@ -109,11 +109,11 @@ enum LaunchMethod { Launch, Attach, AttachForSuspendedLaunch }; lldb::SBValueList *GetTopLevelScope(int64_t variablesReference) { switch (variablesReference) { case VARREF_LOCALS: - return &g_vsc.variables.locals; + return &g_dap.variables.locals; case VARREF_GLOBALS: - return &g_vsc.variables.globals; + return &g_dap.variables.globals; case VARREF_REGS: - return &g_vsc.variables.registers; + return &g_dap.variables.registers; default: return nullptr; } @@ -125,8 +125,8 @@ SOCKET AcceptConnection(int portno) { struct sockaddr_in serv_addr, cli_addr; SOCKET sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { - if (g_vsc.log) - *g_vsc.log << "error: opening socket (" << strerror(errno) << ")" + if (g_dap.log) + *g_dap.log << "error: opening socket (" << strerror(errno) << ")" << std::endl; } else { memset((char *)&serv_addr, 0, sizeof(serv_addr)); @@ -135,8 +135,8 @@ SOCKET AcceptConnection(int portno) { serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); serv_addr.sin_port = htons(portno); if (bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { - if (g_vsc.log) - *g_vsc.log << "error: binding socket (" << strerror(errno) << ")" + if (g_dap.log) + *g_dap.log << "error: binding socket (" << strerror(errno) << ")" << std::endl; } else { listen(sockfd, 5); @@ -145,8 +145,8 @@ SOCKET AcceptConnection(int portno) { llvm::sys::RetryAfterSignal(static_cast(-1), accept, sockfd, (struct sockaddr *)&cli_addr, &clilen); if (newsockfd < 0) - if (g_vsc.log) - *g_vsc.log << "error: accept (" << strerror(errno) << ")" + if (g_dap.log) + *g_dap.log << "error: accept (" << strerror(errno) << ")" << std::endl; } #if defined(_WIN32) @@ -176,7 +176,7 @@ void SendProcessExitedEvent(lldb::SBProcess &process) { llvm::json::Object body; body.try_emplace("exitCode", (int64_t)process.GetExitStatus()); event.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(event))); + g_dap.SendJSON(llvm::json::Value(std::move(event))); } void SendThreadExitedEvent(lldb::tid_t tid) { @@ -185,29 +185,29 @@ void SendThreadExitedEvent(lldb::tid_t tid) { body.try_emplace("reason", "exited"); body.try_emplace("threadId", (int64_t)tid); event.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(event))); + g_dap.SendJSON(llvm::json::Value(std::move(event))); } // Send a "continued" event to indicate the process is in the running state. void SendContinuedEvent() { - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); if (!process.IsValid()) { return; } // If the focus thread is not set then we haven't reported any thread status // to the client, so nothing to report. - if (!g_vsc.configuration_done_sent || - g_vsc.focus_tid == LLDB_INVALID_THREAD_ID) { + if (!g_dap.configuration_done_sent || + g_dap.focus_tid == LLDB_INVALID_THREAD_ID) { return; } llvm::json::Object event(CreateEventObject("continued")); llvm::json::Object body; - body.try_emplace("threadId", (int64_t)g_vsc.focus_tid); + body.try_emplace("threadId", (int64_t)g_dap.focus_tid); body.try_emplace("allThreadsContinued", true); event.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(event))); + g_dap.SendJSON(llvm::json::Value(std::move(event))); } // Send a "terminated" event to indicate the process is done being @@ -217,7 +217,7 @@ void SendTerminatedEvent() { // the threads executing EventThreadFunction and request_discontinue // respectively may call SendTerminatedEvent simultaneously. Without any // synchronization, the thread executing EventThreadFunction may set - // g_vsc.sent_terminated_event before the thread executing + // g_dap.sent_terminated_event before the thread executing // request_discontinue has had a chance to test it, in which case the latter // would move ahead to issue a response to the disconnect request. Said // response may get dispatched ahead of the terminated event compelling the @@ -226,24 +226,24 @@ void SendTerminatedEvent() { // synchronize simultaneous calls to SendTerminatedEvent. static std::mutex mutex; std::lock_guard locker(mutex); - if (!g_vsc.sent_terminated_event) { - g_vsc.sent_terminated_event = true; - g_vsc.RunTerminateCommands(); + if (!g_dap.sent_terminated_event) { + g_dap.sent_terminated_event = true; + g_dap.RunTerminateCommands(); // Send a "terminated" event llvm::json::Object event(CreateTerminatedEventObject()); - g_vsc.SendJSON(llvm::json::Value(std::move(event))); + g_dap.SendJSON(llvm::json::Value(std::move(event))); } } // Send a thread stopped event for all threads as long as the process // is stopped. void SendThreadStoppedEvent() { - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); if (process.IsValid()) { auto state = process.GetState(); if (state == lldb::eStateStopped) { llvm::DenseSet old_thread_ids; - old_thread_ids.swap(g_vsc.thread_ids); + old_thread_ids.swap(g_dap.thread_ids); uint32_t stop_id = process.GetStopID(); const uint32_t num_threads = process.GetNumThreads(); @@ -259,10 +259,10 @@ void SendThreadStoppedEvent() { const lldb::tid_t tid = thread.GetThreadID(); const bool has_reason = ThreadHasStopReason(thread); // If the focus thread doesn't have a stop reason, clear the thread ID - if (tid == g_vsc.focus_tid) { + if (tid == g_dap.focus_tid) { focus_thread_exists = true; if (!has_reason) - g_vsc.focus_tid = LLDB_INVALID_THREAD_ID; + g_dap.focus_tid = LLDB_INVALID_THREAD_ID; } if (has_reason) { ++num_threads_with_reason; @@ -271,47 +271,47 @@ void SendThreadStoppedEvent() { } } - // We will have cleared g_vsc.focus_tid if the focus thread doesn't have + // We will have cleared g_dap.focus_tid if the focus thread doesn't have // a stop reason, so if it was cleared, or wasn't set, or doesn't exist, // then set the focus thread to the first thread with a stop reason. - if (!focus_thread_exists || g_vsc.focus_tid == LLDB_INVALID_THREAD_ID) - g_vsc.focus_tid = first_tid_with_reason; + if (!focus_thread_exists || g_dap.focus_tid == LLDB_INVALID_THREAD_ID) + g_dap.focus_tid = first_tid_with_reason; // If no threads stopped with a reason, then report the first one so // we at least let the UI know we stopped. if (num_threads_with_reason == 0) { lldb::SBThread thread = process.GetThreadAtIndex(0); - g_vsc.focus_tid = thread.GetThreadID(); - g_vsc.SendJSON(CreateThreadStopped(thread, stop_id)); + g_dap.focus_tid = thread.GetThreadID(); + g_dap.SendJSON(CreateThreadStopped(thread, stop_id)); } else { for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) { lldb::SBThread thread = process.GetThreadAtIndex(thread_idx); - g_vsc.thread_ids.insert(thread.GetThreadID()); + g_dap.thread_ids.insert(thread.GetThreadID()); if (ThreadHasStopReason(thread)) { - g_vsc.SendJSON(CreateThreadStopped(thread, stop_id)); + g_dap.SendJSON(CreateThreadStopped(thread, stop_id)); } } } for (auto tid : old_thread_ids) { - auto end = g_vsc.thread_ids.end(); - auto pos = g_vsc.thread_ids.find(tid); + auto end = g_dap.thread_ids.end(); + auto pos = g_dap.thread_ids.find(tid); if (pos == end) SendThreadExitedEvent(tid); } } else { - if (g_vsc.log) - *g_vsc.log << "error: SendThreadStoppedEvent() when process" + if (g_dap.log) + *g_dap.log << "error: SendThreadStoppedEvent() when process" " isn't stopped (" << lldb::SBDebugger::StateAsCString(state) << ')' << std::endl; } } else { - if (g_vsc.log) - *g_vsc.log << "error: SendThreadStoppedEvent() invalid process" + if (g_dap.log) + *g_dap.log << "error: SendThreadStoppedEvent() invalid process" << std::endl; } - g_vsc.RunStopCommands(); + g_dap.RunStopCommands(); } // "ProcessEvent": { @@ -369,13 +369,13 @@ void SendThreadStoppedEvent() { // ] // } void SendProcessEvent(LaunchMethod launch_method) { - lldb::SBFileSpec exe_fspec = g_vsc.target.GetExecutable(); + lldb::SBFileSpec exe_fspec = g_dap.target.GetExecutable(); char exe_path[PATH_MAX]; exe_fspec.GetPath(exe_path, sizeof(exe_path)); llvm::json::Object event(CreateEventObject("process")); llvm::json::Object body; EmplaceSafeString(body, "name", std::string(exe_path)); - const auto pid = g_vsc.target.GetProcess().GetProcessID(); + const auto pid = g_dap.target.GetProcess().GetProcessID(); body.try_emplace("systemProcessId", (int64_t)pid); body.try_emplace("isLocalProcess", true); const char *startMethod = nullptr; @@ -392,7 +392,7 @@ void SendProcessEvent(LaunchMethod launch_method) { } body.try_emplace("startMethod", startMethod); event.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(event))); + g_dap.SendJSON(llvm::json::Value(std::move(event))); } // Grab any STDOUT and STDERR from the process and send it up to VS Code @@ -401,22 +401,22 @@ void SendStdOutStdErr(lldb::SBProcess &process) { char buffer[1024]; size_t count; while ((count = process.GetSTDOUT(buffer, sizeof(buffer))) > 0) - g_vsc.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count)); + g_dap.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count)); while ((count = process.GetSTDERR(buffer, sizeof(buffer))) > 0) - g_vsc.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count)); + g_dap.SendOutput(OutputType::Stderr, llvm::StringRef(buffer, count)); } void ProgressEventThreadFunction() { - lldb::SBListener listener("lldb-vscode.progress.listener"); - g_vsc.debugger.GetBroadcaster().AddListener( + lldb::SBListener listener("lldb-dap.progress.listener"); + g_dap.debugger.GetBroadcaster().AddListener( listener, lldb::SBDebugger::eBroadcastBitProgress); - g_vsc.broadcaster.AddListener(listener, eBroadcastBitStopProgressThread); + g_dap.broadcaster.AddListener(listener, eBroadcastBitStopProgressThread); lldb::SBEvent event; bool done = false; while (!done) { if (listener.WaitForEvent(1, event)) { const auto event_mask = event.GetType(); - if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) { + if (event.BroadcasterMatchesRef(g_dap.broadcaster)) { if (event_mask & eBroadcastBitStopProgressThread) { done = true; } @@ -428,7 +428,7 @@ void ProgressEventThreadFunction() { const char *message = lldb::SBDebugger::GetProgressFromEvent( event, progress_id, completed, total, is_debugger_specific); if (message) - g_vsc.SendProgressEvent(progress_id, message, completed, total); + g_dap.SendProgressEvent(progress_id, message, completed, total); } } } @@ -441,7 +441,7 @@ void ProgressEventThreadFunction() { // is required. void EventThreadFunction() { lldb::SBEvent event; - lldb::SBListener listener = g_vsc.debugger.GetListener(); + lldb::SBListener listener = g_dap.debugger.GetListener(); bool done = false; while (!done) { if (listener.WaitForEvent(1, event)) { @@ -477,7 +477,7 @@ void EventThreadFunction() { // stop events which we do not want to send an event for. We will // manually send a stopped event in request_configurationDone(...) // so don't send any before then. - if (g_vsc.configuration_done_sent) { + if (g_dap.configuration_done_sent) { // Only report a stopped event if the process was not // automatically restarted. if (!lldb::SBProcess::GetRestartedFromEvent(event)) { @@ -487,7 +487,7 @@ void EventThreadFunction() { } break; case lldb::eStateRunning: - g_vsc.WillContinue(); + g_dap.WillContinue(); SendContinuedEvent(); break; case lldb::eStateExited: @@ -495,12 +495,12 @@ void EventThreadFunction() { // just killed with the old PID, or even with no PID. In that case // we don't have to terminate the session. if (process.GetProcessID() == LLDB_INVALID_PROCESS_ID || - process.GetProcessID() == g_vsc.restarting_process_id) { - g_vsc.restarting_process_id = LLDB_INVALID_PROCESS_ID; + process.GetProcessID() == g_dap.restarting_process_id) { + g_dap.restarting_process_id = LLDB_INVALID_PROCESS_ID; } else { // Run any exit LLDB commands the user specified in the // launch.json - g_vsc.RunExitCommands(); + g_dap.RunExitCommands(); SendProcessExitedEvent(process); SendTerminatedEvent(); done = true; @@ -537,10 +537,10 @@ void EventThreadFunction() { body.try_emplace("breakpoint", source_bp); body.try_emplace("reason", "changed"); bp_event.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(bp_event))); + g_dap.SendJSON(llvm::json::Value(std::move(bp_event))); } } - } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) { + } else if (event.BroadcasterMatchesRef(g_dap.broadcaster)) { if (event_mask & eBroadcastBitStopEventThread) { done = true; } @@ -569,7 +569,7 @@ void SetSourceMapFromArguments(const llvm::json::Object &arguments) { if (mapping == nullptr || mapping->size() != 2 || (*mapping)[0].kind() != llvm::json::Value::String || (*mapping)[1].kind() != llvm::json::Value::String) { - g_vsc.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); + g_dap.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); return; } auto mapFrom = GetAsString((*mapping)[0]); @@ -578,7 +578,7 @@ void SetSourceMapFromArguments(const llvm::json::Object &arguments) { } } else { if (ObjectContainsKey(arguments, "sourceMap")) { - g_vsc.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); + g_dap.SendOutput(OutputType::Console, llvm::StringRef(sourceMapHelp)); return; } if (sourcePath.empty()) @@ -588,7 +588,7 @@ void SetSourceMapFromArguments(const llvm::json::Object &arguments) { } strm.flush(); if (!sourceMapCommand.empty()) { - g_vsc.RunLLDBCommands("Setting source map:", {sourceMapCommand}); + g_dap.RunLLDBCommands("Setting source map:", {sourceMapCommand}); } } @@ -621,8 +621,8 @@ void SetSourceMapFromArguments(const llvm::json::Object &arguments) { // }] // } void request_attach(const llvm::json::Object &request) { - g_vsc.is_attach = true; - g_vsc.last_launch_or_attach_request = request; + g_dap.is_attach = true; + g_dap.last_launch_or_attach_request = request; llvm::json::Object response; lldb::SBError error; FillResponse(request, response); @@ -634,83 +634,83 @@ void request_attach(const llvm::json::Object &request) { attach_info.SetProcessID(pid); const auto wait_for = GetBoolean(arguments, "waitFor", false); attach_info.SetWaitForLaunch(wait_for, false /*async*/); - g_vsc.init_commands = GetStrings(arguments, "initCommands"); - g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands"); - g_vsc.stop_commands = GetStrings(arguments, "stopCommands"); - g_vsc.exit_commands = GetStrings(arguments, "exitCommands"); - g_vsc.terminate_commands = GetStrings(arguments, "terminateCommands"); + g_dap.init_commands = GetStrings(arguments, "initCommands"); + g_dap.pre_run_commands = GetStrings(arguments, "preRunCommands"); + g_dap.stop_commands = GetStrings(arguments, "stopCommands"); + g_dap.exit_commands = GetStrings(arguments, "exitCommands"); + g_dap.terminate_commands = GetStrings(arguments, "terminateCommands"); auto attachCommands = GetStrings(arguments, "attachCommands"); llvm::StringRef core_file = GetString(arguments, "coreFile"); const uint64_t timeout_seconds = GetUnsigned(arguments, "timeout", 30); - g_vsc.stop_at_entry = + g_dap.stop_at_entry = core_file.empty() ? GetBoolean(arguments, "stopOnEntry", false) : true; std::vector postRunCommands = GetStrings(arguments, "postRunCommands"); const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot"); - g_vsc.enable_auto_variable_summaries = + g_dap.enable_auto_variable_summaries = GetBoolean(arguments, "enableAutoVariableSummaries", false); - g_vsc.enable_synthetic_child_debugging = + g_dap.enable_synthetic_child_debugging = GetBoolean(arguments, "enableSyntheticChildDebugging", false); // This is a hack for loading DWARF in .o files on Mac where the .o files // in the debug map of the main executable have relative paths which require - // the lldb-vscode binary to have its working directory set to that relative + // the lldb-dap binary to have its working directory set to that relative // root for the .o files in order to be able to load debug info. if (!debuggerRoot.empty()) llvm::sys::fs::set_current_path(debuggerRoot); // Run any initialize LLDB commands the user specified in the launch.json - g_vsc.RunInitCommands(); + g_dap.RunInitCommands(); SetSourceMapFromArguments(*arguments); lldb::SBError status; - g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status)); + g_dap.SetTarget(g_dap.CreateTargetFromArguments(*arguments, status)); if (status.Fail()) { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", status.GetCString()); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } // Run any pre run LLDB commands the user specified in the launch.json - g_vsc.RunPreRunCommands(); + g_dap.RunPreRunCommands(); if (pid == LLDB_INVALID_PROCESS_ID && wait_for) { char attach_msg[256]; auto attach_msg_len = snprintf(attach_msg, sizeof(attach_msg), "Waiting to attach to \"%s\"...", - g_vsc.target.GetExecutable().GetFilename()); - g_vsc.SendOutput(OutputType::Console, + g_dap.target.GetExecutable().GetFilename()); + g_dap.SendOutput(OutputType::Console, llvm::StringRef(attach_msg, attach_msg_len)); } if (attachCommands.empty()) { // No "attachCommands", just attach normally. // Disable async events so the attach will be successful when we return from // the launch call and the launch will happen synchronously - g_vsc.debugger.SetAsync(false); + g_dap.debugger.SetAsync(false); if (core_file.empty()) - g_vsc.target.Attach(attach_info, error); + g_dap.target.Attach(attach_info, error); else - g_vsc.target.LoadCore(core_file.data(), error); + g_dap.target.LoadCore(core_file.data(), error); // Reenable async events - g_vsc.debugger.SetAsync(true); + g_dap.debugger.SetAsync(true); } else { // We have "attachCommands" that are a set of commands that are expected // to execute the commands after which a process should be created. If there // is no valid process after running these commands, we have failed. - g_vsc.RunLLDBCommands("Running attachCommands:", attachCommands); + g_dap.RunLLDBCommands("Running attachCommands:", attachCommands); // The custom commands might have created a new target so we should use the // selected target after these commands are run. - g_vsc.target = g_vsc.debugger.GetSelectedTarget(); + g_dap.target = g_dap.debugger.GetSelectedTarget(); // Make sure the process is attached and stopped before proceeding as the // the launch commands are not run using the synchronous mode. - error = g_vsc.WaitForProcessToStop(timeout_seconds); + error = g_dap.WaitForProcessToStop(timeout_seconds); } if (error.Success() && core_file.empty()) { - auto attached_pid = g_vsc.target.GetProcess().GetProcessID(); + auto attached_pid = g_dap.target.GetProcess().GetProcessID(); if (attached_pid == LLDB_INVALID_PROCESS_ID) { if (attachCommands.empty()) error.SetErrorString("failed to attach to a process"); @@ -723,13 +723,13 @@ void request_attach(const llvm::json::Object &request) { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", std::string(error.GetCString())); } else { - g_vsc.RunLLDBCommands("Running postRunCommands:", postRunCommands); + g_dap.RunLLDBCommands("Running postRunCommands:", postRunCommands); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); if (error.Success()) { SendProcessEvent(Attach); - g_vsc.SendJSON(CreateEventObject("initialized")); + g_dap.SendJSON(CreateEventObject("initialized")); } } @@ -790,12 +790,12 @@ void request_attach(const llvm::json::Object &request) { void request_continue(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); lldb::SBError error = process.Continue(); llvm::json::Object body; body.try_emplace("allThreadsContinued", true); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "ConfigurationDoneRequest": { @@ -832,12 +832,12 @@ void request_continue(const llvm::json::Object &request) { void request_configurationDone(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); - g_vsc.configuration_done_sent = true; - if (g_vsc.stop_at_entry) + g_dap.SendJSON(llvm::json::Value(std::move(response))); + g_dap.configuration_done_sent = true; + if (g_dap.stop_at_entry) SendThreadStoppedEvent(); else - g_vsc.target.GetProcess().Continue(); + g_dap.target.GetProcess().Continue(); } // "DisconnectRequest": { @@ -889,10 +889,10 @@ void request_disconnect(const llvm::json::Object &request) { FillResponse(request, response); auto arguments = request.getObject("arguments"); - bool defaultTerminateDebuggee = g_vsc.is_attach ? false : true; + bool defaultTerminateDebuggee = g_dap.is_attach ? false : true; bool terminateDebuggee = GetBoolean(arguments, "terminateDebuggee", defaultTerminateDebuggee); - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); auto state = process.GetState(); switch (state) { case lldb::eStateInvalid: @@ -908,22 +908,22 @@ void request_disconnect(const llvm::json::Object &request) { case lldb::eStateSuspended: case lldb::eStateStopped: case lldb::eStateRunning: - g_vsc.debugger.SetAsync(false); + g_dap.debugger.SetAsync(false); lldb::SBError error = terminateDebuggee ? process.Kill() : process.Detach(); if (!error.Success()) response.try_emplace("error", error.GetCString()); - g_vsc.debugger.SetAsync(true); + g_dap.debugger.SetAsync(true); break; } SendTerminatedEvent(); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); - if (g_vsc.event_thread.joinable()) { - g_vsc.broadcaster.BroadcastEventByType(eBroadcastBitStopEventThread); - g_vsc.event_thread.join(); + g_dap.SendJSON(llvm::json::Value(std::move(response))); + if (g_dap.event_thread.joinable()) { + g_dap.broadcaster.BroadcastEventByType(eBroadcastBitStopEventThread); + g_dap.event_thread.join(); } - if (g_vsc.progress_event_thread.joinable()) { - g_vsc.broadcaster.BroadcastEventByType(eBroadcastBitStopProgressThread); - g_vsc.progress_event_thread.join(); + if (g_dap.progress_event_thread.joinable()) { + g_dap.broadcaster.BroadcastEventByType(eBroadcastBitStopProgressThread); + g_dap.progress_event_thread.join(); } } @@ -932,13 +932,13 @@ void request_exceptionInfo(const llvm::json::Object &request) { FillResponse(request, response); auto arguments = request.getObject("arguments"); llvm::json::Object body; - lldb::SBThread thread = g_vsc.GetLLDBThread(*arguments); + lldb::SBThread thread = g_dap.GetLLDBThread(*arguments); if (thread.IsValid()) { auto stopReason = thread.GetStopReason(); if (stopReason == lldb::eStopReasonSignal) body.try_emplace("exceptionId", "signal"); else if (stopReason == lldb::eStopReasonBreakpoint) { - ExceptionBreakpoint *exc_bp = g_vsc.GetExceptionBPFromStopReason(thread); + ExceptionBreakpoint *exc_bp = g_dap.GetExceptionBPFromStopReason(thread); if (exc_bp) { EmplaceSafeString(body, "exceptionId", exc_bp->filter); EmplaceSafeString(body, "description", exc_bp->label); @@ -963,7 +963,7 @@ void request_exceptionInfo(const llvm::json::Object &request) { response["success"] = llvm::json::Value(false); } response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "CompletionsRequest": { @@ -1088,7 +1088,7 @@ void request_completions(const llvm::json::Object &request) { auto arguments = request.getObject("arguments"); // If we have a frame, try to set the context for variable completions. - lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments); + lldb::SBFrame frame = g_dap.GetLLDBFrame(*arguments); if (frame.IsValid()) { frame.GetThread().GetProcess().SetSelectedThread(frame.GetThread()); frame.GetThread().SetSelectedFrame(frame.GetFrameID()); @@ -1107,7 +1107,7 @@ void request_completions(const llvm::json::Object &request) { } llvm::json::Array targets; - if (g_vsc.DetectExpressionContext(frame, text) == + if (g_dap.DetectExpressionContext(frame, text) == ExpressionContext::Variable) { char command[] = "expression -- "; text = command + text; @@ -1116,7 +1116,7 @@ void request_completions(const llvm::json::Object &request) { lldb::SBStringList matches; lldb::SBStringList descriptions; - if (g_vsc.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions( + if (g_dap.debugger.GetCommandInterpreter().HandleCompletionWithDescriptions( text.c_str(), offset, 0, 100, matches, descriptions)) { // The first element is the common substring after the cursor position for // all the matches. The rest of the elements are the matches so ignore the @@ -1146,7 +1146,7 @@ void request_completions(const llvm::json::Object &request) { body.try_emplace("targets", std::move(targets)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "EvaluateRequest": { @@ -1255,16 +1255,16 @@ void request_evaluate(const llvm::json::Object &request) { FillResponse(request, response); llvm::json::Object body; auto arguments = request.getObject("arguments"); - lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments); + lldb::SBFrame frame = g_dap.GetLLDBFrame(*arguments); std::string expression = GetString(arguments, "expression").str(); llvm::StringRef context = GetString(arguments, "context"); - if (context == "repl" && g_vsc.DetectExpressionContext(frame, expression) == + if (context == "repl" && g_dap.DetectExpressionContext(frame, expression) == ExpressionContext::Command) { // If we're evaluating a command relative to the current frame, set the // focus_tid to the current frame for any thread related events. if (frame.IsValid()) { - g_vsc.focus_tid = frame.GetThread().GetThreadID(); + g_dap.focus_tid = frame.GetThread().GetThreadID(); } auto result = RunLLDBCommands(llvm::StringRef(), {std::string(expression)}); EmplaceSafeString(body, "result", result); @@ -1302,7 +1302,7 @@ void request_evaluate(const llvm::json::Object &request) { EmplaceSafeString(body, "type", value_typename ? value_typename : NO_TYPENAME); if (value.MightHaveChildren()) { - auto variableReference = g_vsc.variables.InsertExpandableVariable( + auto variableReference = g_dap.variables.InsertExpandableVariable( value, /*is_permanent=*/context == "repl"); body.try_emplace("variablesReference", variableReference); } else { @@ -1311,7 +1311,7 @@ void request_evaluate(const llvm::json::Object &request) { } } response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "compileUnitsRequest": { @@ -1361,9 +1361,9 @@ void request_compileUnits(const llvm::json::Object &request) { llvm::json::Array units; auto arguments = request.getObject("arguments"); std::string module_id = std::string(GetString(arguments, "moduleId")); - int num_modules = g_vsc.target.GetNumModules(); + int num_modules = g_dap.target.GetNumModules(); for (int i = 0; i < num_modules; i++) { - auto curr_module = g_vsc.target.GetModuleAtIndex(i); + auto curr_module = g_dap.target.GetModuleAtIndex(i); if (module_id == curr_module.GetUUIDString()) { int num_units = curr_module.GetNumCompileUnits(); for (int j = 0; j < num_units; j++) { @@ -1375,7 +1375,7 @@ void request_compileUnits(const llvm::json::Object &request) { } } response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "modulesRequest": { @@ -1409,15 +1409,15 @@ void request_modules(const llvm::json::Object &request) { FillResponse(request, response); llvm::json::Array modules; - for (size_t i = 0; i < g_vsc.target.GetNumModules(); i++) { - lldb::SBModule module = g_vsc.target.GetModuleAtIndex(i); + for (size_t i = 0; i < g_dap.target.GetNumModules(); i++) { + lldb::SBModule module = g_dap.target.GetModuleAtIndex(i); modules.emplace_back(CreateModule(module)); } llvm::json::Object body; body.try_emplace("modules", std::move(modules)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "InitializeRequest": { @@ -1498,7 +1498,7 @@ void request_modules(const llvm::json::Object &request) { // } void request_initialize(const llvm::json::Object &request) { auto log_cb = [](const char *buf, void *baton) -> void { - g_vsc.SendOutput(OutputType::Console, llvm::StringRef{buf}); + g_dap.SendOutput(OutputType::Console, llvm::StringRef{buf}); }; auto arguments = request.getObject("arguments"); @@ -1507,25 +1507,24 @@ void request_initialize(const llvm::json::Object &request) { // which may affect the outcome of tests. bool source_init_file = GetBoolean(arguments, "sourceInitFile", true); - g_vsc.debugger = - lldb::SBDebugger::Create(source_init_file, log_cb, nullptr); - auto cmd = g_vsc.debugger.GetCommandInterpreter().AddMultiwordCommand( - "lldb-vscode", "Commands for managing lldb-vscode."); + g_dap.debugger = lldb::SBDebugger::Create(source_init_file, log_cb, nullptr); + auto cmd = g_dap.debugger.GetCommandInterpreter().AddMultiwordCommand( + "lldb-dap", "Commands for managing lldb-dap."); if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) { cmd.AddCommand( - "startDebugging", &g_vsc.start_debugging_request_handler, + "startDebugging", &g_dap.start_debugging_request_handler, "Sends a startDebugging request from the debug adapter to the client " "to start a child debug session of the same type as the caller."); } cmd.AddCommand( - "repl-mode", &g_vsc.repl_mode_request_handler, - "Get or set the repl behavior of vscode-lldb evaluation requests."); + "repl-mode", &g_dap.repl_mode_request_handler, + "Get or set the repl behavior of lldb-dap evaluation requests."); - g_vsc.progress_event_thread = std::thread(ProgressEventThreadFunction); + g_dap.progress_event_thread = std::thread(ProgressEventThreadFunction); // Start our event thread so we can receive events from the debugger, target, // process and more. - g_vsc.event_thread = std::thread(EventThreadFunction); + g_dap.event_thread = std::thread(EventThreadFunction); llvm::json::Object response; FillResponse(request, response); @@ -1544,7 +1543,7 @@ void request_initialize(const llvm::json::Object &request) { body.try_emplace("supportsEvaluateForHovers", true); // Available filters or options for the setExceptionBreakpoints request. llvm::json::Array filters; - for (const auto &exc_bp : g_vsc.exception_breakpoints) { + for (const auto &exc_bp : g_dap.exception_breakpoints) { filters.emplace_back(CreateExceptionBreakpointFilter(exc_bp)); } body.try_emplace("exceptionBreakpointFilters", std::move(filters)); @@ -1607,12 +1606,12 @@ void request_initialize(const llvm::json::Object &request) { body.try_emplace("supportsLogPoints", true); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } llvm::Error request_runInTerminal(const llvm::json::Object &launch_request, const uint64_t timeout_seconds) { - g_vsc.is_attach = true; + g_dap.is_attach = true; lldb::SBAttachInfo attach_info; llvm::Expected> comm_file_or_err = @@ -1628,8 +1627,8 @@ llvm::Error request_runInTerminal(const llvm::json::Object &launch_request, debugger_pid = getpid(); #endif llvm::json::Object reverse_request = CreateRunInTerminalReverseRequest( - launch_request, g_vsc.debug_adaptor_path, comm_file.m_path, debugger_pid); - g_vsc.SendReverseRequest("runInTerminal", std::move(reverse_request), + launch_request, g_dap.debug_adaptor_path, comm_file.m_path, debugger_pid); + g_dap.SendReverseRequest("runInTerminal", std::move(reverse_request), [](llvm::Expected value) { if (!value) { llvm::Error err = value.takeError(); @@ -1644,9 +1643,9 @@ llvm::Error request_runInTerminal(const llvm::json::Object &launch_request, else return pid.takeError(); - g_vsc.debugger.SetAsync(false); + g_dap.debugger.SetAsync(false); lldb::SBError error; - g_vsc.target.Attach(attach_info, error); + g_dap.target.Attach(attach_info, error); if (error.Fail()) return llvm::createStringError(llvm::inconvertibleErrorCode(), @@ -1664,11 +1663,11 @@ llvm::Error request_runInTerminal(const llvm::json::Object &launch_request, // process right in the middle of the exec. To the user, what we are doing is // transparent, as they will only be able to see the process since the exec, // completely unaware of the preparatory work. - g_vsc.target.GetProcess().Continue(); + g_dap.target.GetProcess().Continue(); // Now that the actual target is just starting (i.e. exec was just invoked), // we return the debugger to its async state. - g_vsc.debugger.SetAsync(true); + g_dap.debugger.SetAsync(true); // If sending the notification failed, the launcher should be dead by now and // the async didAttach notification should have an error message, so we @@ -1691,7 +1690,7 @@ lldb::SBError LaunchProcess(const llvm::json::Object &request) { auto launchCommands = GetStrings(arguments, "launchCommands"); // Instantiate a launch info instance for the target. - auto launch_info = g_vsc.target.GetLaunchInfo(); + auto launch_info = g_dap.target.GetLaunchInfo(); // Grab the current working directory if there is one and set it in the // launch info. @@ -1730,21 +1729,21 @@ lldb::SBError LaunchProcess(const llvm::json::Object &request) { } else if (launchCommands.empty()) { // Disable async events so the launch will be successful when we return from // the launch call and the launch will happen synchronously - g_vsc.debugger.SetAsync(false); - g_vsc.target.Launch(launch_info, error); - g_vsc.debugger.SetAsync(true); + g_dap.debugger.SetAsync(false); + g_dap.target.Launch(launch_info, error); + g_dap.debugger.SetAsync(true); } else { // Set the launch info so that run commands can access the configured // launch details. - g_vsc.target.SetLaunchInfo(launch_info); - g_vsc.RunLLDBCommands("Running launchCommands:", launchCommands); + g_dap.target.SetLaunchInfo(launch_info); + g_dap.RunLLDBCommands("Running launchCommands:", launchCommands); // The custom commands might have created a new target so we should use the // selected target after these commands are run. - g_vsc.target = g_vsc.debugger.GetSelectedTarget(); + g_dap.target = g_dap.debugger.GetSelectedTarget(); // Make sure the process is launched and stopped at the entry point before // proceeding as the launch commands are not run using the synchronous // mode. - error = g_vsc.WaitForProcessToStop(timeout_seconds); + error = g_dap.WaitForProcessToStop(timeout_seconds); } return error; } @@ -1784,28 +1783,28 @@ lldb::SBError LaunchProcess(const llvm::json::Object &request) { // }] // } void request_launch(const llvm::json::Object &request) { - g_vsc.is_attach = false; - g_vsc.last_launch_or_attach_request = request; + g_dap.is_attach = false; + g_dap.last_launch_or_attach_request = request; llvm::json::Object response; FillResponse(request, response); auto arguments = request.getObject("arguments"); - g_vsc.init_commands = GetStrings(arguments, "initCommands"); - g_vsc.pre_run_commands = GetStrings(arguments, "preRunCommands"); - g_vsc.stop_commands = GetStrings(arguments, "stopCommands"); - g_vsc.exit_commands = GetStrings(arguments, "exitCommands"); - g_vsc.terminate_commands = GetStrings(arguments, "terminateCommands"); + g_dap.init_commands = GetStrings(arguments, "initCommands"); + g_dap.pre_run_commands = GetStrings(arguments, "preRunCommands"); + g_dap.stop_commands = GetStrings(arguments, "stopCommands"); + g_dap.exit_commands = GetStrings(arguments, "exitCommands"); + g_dap.terminate_commands = GetStrings(arguments, "terminateCommands"); std::vector postRunCommands = GetStrings(arguments, "postRunCommands"); - g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false); + g_dap.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false); const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot"); - g_vsc.enable_auto_variable_summaries = + g_dap.enable_auto_variable_summaries = GetBoolean(arguments, "enableAutoVariableSummaries", false); - g_vsc.enable_synthetic_child_debugging = + g_dap.enable_synthetic_child_debugging = GetBoolean(arguments, "enableSyntheticChildDebugging", false); // This is a hack for loading DWARF in .o files on Mac where the .o files // in the debug map of the main executable have relative paths which require - // the lldb-vscode binary to have its working directory set to that relative + // the lldb-dap binary to have its working directory set to that relative // root for the .o files in order to be able to load debug info. if (!debuggerRoot.empty()) llvm::sys::fs::set_current_path(debuggerRoot); @@ -1813,21 +1812,21 @@ void request_launch(const llvm::json::Object &request) { // Run any initialize LLDB commands the user specified in the launch.json. // This is run before target is created, so commands can't do anything with // the targets - preRunCommands are run with the target. - g_vsc.RunInitCommands(); + g_dap.RunInitCommands(); SetSourceMapFromArguments(*arguments); lldb::SBError status; - g_vsc.SetTarget(g_vsc.CreateTargetFromArguments(*arguments, status)); + g_dap.SetTarget(g_dap.CreateTargetFromArguments(*arguments, status)); if (status.Fail()) { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", status.GetCString()); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } // Run any pre run LLDB commands the user specified in the launch.json - g_vsc.RunPreRunCommands(); + g_dap.RunPreRunCommands(); status = LaunchProcess(request); @@ -1835,18 +1834,18 @@ void request_launch(const llvm::json::Object &request) { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", std::string(status.GetCString())); } else { - g_vsc.RunLLDBCommands("Running postRunCommands:", postRunCommands); + g_dap.RunLLDBCommands("Running postRunCommands:", postRunCommands); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); if (!status.Fail()) { - if (g_vsc.is_attach) - SendProcessEvent(Attach); // this happens when doing runInTerminal + if (g_dap.is_attach) + SendProcessEvent(Attach); // this happens when doing runInTerminal else SendProcessEvent(Launch); } - g_vsc.SendJSON(CreateEventObject("initialized")); + g_dap.SendJSON(CreateEventObject("initialized")); } // "NextRequest": { @@ -1891,16 +1890,16 @@ void request_next(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); auto arguments = request.getObject("arguments"); - lldb::SBThread thread = g_vsc.GetLLDBThread(*arguments); + lldb::SBThread thread = g_dap.GetLLDBThread(*arguments); if (thread.IsValid()) { // Remember the thread ID that caused the resume so we can set the // "threadCausedFocus" boolean value in the "stopped" events. - g_vsc.focus_tid = thread.GetThreadID(); + g_dap.focus_tid = thread.GetThreadID(); thread.StepOver(); } else { response["success"] = llvm::json::Value(false); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "PauseRequest": { @@ -1942,12 +1941,11 @@ void request_next(const llvm::json::Object &request) { void request_pause(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); lldb::SBError error = process.Stop(); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } - // "RestartRequest": { // "allOf": [ { "$ref": "#/definitions/Request" }, { // "type": "object", @@ -1992,11 +1990,11 @@ void request_pause(const llvm::json::Object &request) { void request_restart(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); - if (!g_vsc.last_launch_or_attach_request) { + if (!g_dap.last_launch_or_attach_request) { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", "Restart request received but no process was launched."); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } // Check if we were in a "launch" session or an "attach" session. @@ -2008,12 +2006,12 @@ void request_restart(const llvm::json::Object &request) { // Note that when using runInTerminal we're technically attached, but it's an // implementation detail. The adapter *did* launch the process in response to // a "launch" command, so we can still stop it and re-run it. This is why we - // don't just check `g_vsc.is_attach`. - if (GetString(*g_vsc.last_launch_or_attach_request, "command") == "attach") { + // don't just check `g_dap.is_attach`. + if (GetString(*g_dap.last_launch_or_attach_request, "command") == "attach") { response["success"] = llvm::json::Value(false); EmplaceSafeString(response, "message", "Restarting an \"attach\" session is not supported."); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } @@ -2023,20 +2021,20 @@ void request_restart(const llvm::json::Object &request) { if (restart_arguments) { auto launch_request_arguments = restart_arguments->getObject("arguments"); if (launch_request_arguments) { - (*g_vsc.last_launch_or_attach_request)["arguments"] = + (*g_dap.last_launch_or_attach_request)["arguments"] = llvm::json::Value(llvm::json::Object(*launch_request_arguments)); } } // Keep track of the old PID so when we get a "process exited" event from the // killed process we can detect it and not shut down the whole session. - lldb::SBProcess process = g_vsc.target.GetProcess(); - g_vsc.restarting_process_id = process.GetProcessID(); + lldb::SBProcess process = g_dap.target.GetProcess(); + g_dap.restarting_process_id = process.GetProcessID(); // Stop the current process if necessary. The logic here is similar to // CommandObjectProcessLaunchOrAttach::StopProcessIfNecessary, except that // we don't ask the user for confirmation. - g_vsc.debugger.SetAsync(false); + g_dap.debugger.SetAsync(false); if (process.IsValid()) { lldb::StateType state = process.GetState(); if (state != lldb::eStateConnected) { @@ -2044,21 +2042,21 @@ void request_restart(const llvm::json::Object &request) { } // Clear the list of thread ids to avoid sending "thread exited" events // for threads of the process we are terminating. - g_vsc.thread_ids.clear(); + g_dap.thread_ids.clear(); } - g_vsc.debugger.SetAsync(true); - LaunchProcess(*g_vsc.last_launch_or_attach_request); + g_dap.debugger.SetAsync(true); + LaunchProcess(*g_dap.last_launch_or_attach_request); // This is normally done after receiving a "configuration done" request. // Because we're restarting, configuration has already happened so we can // continue the process right away. - if (g_vsc.stop_at_entry) { + if (g_dap.stop_at_entry) { SendThreadStoppedEvent(); } else { - g_vsc.target.GetProcess().Continue(); + g_dap.target.GetProcess().Continue(); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "ScopesRequest": { @@ -2117,7 +2115,7 @@ void request_scopes(const llvm::json::Object &request) { FillResponse(request, response); llvm::json::Object body; auto arguments = request.getObject("arguments"); - lldb::SBFrame frame = g_vsc.GetLLDBFrame(*arguments); + lldb::SBFrame frame = g_dap.GetLLDBFrame(*arguments); // As the user selects different stack frames in the GUI, a "scopes" request // will be sent to the DAP. This is the only way we know that the user has // selected a frame in a thread. There are no other notifications that are @@ -2137,18 +2135,18 @@ void request_scopes(const llvm::json::Object &request) { frame.GetThread().SetSelectedFrame(frame.GetFrameID()); } - g_vsc.variables.locals = frame.GetVariables(/*arguments=*/true, + g_dap.variables.locals = frame.GetVariables(/*arguments=*/true, /*locals=*/true, /*statics=*/false, /*in_scope_only=*/true); - g_vsc.variables.globals = frame.GetVariables(/*arguments=*/false, + g_dap.variables.globals = frame.GetVariables(/*arguments=*/false, /*locals=*/false, /*statics=*/true, /*in_scope_only=*/true); - g_vsc.variables.registers = frame.GetRegisters(); - body.try_emplace("scopes", g_vsc.CreateTopLevelScopes()); + g_dap.variables.registers = frame.GetRegisters(); + body.try_emplace("scopes", g_dap.CreateTopLevelScopes()); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "SetBreakpointsRequest": { @@ -2283,8 +2281,8 @@ void request_setBreakpoints(const llvm::json::Object &request) { request_bps[src_bp.line] = src_bp; // We check if this breakpoint already exists to update it - auto existing_source_bps = g_vsc.source_breakpoints.find(path); - if (existing_source_bps != g_vsc.source_breakpoints.end()) { + auto existing_source_bps = g_dap.source_breakpoints.find(path); + if (existing_source_bps != g_dap.source_breakpoints.end()) { const auto &existing_bp = existing_source_bps->second.find(src_bp.line); if (existing_bp != existing_source_bps->second.end()) { @@ -2295,8 +2293,8 @@ void request_setBreakpoints(const llvm::json::Object &request) { } } // At this point the breakpoint is new - g_vsc.source_breakpoints[path][src_bp.line] = src_bp; - SourceBreakpoint &new_bp = g_vsc.source_breakpoints[path][src_bp.line]; + g_dap.source_breakpoints[path][src_bp.line] = src_bp; + SourceBreakpoint &new_bp = g_dap.source_breakpoints[path][src_bp.line]; new_bp.SetBreakpoint(path.data()); AppendBreakpoint(new_bp.bp, response_breakpoints, path, new_bp.line); } @@ -2306,13 +2304,13 @@ void request_setBreakpoints(const llvm::json::Object &request) { // Delete any breakpoints in this source file that aren't in the // request_bps set. There is no call to remove breakpoints other than // calling this function with a smaller or empty "breakpoints" list. - auto old_src_bp_pos = g_vsc.source_breakpoints.find(path); - if (old_src_bp_pos != g_vsc.source_breakpoints.end()) { + auto old_src_bp_pos = g_dap.source_breakpoints.find(path); + if (old_src_bp_pos != g_dap.source_breakpoints.end()) { for (auto &old_bp : old_src_bp_pos->second) { auto request_pos = request_bps.find(old_bp.first); if (request_pos == request_bps.end()) { // This breakpoint no longer exists in this source file, delete it - g_vsc.target.BreakpointDelete(old_bp.second.bp.GetID()); + g_dap.target.BreakpointDelete(old_bp.second.bp.GetID()); old_src_bp_pos->second.erase(old_bp.first); } } @@ -2321,7 +2319,7 @@ void request_setBreakpoints(const llvm::json::Object &request) { llvm::json::Object body; body.try_emplace("breakpoints", std::move(response_breakpoints)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "SetExceptionBreakpointsRequest": { @@ -2380,23 +2378,23 @@ void request_setExceptionBreakpoints(const llvm::json::Object &request) { // Keep a list of any exception breakpoint filter names that weren't set // so we can clear any exception breakpoints if needed. std::set unset_filters; - for (const auto &bp : g_vsc.exception_breakpoints) + for (const auto &bp : g_dap.exception_breakpoints) unset_filters.insert(bp.filter); for (const auto &value : *filters) { const auto filter = GetAsString(value); - auto exc_bp = g_vsc.GetExceptionBreakpoint(std::string(filter)); + auto exc_bp = g_dap.GetExceptionBreakpoint(std::string(filter)); if (exc_bp) { exc_bp->SetBreakpoint(); unset_filters.erase(std::string(filter)); } } for (const auto &filter : unset_filters) { - auto exc_bp = g_vsc.GetExceptionBreakpoint(filter); + auto exc_bp = g_dap.GetExceptionBreakpoint(filter); if (exc_bp) exc_bp->ClearBreakpoint(); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "SetFunctionBreakpointsRequest": { @@ -2497,11 +2495,11 @@ void request_setFunctionBreakpoints(const llvm::json::Object &request) { // Disable any function breakpoints that aren't in the request_bps. // There is no call to remove function breakpoints other than calling this // function with a smaller or empty "breakpoints" list. - for (auto &pair : g_vsc.function_breakpoints) { + for (auto &pair : g_dap.function_breakpoints) { auto request_pos = request_bps.find(pair.first()); if (request_pos == request_bps.end()) { // This function breakpoint no longer exists delete it from LLDB - g_vsc.target.BreakpointDelete(pair.second.bp.GetID()); + g_dap.target.BreakpointDelete(pair.second.bp.GetID()); remove_names.push_back(pair.first()); } else { // Update the existing breakpoint as any setting withing the function @@ -2516,14 +2514,14 @@ void request_setFunctionBreakpoints(const llvm::json::Object &request) { } // Remove any breakpoints that are no longer in our list for (const auto &name : remove_names) - g_vsc.function_breakpoints.erase(name); + g_dap.function_breakpoints.erase(name); // Any breakpoints that are left in "request_bps" are breakpoints that // need to be set. for (auto &pair : request_bps) { // Add this breakpoint info to the response - g_vsc.function_breakpoints[pair.first()] = std::move(pair.second); - FunctionBreakpoint &new_bp = g_vsc.function_breakpoints[pair.first()]; + g_dap.function_breakpoints[pair.first()] = std::move(pair.second); + FunctionBreakpoint &new_bp = g_dap.function_breakpoints[pair.first()]; new_bp.SetBreakpoint(); AppendBreakpoint(new_bp.bp, response_breakpoints); } @@ -2531,7 +2529,7 @@ void request_setFunctionBreakpoints(const llvm::json::Object &request) { llvm::json::Object body; body.try_emplace("breakpoints", std::move(response_breakpoints)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "SourceRequest": { @@ -2597,7 +2595,7 @@ void request_source(const llvm::json::Object &request) { FillResponse(request, response); llvm::json::Object body{{"content", ""}}; response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "StackTraceRequest": { @@ -2675,7 +2673,7 @@ void request_stackTrace(const llvm::json::Object &request) { FillResponse(request, response); lldb::SBError error; auto arguments = request.getObject("arguments"); - lldb::SBThread thread = g_vsc.GetLLDBThread(*arguments); + lldb::SBThread thread = g_dap.GetLLDBThread(*arguments); llvm::json::Array stackFrames; llvm::json::Object body; @@ -2753,7 +2751,7 @@ void request_stackTrace(const llvm::json::Object &request) { } body.try_emplace("stackFrames", std::move(stackFrames)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "StepInRequest": { @@ -2805,16 +2803,16 @@ void request_stepIn(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); auto arguments = request.getObject("arguments"); - lldb::SBThread thread = g_vsc.GetLLDBThread(*arguments); + lldb::SBThread thread = g_dap.GetLLDBThread(*arguments); if (thread.IsValid()) { // Remember the thread ID that caused the resume so we can set the // "threadCausedFocus" boolean value in the "stopped" events. - g_vsc.focus_tid = thread.GetThreadID(); + g_dap.focus_tid = thread.GetThreadID(); thread.StepInto(); } else { response["success"] = llvm::json::Value(false); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "StepOutRequest": { @@ -2857,16 +2855,16 @@ void request_stepOut(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); auto arguments = request.getObject("arguments"); - lldb::SBThread thread = g_vsc.GetLLDBThread(*arguments); + lldb::SBThread thread = g_dap.GetLLDBThread(*arguments); if (thread.IsValid()) { // Remember the thread ID that caused the resume so we can set the // "threadCausedFocus" boolean value in the "stopped" events. - g_vsc.focus_tid = thread.GetThreadID(); + g_dap.focus_tid = thread.GetThreadID(); thread.StepOut(); } else { response["success"] = llvm::json::Value(false); } - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "ThreadsRequest": { @@ -2906,7 +2904,7 @@ void request_stepOut(const llvm::json::Object &request) { // } void request_threads(const llvm::json::Object &request) { - lldb::SBProcess process = g_vsc.target.GetProcess(); + lldb::SBProcess process = g_dap.target.GetProcess(); llvm::json::Object response; FillResponse(request, response); @@ -2922,7 +2920,7 @@ void request_threads(const llvm::json::Object &request) { llvm::json::Object body; body.try_emplace("threads", std::move(threads)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "SetVariableRequest": { @@ -3034,10 +3032,10 @@ void request_setVariable(const llvm::json::Object &request) { // only specifies the variable reference of the enclosing scope/variable, and // the name of the variable. We could have two shadowed variables with the // same name in "Locals" or "Globals". In our case the "id" absolute index - // of the variable within the g_vsc.variables list. + // of the variable within the g_dap.variables list. const auto id_value = GetUnsigned(arguments, "id", UINT64_MAX); if (id_value != UINT64_MAX) { - variable = g_vsc.variables.GetVariable(id_value); + variable = g_dap.variables.GetVariable(id_value); } else if (lldb::SBValueList *top_scope = GetTopLevelScope(variablesReference)) { // variablesReference is one of our scopes, not an actual variable it is @@ -3060,7 +3058,7 @@ void request_setVariable(const llvm::json::Object &request) { // We have a named item within an actual variable so we need to find it // withing the container variable by name. - lldb::SBValue container = g_vsc.variables.GetVariable(variablesReference); + lldb::SBValue container = g_dap.variables.GetVariable(variablesReference); variable = container.GetChildMemberWithName(name.data()); if (!variable.IsValid()) { if (name.startswith("[")) { @@ -3081,12 +3079,12 @@ void request_setVariable(const llvm::json::Object &request) { SetValueForKey(variable, body, "value"); EmplaceSafeString(body, "type", variable.GetType().GetDisplayTypeName()); - // We don't know the index of the variable in our g_vsc.variables + // We don't know the index of the variable in our g_dap.variables // so always insert a new one to get its variablesReference. // is_permanent is false because debug console does not support // setVariable request. if (variable.MightHaveChildren()) - newVariablesReference = g_vsc.variables.InsertExpandableVariable( + newVariablesReference = g_dap.variables.InsertExpandableVariable( variable, /*is_permanent=*/false); body.try_emplace("variablesReference", newVariablesReference); @@ -3099,7 +3097,7 @@ void request_setVariable(const llvm::json::Object &request) { } response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "VariablesRequest": { @@ -3201,8 +3199,8 @@ void request_variables(const llvm::json::Object &request) { // and resolve what the pointer resolves to. Only change the format if the // format was set to the default format or if it was hex as some registers // have formats set for them. - const uint32_t addr_size = g_vsc.target.GetProcess().GetAddressByteSize(); - lldb::SBValue reg_set = g_vsc.variables.registers.GetValueAtIndex(0); + const uint32_t addr_size = g_dap.target.GetProcess().GetAddressByteSize(); + lldb::SBValue reg_set = g_dap.variables.registers.GetValueAtIndex(0); const uint32_t num_regs = reg_set.GetNumChildren(); for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) { lldb::SBValue reg = reg_set.GetChildAtIndex(reg_idx); @@ -3260,7 +3258,7 @@ void request_variables(const llvm::json::Object &request) { int64_t var_ref = 0; if (variable.MightHaveChildren() || variable.IsSynthetic()) { - var_ref = g_vsc.variables.InsertExpandableVariable( + var_ref = g_dap.variables.InsertExpandableVariable( variable, /*is_permanent=*/false); } variables.emplace_back(CreateVariable( @@ -3270,7 +3268,7 @@ void request_variables(const llvm::json::Object &request) { } else { // We are expanding a variable that has children, so we will return its // children. - lldb::SBValue variable = g_vsc.variables.GetVariable(variablesReference); + lldb::SBValue variable = g_dap.variables.GetVariable(variablesReference); if (variable.IsValid()) { auto addChild = [&](lldb::SBValue child, std::optional custom_name = {}) { @@ -3278,9 +3276,9 @@ void request_variables(const llvm::json::Object &request) { return; if (child.MightHaveChildren()) { auto is_permanent = - g_vsc.variables.IsPermanentVariableReference(variablesReference); + g_dap.variables.IsPermanentVariableReference(variablesReference); auto childVariablesReferences = - g_vsc.variables.InsertExpandableVariable(child, is_permanent); + g_dap.variables.InsertExpandableVariable(child, is_permanent); variables.emplace_back(CreateVariable( child, childVariablesReferences, childVariablesReferences, hex, /*is_name_duplicated=*/false, custom_name)); @@ -3300,7 +3298,7 @@ void request_variables(const llvm::json::Object &request) { // "[raw]" child that can be used to inspect the raw version of a // synthetic member. That eliminates the need for the user to go to the // debug console and type `frame var to get these values. - if (g_vsc.enable_synthetic_child_debugging && variable.IsSynthetic() && + if (g_dap.enable_synthetic_child_debugging && variable.IsSynthetic() && i == num_children) addChild(variable.GetNonSyntheticValue(), "[raw]"); } @@ -3308,7 +3306,7 @@ void request_variables(const llvm::json::Object &request) { llvm::json::Object body; body.try_emplace("variables", std::move(variables)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // "DisassembleRequest": { @@ -3394,27 +3392,27 @@ void request_disassemble(const llvm::json::Object &request) { response["success"] = false; response["message"] = "Malformed memory reference: " + memoryReference.str(); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } addr_ptr += GetSigned(arguments, "instructionOffset", 0); - lldb::SBAddress addr(addr_ptr, g_vsc.target); + lldb::SBAddress addr(addr_ptr, g_dap.target); if (!addr.IsValid()) { response["success"] = false; response["message"] = "Memory reference not found in the current binary."; - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } const auto inst_count = GetUnsigned(arguments, "instructionCount", 0); lldb::SBInstructionList insts = - g_vsc.target.ReadInstructions(addr, inst_count); + g_dap.target.ReadInstructions(addr, inst_count); if (!insts.IsValid()) { response["success"] = false; response["message"] = "Failed to find instructions for memory address."; - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); return; } @@ -3424,11 +3422,11 @@ void request_disassemble(const llvm::json::Object &request) { for (size_t i = 0; i < num_insts; ++i) { lldb::SBInstruction inst = insts.GetInstructionAtIndex(i); auto addr = inst.GetAddress(); - const auto inst_addr = addr.GetLoadAddress(g_vsc.target); - const char *m = inst.GetMnemonic(g_vsc.target); - const char *o = inst.GetOperands(g_vsc.target); - const char *c = inst.GetComment(g_vsc.target); - auto d = inst.GetData(g_vsc.target); + const auto inst_addr = addr.GetLoadAddress(g_dap.target); + const char *m = inst.GetMnemonic(g_dap.target); + const char *o = inst.GetOperands(g_dap.target); + const char *c = inst.GetComment(g_dap.target); + auto d = inst.GetData(g_dap.target); std::string bytes; llvm::raw_string_ostream sb(bytes); @@ -3514,7 +3512,7 @@ void request_disassemble(const llvm::json::Object &request) { llvm::json::Object body; body.try_emplace("instructions", std::move(instructions)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } // A request used in testing to get the details on all breakpoints that are // currently set in the target. This helps us to test "setBreakpoints" and @@ -3524,48 +3522,48 @@ void request__testGetTargetBreakpoints(const llvm::json::Object &request) { llvm::json::Object response; FillResponse(request, response); llvm::json::Array response_breakpoints; - for (uint32_t i = 0; g_vsc.target.GetBreakpointAtIndex(i).IsValid(); ++i) { - auto bp = g_vsc.target.GetBreakpointAtIndex(i); + for (uint32_t i = 0; g_dap.target.GetBreakpointAtIndex(i).IsValid(); ++i) { + auto bp = g_dap.target.GetBreakpointAtIndex(i); AppendBreakpoint(bp, response_breakpoints); } llvm::json::Object body; body.try_emplace("breakpoints", std::move(response_breakpoints)); response.try_emplace("body", std::move(body)); - g_vsc.SendJSON(llvm::json::Value(std::move(response))); + g_dap.SendJSON(llvm::json::Value(std::move(response))); } void RegisterRequestCallbacks() { - g_vsc.RegisterRequestCallback("attach", request_attach); - g_vsc.RegisterRequestCallback("completions", request_completions); - g_vsc.RegisterRequestCallback("continue", request_continue); - g_vsc.RegisterRequestCallback("configurationDone", request_configurationDone); - g_vsc.RegisterRequestCallback("disconnect", request_disconnect); - g_vsc.RegisterRequestCallback("evaluate", request_evaluate); - g_vsc.RegisterRequestCallback("exceptionInfo", request_exceptionInfo); - g_vsc.RegisterRequestCallback("initialize", request_initialize); - g_vsc.RegisterRequestCallback("launch", request_launch); - g_vsc.RegisterRequestCallback("next", request_next); - g_vsc.RegisterRequestCallback("pause", request_pause); - g_vsc.RegisterRequestCallback("restart", request_restart); - g_vsc.RegisterRequestCallback("scopes", request_scopes); - g_vsc.RegisterRequestCallback("setBreakpoints", request_setBreakpoints); - g_vsc.RegisterRequestCallback("setExceptionBreakpoints", + g_dap.RegisterRequestCallback("attach", request_attach); + g_dap.RegisterRequestCallback("completions", request_completions); + g_dap.RegisterRequestCallback("continue", request_continue); + g_dap.RegisterRequestCallback("configurationDone", request_configurationDone); + g_dap.RegisterRequestCallback("disconnect", request_disconnect); + g_dap.RegisterRequestCallback("evaluate", request_evaluate); + g_dap.RegisterRequestCallback("exceptionInfo", request_exceptionInfo); + g_dap.RegisterRequestCallback("initialize", request_initialize); + g_dap.RegisterRequestCallback("launch", request_launch); + g_dap.RegisterRequestCallback("next", request_next); + g_dap.RegisterRequestCallback("pause", request_pause); + g_dap.RegisterRequestCallback("restart", request_restart); + g_dap.RegisterRequestCallback("scopes", request_scopes); + g_dap.RegisterRequestCallback("setBreakpoints", request_setBreakpoints); + g_dap.RegisterRequestCallback("setExceptionBreakpoints", request_setExceptionBreakpoints); - g_vsc.RegisterRequestCallback("setFunctionBreakpoints", + g_dap.RegisterRequestCallback("setFunctionBreakpoints", request_setFunctionBreakpoints); - g_vsc.RegisterRequestCallback("setVariable", request_setVariable); - g_vsc.RegisterRequestCallback("source", request_source); - g_vsc.RegisterRequestCallback("stackTrace", request_stackTrace); - g_vsc.RegisterRequestCallback("stepIn", request_stepIn); - g_vsc.RegisterRequestCallback("stepOut", request_stepOut); - g_vsc.RegisterRequestCallback("threads", request_threads); - g_vsc.RegisterRequestCallback("variables", request_variables); - g_vsc.RegisterRequestCallback("disassemble", request_disassemble); + g_dap.RegisterRequestCallback("setVariable", request_setVariable); + g_dap.RegisterRequestCallback("source", request_source); + g_dap.RegisterRequestCallback("stackTrace", request_stackTrace); + g_dap.RegisterRequestCallback("stepIn", request_stepIn); + g_dap.RegisterRequestCallback("stepOut", request_stepOut); + g_dap.RegisterRequestCallback("threads", request_threads); + g_dap.RegisterRequestCallback("variables", request_variables); + g_dap.RegisterRequestCallback("disassemble", request_disassemble); // Custom requests - g_vsc.RegisterRequestCallback("compileUnits", request_compileUnits); - g_vsc.RegisterRequestCallback("modules", request_modules); + g_dap.RegisterRequestCallback("compileUnits", request_compileUnits); + g_dap.RegisterRequestCallback("modules", request_modules); // Testing requests - g_vsc.RegisterRequestCallback("_testGetTargetBreakpoints", + g_dap.RegisterRequestCallback("_testGetTargetBreakpoints", request__testGetTargetBreakpoints); } @@ -3579,21 +3577,21 @@ static void printHelp(LLDBVSCodeOptTable &table, llvm::StringRef tool_name) { EXAMPLES: The debug adapter can be started in two modes. - Running lldb-vscode without any arguments will start communicating with the - parent over stdio. Passing a port number causes lldb-vscode to start listening + Running lldb-dap without any arguments will start communicating with the + parent over stdio. Passing a port number causes lldb-dap to start listening for connections on that port. - lldb-vscode -p + lldb-dap -p Passing --wait-for-debugger will pause the process at startup and wait for a debugger to attach to the process. - lldb-vscode -g + lldb-dap -g )___"; llvm::outs() << examples; } -// If --launch-target is provided, this instance of lldb-vscode becomes a +// If --launch-target is provided, this instance of lldb-dap becomes a // runInTerminal launcher. It will ultimately launch the program specified in // the --launch-target argument, which is the original program the user wanted // to debug. This is done in such a way that the actual debug adaptor can @@ -3638,7 +3636,7 @@ void LaunchRunInTerminalTarget(llvm::opt::Arg &target_arg, // using a signal to prevent being paused forever. // This env var should be used only for tests. - const char *timeout_env_var = getenv("LLDB_VSCODE_RIT_TIMEOUT_IN_MS"); + const char *timeout_env_var = getenv("LLDB_DAP_RIT_TIMEOUT_IN_MS"); int timeout_in_ms = timeout_env_var != nullptr ? atoi(timeout_env_var) : 20000; if (llvm::Error err = comm_channel.WaitUntilDebugAdaptorAttaches( @@ -3676,26 +3674,26 @@ int SetupStdoutStderrRedirection() { int stdoutfd = fileno(stdout); int new_stdout_fd = dup(stdoutfd); auto output_callback_stderr = [](llvm::StringRef data) { - g_vsc.SendOutput(OutputType::Stderr, data); + g_dap.SendOutput(OutputType::Stderr, data); }; auto output_callback_stdout = [](llvm::StringRef data) { - g_vsc.SendOutput(OutputType::Stdout, data); + g_dap.SendOutput(OutputType::Stdout, data); }; if (llvm::Error err = RedirectFd(stdoutfd, output_callback_stdout)) { std::string error_message = llvm::toString(std::move(err)); - if (g_vsc.log) - *g_vsc.log << error_message << std::endl; + if (g_dap.log) + *g_dap.log << error_message << std::endl; output_callback_stderr(error_message); } if (llvm::Error err = RedirectFd(fileno(stderr), output_callback_stderr)) { std::string error_message = llvm::toString(std::move(err)); - if (g_vsc.log) - *g_vsc.log << error_message << std::endl; + if (g_dap.log) + *g_dap.log << error_message << std::endl; output_callback_stderr(error_message); } /// used only by TestVSCode_redirection_to_console.py - if (getenv("LLDB_VSCODE_TEST_STDOUT_STDERR_REDIRECTION") != nullptr) + if (getenv("LLDB_DAP_TEST_STDOUT_STDERR_REDIRECTION") != nullptr) redirection_test(); return new_stdout_fd; } @@ -3706,7 +3704,7 @@ int main(int argc, char *argv[]) { llvm::SmallString<256> program_path(argv[0]); llvm::sys::fs::make_absolute(program_path); - g_vsc.debug_adaptor_path = program_path.str().str(); + g_dap.debug_adaptor_path = program_path.str().str(); LLDBVSCodeOptTable T; unsigned MAI, MAC; @@ -3722,11 +3720,11 @@ int main(int argc, char *argv[]) { llvm::opt::Arg *repl_mode = input_args.getLastArg(OPT_repl_mode); llvm::StringRef repl_mode_value = repl_mode->getValue(); if (repl_mode_value == "auto") { - g_vsc.repl_mode = ReplMode::Auto; + g_dap.repl_mode = ReplMode::Auto; } else if (repl_mode_value == "variable") { - g_vsc.repl_mode = ReplMode::Variable; + g_dap.repl_mode = ReplMode::Variable; } else if (repl_mode_value == "command") { - g_vsc.repl_mode = ReplMode::Command; + g_dap.repl_mode = ReplMode::Command; } else { llvm::errs() << "'" << repl_mode_value @@ -3742,7 +3740,8 @@ int main(int argc, char *argv[]) { if (debugger_pid) { llvm::StringRef debugger_pid_value = debugger_pid->getValue(); if (debugger_pid_value.getAsInteger(10, pid)) { - llvm::errs() << "'" << debugger_pid_value << "' is not a valid " + llvm::errs() << "'" << debugger_pid_value + << "' is not a valid " "PID\n"; return EXIT_FAILURE; } @@ -3796,20 +3795,20 @@ int main(int argc, char *argv[]) { printf("Listening on port %i...\n", portno); SOCKET socket_fd = AcceptConnection(portno); if (socket_fd >= 0) { - g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true); - g_vsc.output.descriptor = StreamDescriptor::from_socket(socket_fd, false); + g_dap.input.descriptor = StreamDescriptor::from_socket(socket_fd, true); + g_dap.output.descriptor = StreamDescriptor::from_socket(socket_fd, false); } else { return EXIT_FAILURE; } } else { - g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false); - g_vsc.output.descriptor = StreamDescriptor::from_file(new_stdout_fd, false); + g_dap.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false); + g_dap.output.descriptor = StreamDescriptor::from_file(new_stdout_fd, false); } bool CleanExit = true; - if (auto Err = g_vsc.Loop()) { - if (g_vsc.log) - *g_vsc.log << "Transport Error: " << llvm::toString(std::move(Err)) + if (auto Err = g_dap.Loop()) { + if (g_dap.log) + *g_dap.log << "Transport Error: " << llvm::toString(std::move(Err)) << "\n"; CleanExit = false; } diff --git a/lldb/tools/lldb-vscode/package.json b/lldb/tools/lldb-dap/package.json similarity index 97% rename from lldb/tools/lldb-vscode/package.json rename to lldb/tools/lldb-dap/package.json index 1b3d452f92ab8..79954cde2bbc8 100644 --- a/lldb/tools/lldb-vscode/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -1,5 +1,5 @@ { - "name": "lldb-vscode", + "name": "lldb-dap", "displayName": "LLDB VSCode", "version": "0.1.0", "publisher": "llvm", @@ -103,7 +103,7 @@ ], "debuggers": [ { - "type": "lldb-vscode", + "type": "lldb-dap", "label": "Native LLDB Debugger", "enableBreakpointsFor": { "languageIds": [ @@ -124,9 +124,9 @@ "swift" ] }, - "program": "./bin/lldb-vscode", + "program": "./bin/lldb-dap", "windows": { - "program": "./bin/lldb-vscode.exe" + "program": "./bin/lldb-dap.exe" }, "configurationAttributes": { "launch": { @@ -219,7 +219,7 @@ }, "launchCommands": { "type": "array", - "description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-vscode will auto resume if necessary.", + "description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-dap will auto resume if necessary.", "default": [] }, "stopCommands": { @@ -345,7 +345,7 @@ }, "initialConfigurations": [ { - "type": "lldb-vscode", + "type": "lldb-dap", "request": "launch", "name": "Debug", "program": "${workspaceRoot}/", @@ -359,7 +359,7 @@ "label": "LLDB: Launch", "description": "", "body": { - "type": "lldb-vscode", + "type": "lldb-dap", "request": "launch", "name": "${2:Launch}", "program": "^\"\\${workspaceRoot}/${1:}\"", diff --git a/lldb/tools/lldb-vscode/syntaxes/arm.disasm b/lldb/tools/lldb-dap/syntaxes/arm.disasm similarity index 100% rename from lldb/tools/lldb-vscode/syntaxes/arm.disasm rename to lldb/tools/lldb-dap/syntaxes/arm.disasm diff --git a/lldb/tools/lldb-vscode/syntaxes/arm64.disasm b/lldb/tools/lldb-dap/syntaxes/arm64.disasm similarity index 100% rename from lldb/tools/lldb-vscode/syntaxes/arm64.disasm rename to lldb/tools/lldb-dap/syntaxes/arm64.disasm diff --git a/lldb/tools/lldb-vscode/syntaxes/disassembly.json b/lldb/tools/lldb-dap/syntaxes/disassembly.json similarity index 100% rename from lldb/tools/lldb-vscode/syntaxes/disassembly.json rename to lldb/tools/lldb-dap/syntaxes/disassembly.json diff --git a/lldb/tools/lldb-vscode/syntaxes/x86.disasm b/lldb/tools/lldb-dap/syntaxes/x86.disasm similarity index 100% rename from lldb/tools/lldb-vscode/syntaxes/x86.disasm rename to lldb/tools/lldb-dap/syntaxes/x86.disasm diff --git a/lldb/tools/lldb-vscode b/lldb/tools/lldb-vscode new file mode 120000 index 0000000000000..46b40044086c9 --- /dev/null +++ b/lldb/tools/lldb-vscode @@ -0,0 +1 @@ +lldb-dap \ No newline at end of file diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index 94b43800c17bd..6847e47a7b47c 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -196,6 +196,9 @@ Changes to LLDB for formatters to quickly find directly nested type when it's known where to search for it, avoiding more expensive global search via ``SBTarget::FindFirstType``. +* ``lldb-vscode`` was renamed to ``lldb-dap`` and and its installation + instructions have been updated to reflect this. The underlying functionality + remains unchanged. Changes to Sanitizers ---------------------