22Test lldb-dap disassemble request
33"""
44
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
107import lldbdap_testcase
11- import os
128
139
1410class TestDAP_disassemble (lldbdap_testcase .DAPTestCaseBase ):
@@ -20,18 +16,35 @@ def test_disassemble(self):
2016 program = self .getBuildArtifact ("a.out" )
2117 self .build_and_launch (program )
2218 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 ])
2421 self .continue_to_next_stop ()
2522
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." )
2946
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 ()
3548
3649 @skipIfWindows
3750 def test_disassemble_backwards (self ):
@@ -74,3 +87,7 @@ def test_disassemble_backwards(self):
7487 backwards_instructions ,
7588 f"requested instruction should be preceeded by { backwards_instructions } instructions. Actual index: { frame_instruction_index } " ,
7689 )
90+
91+ # clear breakpoints
92+ self .set_source_breakpoints (source , [])
93+ self .continue_to_exit ()
0 commit comments