22Test lldb breakpoint with symlinks/realpath and source-map.
33"""
44
5-
65import lldb
76from lldbsuite .test .decorators import *
87from lldbsuite .test .lldbtest import *
@@ -32,66 +31,71 @@ def buildAndCreateTarget(self):
3231 target = self .dbg .CreateTarget (exe )
3332 self .assertTrue (target , VALID_TARGET )
3433
35- # Retrieve the associated command interpreter from our debugger.
36- ci = self .dbg .GetCommandInterpreter ()
37- self .assertTrue (ci , VALID_COMMAND_INTERPRETER )
38- return ci
39-
4034 @skipIf (oslist = ["windows" ])
41- def test_file_line_breakpoint_realpath (self ):
42- """Test file/line breakpoint where support files have symlinks."""
43- ci = self .buildAndCreateTarget ()
44-
45- file_path = self .getBuildArtifact ("a.out" )
46- print ("DEBUG" , file_path )
47-
48- res = lldb .SBCommandReturnObject ()
49- # ci.HandleCommand(f"b main.c:{self.line_in_main}", res)
50- # print("DEBUG OUT", res.GetOutput())
51- # print("DEBUG ERR", res.GetError())
52-
35+ def test_file_line_breakpoint_realpath_and_source_map (self ):
36+ """Test file/line breakpoint with realpathing and source-mapping."""
37+ self .buildAndCreateTarget ()
5338 cwd = os .getcwd ()
54- print ("DEBUG CWD" , cwd )
5539
5640 ######################################################################
5741 # Baseline
58- #- --------------------------------------------------------------------
42+ # --------------------------------------------------------------------
5943 # Breakpoints should be resolved with paths which are in the line-table.
6044 lldbutil .run_break_set_by_file_and_line (
6145 self , "main.c" , self .line_in_main , num_expected_locations = 1 , loc_exact = True
6246 )
6347 lldbutil .run_break_set_by_file_and_line (
64- self , "symlink1/foo.h" , self .line_in_foo , num_expected_locations = 1 , loc_exact = True
48+ self ,
49+ "symlink1/foo.h" ,
50+ self .line_in_foo ,
51+ num_expected_locations = 1 ,
52+ loc_exact = True ,
6553 )
6654 lldbutil .run_break_set_by_file_and_line (
67- self , "symlink2/bar.h" , self .line_in_bar , num_expected_locations = 1 , loc_exact = True
55+ self ,
56+ "symlink2/bar.h" ,
57+ self .line_in_bar ,
58+ num_expected_locations = 1 ,
59+ loc_exact = True ,
6860 )
6961 lldbutil .run_break_set_by_file_and_line (
70- self , "symlink2/qux.h" , self .line_in_qux , num_expected_locations = 1 , loc_exact = True
62+ self ,
63+ "symlink2/qux.h" ,
64+ self .line_in_qux ,
65+ num_expected_locations = 1 ,
66+ loc_exact = True ,
7167 )
7268
7369 ######################################################################
7470 # Symlinked file
75- #- --------------------------------------------------------------------
71+ # --------------------------------------------------------------------
7672 # - `symlink1/foo.h` is a symlink file, pointing at `real/foo.h`
7773 # - main.c includes `symlink1/foo.h`.
7874 # - As a result, the line-table contains a support file `(test_base_dir)/symlink1/foo.h`
7975 # - Setting a breakpoint for `real/foo.h` won't be resolved, because it doesn't match the above path.
8076 # - Setting a realpath prefix to the current working directory will cause the above support file to be realpath'ed to `(test_base_dir)/real/foo.h`
8177 # - Now setting a breakpoint for `real/foo.h` will be resolved.
8278 lldbutil .run_break_set_by_file_and_line (
83- self , "real/foo.h" , self .line_in_foo , num_expected_locations = 0 , loc_exact = True
79+ self ,
80+ "real/foo.h" ,
81+ self .line_in_foo ,
82+ num_expected_locations = 0 ,
83+ loc_exact = True ,
8484 )
8585 self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
8686 lldbutil .run_break_set_by_file_and_line (
87- self , "real/foo.h" , self .line_in_foo , num_expected_locations = 1 , loc_exact = True
87+ self ,
88+ "real/foo.h" ,
89+ self .line_in_foo ,
90+ num_expected_locations = 1 ,
91+ loc_exact = True ,
8892 )
8993 # Clear settings so that the test below won't be affected.
9094 self .runCmd ("settings clear target.source-realpath-prefixes" )
9195
9296 ######################################################################
9397 # Symlinked directory
94- #- --------------------------------------------------------------------
98+ # --------------------------------------------------------------------
9599 # - `symlink2` is a symlink directory, pointing at `real`.
96100 # - So, `symlink2/bar.h` will be realpath'ed to `real/bar.h`.
97101 # - main.c includes `symlink2/bar.h`.
@@ -100,18 +104,26 @@ def test_file_line_breakpoint_realpath(self):
100104 # - Setting a realpath prefix to the current working directory will cause the above support file to be realpath'ed to `(test_base_dir)/real/bar.h`
101105 # - Now setting a breakpoint for `real/bar.h` will be resolved.
102106 lldbutil .run_break_set_by_file_and_line (
103- self , "real/bar.h" , self .line_in_foo , num_expected_locations = 0 , loc_exact = True
107+ self ,
108+ "real/bar.h" ,
109+ self .line_in_foo ,
110+ num_expected_locations = 0 ,
111+ loc_exact = True ,
104112 )
105113 self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
106114 lldbutil .run_break_set_by_file_and_line (
107- self , "real/bar.h" , self .line_in_foo , num_expected_locations = 1 , loc_exact = True
115+ self ,
116+ "real/bar.h" ,
117+ self .line_in_foo ,
118+ num_expected_locations = 1 ,
119+ loc_exact = True ,
108120 )
109121 # Clear settings so that the test below won't be affected.
110122 self .runCmd ("settings clear target.source-realpath-prefixes" )
111123
112124 ######################################################################
113125 # Symlink + source-map
114- #- --------------------------------------------------------------------
126+ # --------------------------------------------------------------------
115127 # - `symlink2` is a symlink directory, pointing at `real`.
116128 # - So, `symlink2/qux.h` will be realpath'ed to `real/qux.h`.
117129 # - main.c includes `symlink2/qux.h`.
@@ -120,15 +132,27 @@ def test_file_line_breakpoint_realpath(self):
120132 # - Setting a breakpoint for `to-be-mapped/qux.h` won't be resolved, because it doesn't match the above path.
121133 # - After setting a source-map, setting the same breakpoint will be resolved, because the input path `to-be-mapped/qux.h` is reverse-mapped to `real/qux.h`, which matches the realpath'ed support file.
122134 lldbutil .run_break_set_by_file_and_line (
123- self , "real/qux.h" , self .line_in_foo , num_expected_locations = 0 , loc_exact = True
135+ self ,
136+ "real/qux.h" ,
137+ self .line_in_foo ,
138+ num_expected_locations = 0 ,
139+ loc_exact = True ,
124140 )
125141 self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
126142 lldbutil .run_break_set_by_file_and_line (
127- self , "to-be-mapped/qux.h" , self .line_in_foo , num_expected_locations = 0 , loc_exact = True
143+ self ,
144+ "to-be-mapped/qux.h" ,
145+ self .line_in_foo ,
146+ num_expected_locations = 0 ,
147+ loc_exact = True ,
128148 )
129149 self .runCmd ('settings set target.source-map "real" "to-be-mapped"' )
130150 lldbutil .run_break_set_by_file_and_line (
131- self , "to-be-mapped/qux.h" , self .line_in_foo , num_expected_locations = 1 , loc_exact = True
151+ self ,
152+ "to-be-mapped/qux.h" ,
153+ self .line_in_foo ,
154+ num_expected_locations = 1 ,
155+ loc_exact = True ,
132156 )
133157 # Clear settings so that the test below won't be affected.
134158 self .runCmd ("settings clear target.source-realpath-prefixes" )
0 commit comments