1
1
import os
2
2
import time
3
3
4
- import vscode
4
+ import dap_server
5
5
from lldbsuite .test .lldbtest import *
6
6
7
7
8
- class VSCodeTestCaseBase (TestBase ):
8
+ class DAPTestCaseBase (TestBase ):
9
9
NO_DEBUG_INFO_TESTCASE = True
10
10
11
- def create_debug_adaptor (self , lldbVSCodeEnv = None ):
11
+ def create_debug_adaptor (self , lldbDAPEnv = None ):
12
12
"""Create the Visual Studio Code debug adaptor"""
13
13
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"
15
15
)
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 ,
19
19
init_commands = self .setUpCommands (),
20
20
log_file = log_file_path ,
21
- env = lldbVSCodeEnv ,
21
+ env = lldbDAPEnv ,
22
22
)
23
23
24
- def build_and_create_debug_adaptor (self , lldbVSCodeEnv = None ):
24
+ def build_and_create_debug_adaptor (self , lldbDAPEnv = None ):
25
25
self .build ()
26
- self .create_debug_adaptor (lldbVSCodeEnv )
26
+ self .create_debug_adaptor (lldbDAPEnv )
27
27
28
28
def set_source_breakpoints (self , source_path , lines , data = None ):
29
29
"""Sets source breakpoints and returns an array of strings containing
@@ -32,7 +32,7 @@ def set_source_breakpoints(self, source_path, lines, data=None):
32
32
Each object in data is 1:1 mapping with the entry in lines.
33
33
It contains optional location/hitCondition/logMessage parameters.
34
34
"""
35
- response = self .vscode .request_setBreakpoints (source_path , lines , data )
35
+ response = self .dap_server .request_setBreakpoints (source_path , lines , data )
36
36
if response is None :
37
37
return []
38
38
breakpoints = response ["body" ]["breakpoints" ]
@@ -46,7 +46,7 @@ def set_function_breakpoints(self, functions, condition=None, hitCondition=None)
46
46
and returns an array of strings containing the breakpoint IDs
47
47
("1", "2") for each breakpoint that was set.
48
48
"""
49
- response = self .vscode .request_setFunctionBreakpoints (
49
+ response = self .dap_server .request_setFunctionBreakpoints (
50
50
functions , condition = condition , hitCondition = hitCondition
51
51
)
52
52
if response is None :
@@ -70,7 +70,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
70
70
"breakpoint_ids" should be a list of breakpoint ID strings
71
71
(["1", "2"]). The return value from self.set_source_breakpoints()
72
72
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 ()
74
74
for stopped_event in stopped_events :
75
75
if "body" in stopped_event :
76
76
body = stopped_event ["body" ]
@@ -83,7 +83,7 @@ def verify_breakpoint_hit(self, breakpoint_ids):
83
83
# Descriptions for breakpoints will be in the form
84
84
# "breakpoint 1.1", so look for any description that matches
85
85
# ("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
87
87
# allow breakpoints to have multiple locations, but LLDB does.
88
88
# So when looking at the description we just want to make sure
89
89
# the right breakpoint matches and not worry about the actual
@@ -100,7 +100,7 @@ def verify_stop_exception_info(self, expected_description):
100
100
reason is 'exception' and that the description matches
101
101
'expected_description'
102
102
"""
103
- stopped_events = self .vscode .wait_for_stopped ()
103
+ stopped_events = self .dap_server .wait_for_stopped ()
104
104
for stopped_event in stopped_events :
105
105
if "body" in stopped_event :
106
106
body = stopped_event ["body" ]
@@ -150,7 +150,7 @@ def get_dict_value(self, d, key_path):
150
150
def get_stackFrames_and_totalFramesCount (
151
151
self , threadId = None , startFrame = None , levels = None , dump = False
152
152
):
153
- response = self .vscode .request_stackTrace (
153
+ response = self .dap_server .request_stackTrace (
154
154
threadId = threadId , startFrame = startFrame , levels = levels , dump = dump
155
155
)
156
156
if response :
@@ -185,16 +185,16 @@ def get_source_and_line(self, threadId=None, frameIndex=0):
185
185
return ("" , 0 )
186
186
187
187
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 )
189
189
190
190
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 )
192
192
193
193
def collect_console (self , duration ):
194
- return self .vscode .collect_output ("console" , duration = duration )
194
+ return self .dap_server .collect_output ("console" , duration = duration )
195
195
196
196
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 )
198
198
if value .startswith ("0x" ):
199
199
return int (value , 16 )
200
200
elif value .startswith ("0" ):
@@ -204,48 +204,48 @@ def get_local_as_int(self, name, threadId=None):
204
204
205
205
def set_local (self , name , value , id = None ):
206
206
"""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 )
208
208
209
209
def set_global (self , name , value , id = None ):
210
210
"""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 )
212
212
213
213
def stepIn (self , threadId = None , waitForStop = True ):
214
- self .vscode .request_stepIn (threadId = threadId )
214
+ self .dap_server .request_stepIn (threadId = threadId )
215
215
if waitForStop :
216
- return self .vscode .wait_for_stopped ()
216
+ return self .dap_server .wait_for_stopped ()
217
217
return None
218
218
219
219
def stepOver (self , threadId = None , waitForStop = True ):
220
- self .vscode .request_next (threadId = threadId )
220
+ self .dap_server .request_next (threadId = threadId )
221
221
if waitForStop :
222
- return self .vscode .wait_for_stopped ()
222
+ return self .dap_server .wait_for_stopped ()
223
223
return None
224
224
225
225
def stepOut (self , threadId = None , waitForStop = True ):
226
- self .vscode .request_stepOut (threadId = threadId )
226
+ self .dap_server .request_stepOut (threadId = threadId )
227
227
if waitForStop :
228
- return self .vscode .wait_for_stopped ()
228
+ return self .dap_server .wait_for_stopped ()
229
229
return None
230
230
231
231
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 ()
234
234
235
235
def continue_to_breakpoints (self , breakpoint_ids ):
236
- self .vscode .request_continue ()
236
+ self .dap_server .request_continue ()
237
237
self .verify_breakpoint_hit (breakpoint_ids )
238
238
239
239
def continue_to_exception_breakpoint (self , filter_label ):
240
- self .vscode .request_continue ()
240
+ self .dap_server .request_continue ()
241
241
self .assertTrue (
242
242
self .verify_stop_exception_info (filter_label ),
243
243
'verify we got "%s"' % (filter_label ),
244
244
)
245
245
246
246
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 ()
249
249
self .assertEquals (
250
250
len (stopped_events ), 1 , "stopped_events = {}" .format (stopped_events )
251
251
)
@@ -266,10 +266,10 @@ def disassemble(self, threadId=None, frameIndex=None):
266
266
memoryReference = stackFrames [0 ]["instructionPointerReference" ]
267
267
self .assertIsNotNone (memoryReference )
268
268
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 )
271
271
272
- return self .vscode .disassembled_instructions [memoryReference ]
272
+ return self .dap_server .disassembled_instructions [memoryReference ]
273
273
274
274
def attach (
275
275
self ,
@@ -289,22 +289,22 @@ def attach(
289
289
sourceMap = None ,
290
290
sourceInitFile = False ,
291
291
):
292
- """Build the default Makefile target, create the VSCode debug adaptor,
292
+ """Build the default Makefile target, create the DAP debug adaptor,
293
293
and attach to the process.
294
294
"""
295
295
296
- # Make sure we disconnect and terminate the VSCode debug adaptor even
296
+ # Make sure we disconnect and terminate the DAP debug adaptor even
297
297
# if we throw an exception during the test case.
298
298
def cleanup ():
299
299
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 ()
302
302
303
303
# Execute the cleanup function during test case tear down.
304
304
self .addTearDownHook (cleanup )
305
305
# 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 (
308
308
program = program ,
309
309
pid = pid ,
310
310
waitFor = waitFor ,
@@ -352,21 +352,21 @@ def launch(
352
352
enableAutoVariableSummaries = False ,
353
353
enableSyntheticChildDebugging = False ,
354
354
):
355
- """Sending launch request to vscode """
355
+ """Sending launch request to dap """
356
356
357
- # Make sure we disconnect and terminate the VSCode debug adapter,
357
+ # Make sure we disconnect and terminate the DAP debug adapter,
358
358
# if we throw an exception during the test case
359
359
def cleanup ():
360
360
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 ()
363
363
364
364
# Execute the cleanup function during test case tear down.
365
365
self .addTearDownHook (cleanup )
366
366
367
367
# 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 (
370
370
program ,
371
371
args = args ,
372
372
cwd = cwd ,
@@ -422,14 +422,14 @@ def build_and_launch(
422
422
runInTerminal = False ,
423
423
disconnectAutomatically = True ,
424
424
postRunCommands = None ,
425
- lldbVSCodeEnv = None ,
425
+ lldbDAPEnv = None ,
426
426
enableAutoVariableSummaries = False ,
427
427
enableSyntheticChildDebugging = False ,
428
428
):
429
- """Build the default Makefile target, create the VSCode debug adaptor,
429
+ """Build the default Makefile target, create the DAP debug adaptor,
430
430
and launch the process.
431
431
"""
432
- self .build_and_create_debug_adaptor (lldbVSCodeEnv )
432
+ self .build_and_create_debug_adaptor (lldbDAPEnv )
433
433
self .assertTrue (os .path .exists (program ), "executable must exist" )
434
434
435
435
return self .launch (
0 commit comments