2
2
Test lldb-dap disassemble request
3
3
"""
4
4
5
-
6
- import dap_server
7
- from lldbsuite .test .decorators import *
8
- from lldbsuite .test .lldbtest import *
9
- from lldbsuite .test import lldbutil
5
+ from lldbsuite .test .decorators import skipIfWindows
6
+ from lldbsuite .test .lldbtest import line_number
10
7
import lldbdap_testcase
11
- import os
12
8
13
9
14
10
class TestDAP_disassemble (lldbdap_testcase .DAPTestCaseBase ):
@@ -20,18 +16,35 @@ def test_disassemble(self):
20
16
program = self .getBuildArtifact ("a.out" )
21
17
self .build_and_launch (program )
22
18
source = "main.c"
23
- self .set_source_breakpoints (source , [line_number (source , "// breakpoint 1" )])
19
+ bp_line_no = line_number (source , "// breakpoint 1" )
20
+ self .set_source_breakpoints (source , [bp_line_no ])
24
21
self .continue_to_next_stop ()
25
22
26
- _ , pc_assembly = self .disassemble (frameIndex = 0 )
27
- self .assertIn ("location" , pc_assembly , "Source location missing." )
28
- self .assertIn ("instruction" , pc_assembly , "Assembly instruction missing." )
23
+ insts_with_bp , pc_with_bp_assembly = self .disassemble (frameIndex = 0 )
24
+ self .assertIn ("location" , pc_with_bp_assembly , "Source location missing." )
25
+ self .assertEqual (
26
+ pc_with_bp_assembly ["line" ], bp_line_no , "Expects the same line number"
27
+ )
28
+ no_bp = self .set_source_breakpoints (source , [])
29
+ self .assertEqual (len (no_bp ), 0 , "Expects no breakpoints." )
30
+ self .assertIn (
31
+ "instruction" , pc_with_bp_assembly , "Assembly instruction missing."
32
+ )
33
+
34
+ insts_no_bp , pc_no_bp_assembly = self .disassemble (frameIndex = 0 )
35
+ self .assertIn ("location" , pc_no_bp_assembly , "Source location missing." )
36
+ self .assertEqual (
37
+ pc_with_bp_assembly ["line" ], bp_line_no , "Expects the same line number"
38
+ )
39
+ # the disassembly instructions should be the same with breakpoint and no breakpoint;
40
+ self .assertDictEqual (
41
+ insts_with_bp ,
42
+ insts_no_bp ,
43
+ "Expects instructions are the same after removing breakpoints." ,
44
+ )
45
+ self .assertIn ("instruction" , pc_no_bp_assembly , "Assembly instruction missing." )
29
46
30
- # The calling frame (qsort) is coming from a system library, as a result
31
- # we should not have a source location.
32
- _ , qsort_assembly = self .disassemble (frameIndex = 1 )
33
- self .assertNotIn ("location" , qsort_assembly , "Source location not expected." )
34
- self .assertIn ("instruction" , pc_assembly , "Assembly instruction missing." )
47
+ self .continue_to_exit ()
35
48
36
49
@skipIfWindows
37
50
def test_disassemble_backwards (self ):
@@ -74,3 +87,7 @@ def test_disassemble_backwards(self):
74
87
backwards_instructions ,
75
88
f"requested instruction should be preceeded by { backwards_instructions } instructions. Actual index: { frame_instruction_index } " ,
76
89
)
90
+
91
+ # clear breakpoints
92
+ self .set_source_breakpoints (source , [])
93
+ self .continue_to_exit ()
0 commit comments