11import os
22import time
33
4- import vscode
4+ import dap_server
55from lldbsuite .test .lldbtest import *
66
77
8- class VSCodeTestCaseBase (TestBase ):
8+ class DAPTestCaseBase (TestBase ):
99 NO_DEBUG_INFO_TESTCASE = True
1010
11- def create_debug_adaptor (self , lldbVSCodeEnv = None ):
11+ def create_debug_adaptor (self , lldbDAPEnv = None ):
1212 """Create the Visual Studio Code debug adaptor"""
1313 self .assertTrue (
14- is_exe (self .lldbVSCodeExec ), "lldb-vscode must exist and be executable"
14+ is_exe (self .lldbDAPExec ), "lldb-dap must exist and be executable"
1515 )
16- log_file_path = self .getBuildArtifact ("vscode .txt" )
17- self .vscode = vscode . DebugAdaptor (
18- executable = self .lldbVSCodeExec ,
16+ log_file_path = self .getBuildArtifact ("dap .txt" )
17+ self .dap_server = dap_server . DebugAdaptorServer (
18+ executable = self .lldbDAPExec ,
1919 init_commands = self .setUpCommands (),
2020 log_file = log_file_path ,
21- env = lldbVSCodeEnv ,
21+ env = lldbDAPEnv ,
2222 )
2323
24- def build_and_create_debug_adaptor (self , lldbVSCodeEnv = None ):
24+ def build_and_create_debug_adaptor (self , lldbDAPEnv = None ):
2525 self .build ()
26- self .create_debug_adaptor (lldbVSCodeEnv )
26+ self .create_debug_adaptor (lldbDAPEnv )
2727
2828 def set_source_breakpoints (self , source_path , lines , data = None ):
2929 """Sets source breakpoints and returns an array of strings containing
@@ -32,7 +32,7 @@ def set_source_breakpoints(self, source_path, lines, data=None):
3232 Each object in data is 1:1 mapping with the entry in lines.
3333 It contains optional location/hitCondition/logMessage parameters.
3434 """
35- response = self .vscode .request_setBreakpoints (source_path , lines , data )
35+ response = self .dap_server .request_setBreakpoints (source_path , lines , data )
3636 if response is None :
3737 return []
3838 breakpoints = response ["body" ]["breakpoints" ]
@@ -46,7 +46,7 @@ def set_function_breakpoints(self, functions, condition=None, hitCondition=None)
4646 and returns an array of strings containing the breakpoint IDs
4747 ("1", "2") for each breakpoint that was set.
4848 """
49- response = self .vscode .request_setFunctionBreakpoints (
49+ response = self .dap_server .request_setFunctionBreakpoints (
5050 functions , condition = condition , hitCondition = hitCondition
5151 )
5252 if response is None :
@@ -70,7 +70,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
7070 "breakpoint_ids" should be a list of breakpoint ID strings
7171 (["1", "2"]). The return value from self.set_source_breakpoints()
7272 or self.set_function_breakpoints() can be passed to this function"""
73- stopped_events = self .vscode .wait_for_stopped ()
73+ stopped_events = self .dap_server .wait_for_stopped ()
7474 for stopped_event in stopped_events :
7575 if "body" in stopped_event :
7676 body = stopped_event ["body" ]
@@ -83,7 +83,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
8383 # Descriptions for breakpoints will be in the form
8484 # "breakpoint 1.1", so look for any description that matches
8585 # ("breakpoint 1.") in the description field as verification
86- # that one of the breakpoint locations was hit. VSCode doesn't
86+ # that one of the breakpoint locations was hit. DAP doesn't
8787 # allow breakpoints to have multiple locations, but LLDB does.
8888 # So when looking at the description we just want to make sure
8989 # the right breakpoint matches and not worry about the actual
@@ -100,7 +100,7 @@ def verify_stop_exception_info(self, expected_description):
100100 reason is 'exception' and that the description matches
101101 'expected_description'
102102 """
103- stopped_events = self .vscode .wait_for_stopped ()
103+ stopped_events = self .dap_server .wait_for_stopped ()
104104 for stopped_event in stopped_events :
105105 if "body" in stopped_event :
106106 body = stopped_event ["body" ]
@@ -150,7 +150,7 @@ def get_dict_value(self, d, key_path):
150150 def get_stackFrames_and_totalFramesCount (
151151 self , threadId = None , startFrame = None , levels = None , dump = False
152152 ):
153- response = self .vscode .request_stackTrace (
153+ response = self .dap_server .request_stackTrace (
154154 threadId = threadId , startFrame = startFrame , levels = levels , dump = dump
155155 )
156156 if response :
@@ -185,16 +185,16 @@ def get_source_and_line(self, threadId=None, frameIndex=0):
185185 return ("" , 0 )
186186
187187 def get_stdout (self , timeout = 0.0 ):
188- return self .vscode .get_output ("stdout" , timeout = timeout )
188+ return self .dap_server .get_output ("stdout" , timeout = timeout )
189189
190190 def get_console (self , timeout = 0.0 ):
191- return self .vscode .get_output ("console" , timeout = timeout )
191+ return self .dap_server .get_output ("console" , timeout = timeout )
192192
193193 def collect_console (self , duration ):
194- return self .vscode .collect_output ("console" , duration = duration )
194+ return self .dap_server .collect_output ("console" , duration = duration )
195195
196196 def get_local_as_int (self , name , threadId = None ):
197- value = self .vscode .get_local_variable_value (name , threadId = threadId )
197+ value = self .dap_server .get_local_variable_value (name , threadId = threadId )
198198 if value .startswith ("0x" ):
199199 return int (value , 16 )
200200 elif value .startswith ("0" ):
@@ -204,48 +204,48 @@ def get_local_as_int(self, name, threadId=None):
204204
205205 def set_local (self , name , value , id = None ):
206206 """Set a top level local variable only."""
207- return self .vscode .request_setVariable (1 , name , str (value ), id = id )
207+ return self .dap_server .request_setVariable (1 , name , str (value ), id = id )
208208
209209 def set_global (self , name , value , id = None ):
210210 """Set a top level global variable only."""
211- return self .vscode .request_setVariable (2 , name , str (value ), id = id )
211+ return self .dap_server .request_setVariable (2 , name , str (value ), id = id )
212212
213213 def stepIn (self , threadId = None , waitForStop = True ):
214- self .vscode .request_stepIn (threadId = threadId )
214+ self .dap_server .request_stepIn (threadId = threadId )
215215 if waitForStop :
216- return self .vscode .wait_for_stopped ()
216+ return self .dap_server .wait_for_stopped ()
217217 return None
218218
219219 def stepOver (self , threadId = None , waitForStop = True ):
220- self .vscode .request_next (threadId = threadId )
220+ self .dap_server .request_next (threadId = threadId )
221221 if waitForStop :
222- return self .vscode .wait_for_stopped ()
222+ return self .dap_server .wait_for_stopped ()
223223 return None
224224
225225 def stepOut (self , threadId = None , waitForStop = True ):
226- self .vscode .request_stepOut (threadId = threadId )
226+ self .dap_server .request_stepOut (threadId = threadId )
227227 if waitForStop :
228- return self .vscode .wait_for_stopped ()
228+ return self .dap_server .wait_for_stopped ()
229229 return None
230230
231231 def continue_to_next_stop (self ):
232- self .vscode .request_continue ()
233- return self .vscode .wait_for_stopped ()
232+ self .dap_server .request_continue ()
233+ return self .dap_server .wait_for_stopped ()
234234
235235 def continue_to_breakpoints (self , breakpoint_ids ):
236- self .vscode .request_continue ()
236+ self .dap_server .request_continue ()
237237 self .verify_breakpoint_hit (breakpoint_ids )
238238
239239 def continue_to_exception_breakpoint (self , filter_label ):
240- self .vscode .request_continue ()
240+ self .dap_server .request_continue ()
241241 self .assertTrue (
242242 self .verify_stop_exception_info (filter_label ),
243243 'verify we got "%s"' % (filter_label ),
244244 )
245245
246246 def continue_to_exit (self , exitCode = 0 ):
247- self .vscode .request_continue ()
248- stopped_events = self .vscode .wait_for_stopped ()
247+ self .dap_server .request_continue ()
248+ stopped_events = self .dap_server .wait_for_stopped ()
249249 self .assertEquals (
250250 len (stopped_events ), 1 , "stopped_events = {}" .format (stopped_events )
251251 )
@@ -266,10 +266,10 @@ def disassemble(self, threadId=None, frameIndex=None):
266266 memoryReference = stackFrames [0 ]["instructionPointerReference" ]
267267 self .assertIsNotNone (memoryReference )
268268
269- if memoryReference not in self .vscode .disassembled_instructions :
270- self .vscode .request_disassemble (memoryReference = memoryReference )
269+ if memoryReference not in self .dap_server .disassembled_instructions :
270+ self .dap_server .request_disassemble (memoryReference = memoryReference )
271271
272- return self .vscode .disassembled_instructions [memoryReference ]
272+ return self .dap_server .disassembled_instructions [memoryReference ]
273273
274274 def attach (
275275 self ,
@@ -289,22 +289,22 @@ def attach(
289289 sourceMap = None ,
290290 sourceInitFile = False ,
291291 ):
292- """Build the default Makefile target, create the VSCode debug adaptor,
292+ """Build the default Makefile target, create the DAP debug adaptor,
293293 and attach to the process.
294294 """
295295
296- # Make sure we disconnect and terminate the VSCode debug adaptor even
296+ # Make sure we disconnect and terminate the DAP debug adaptor even
297297 # if we throw an exception during the test case.
298298 def cleanup ():
299299 if disconnectAutomatically :
300- self .vscode .request_disconnect (terminateDebuggee = True )
301- self .vscode .terminate ()
300+ self .dap_server .request_disconnect (terminateDebuggee = True )
301+ self .dap_server .terminate ()
302302
303303 # Execute the cleanup function during test case tear down.
304304 self .addTearDownHook (cleanup )
305305 # Initialize and launch the program
306- self .vscode .request_initialize (sourceInitFile )
307- response = self .vscode .request_attach (
306+ self .dap_server .request_initialize (sourceInitFile )
307+ response = self .dap_server .request_attach (
308308 program = program ,
309309 pid = pid ,
310310 waitFor = waitFor ,
@@ -352,21 +352,21 @@ def launch(
352352 enableAutoVariableSummaries = False ,
353353 enableSyntheticChildDebugging = False ,
354354 ):
355- """Sending launch request to vscode """
355+ """Sending launch request to dap """
356356
357- # Make sure we disconnect and terminate the VSCode debug adapter,
357+ # Make sure we disconnect and terminate the DAP debug adapter,
358358 # if we throw an exception during the test case
359359 def cleanup ():
360360 if disconnectAutomatically :
361- self .vscode .request_disconnect (terminateDebuggee = True )
362- self .vscode .terminate ()
361+ self .dap_server .request_disconnect (terminateDebuggee = True )
362+ self .dap_server .terminate ()
363363
364364 # Execute the cleanup function during test case tear down.
365365 self .addTearDownHook (cleanup )
366366
367367 # Initialize and launch the program
368- self .vscode .request_initialize (sourceInitFile )
369- response = self .vscode .request_launch (
368+ self .dap_server .request_initialize (sourceInitFile )
369+ response = self .dap_server .request_launch (
370370 program ,
371371 args = args ,
372372 cwd = cwd ,
@@ -422,14 +422,14 @@ def build_and_launch(
422422 runInTerminal = False ,
423423 disconnectAutomatically = True ,
424424 postRunCommands = None ,
425- lldbVSCodeEnv = None ,
425+ lldbDAPEnv = None ,
426426 enableAutoVariableSummaries = False ,
427427 enableSyntheticChildDebugging = False ,
428428 ):
429- """Build the default Makefile target, create the VSCode debug adaptor,
429+ """Build the default Makefile target, create the DAP debug adaptor,
430430 and launch the process.
431431 """
432- self .build_and_create_debug_adaptor (lldbVSCodeEnv )
432+ self .build_and_create_debug_adaptor (lldbDAPEnv )
433433 self .assertTrue (os .path .exists (program ), "executable must exist" )
434434
435435 return self .launch (
0 commit comments