2
2
Test lldb breakpoint with symlinks/realpath and source-map.
3
3
"""
4
4
5
-
6
5
import lldb
7
6
from lldbsuite .test .decorators import *
8
7
from lldbsuite .test .lldbtest import *
@@ -32,66 +31,71 @@ def buildAndCreateTarget(self):
32
31
target = self .dbg .CreateTarget (exe )
33
32
self .assertTrue (target , VALID_TARGET )
34
33
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
-
40
34
@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 ()
53
38
cwd = os .getcwd ()
54
- print ("DEBUG CWD" , cwd )
55
39
56
40
######################################################################
57
41
# Baseline
58
- #- --------------------------------------------------------------------
42
+ # --------------------------------------------------------------------
59
43
# Breakpoints should be resolved with paths which are in the line-table.
60
44
lldbutil .run_break_set_by_file_and_line (
61
45
self , "main.c" , self .line_in_main , num_expected_locations = 1 , loc_exact = True
62
46
)
63
47
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 ,
65
53
)
66
54
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 ,
68
60
)
69
61
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 ,
71
67
)
72
68
73
69
######################################################################
74
70
# Symlinked file
75
- #- --------------------------------------------------------------------
71
+ # --------------------------------------------------------------------
76
72
# - `symlink1/foo.h` is a symlink file, pointing at `real/foo.h`
77
73
# - main.c includes `symlink1/foo.h`.
78
74
# - As a result, the line-table contains a support file `(test_base_dir)/symlink1/foo.h`
79
75
# - Setting a breakpoint for `real/foo.h` won't be resolved, because it doesn't match the above path.
80
76
# - 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`
81
77
# - Now setting a breakpoint for `real/foo.h` will be resolved.
82
78
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 ,
84
84
)
85
85
self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
86
86
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 ,
88
92
)
89
93
# Clear settings so that the test below won't be affected.
90
94
self .runCmd ("settings clear target.source-realpath-prefixes" )
91
95
92
96
######################################################################
93
97
# Symlinked directory
94
- #- --------------------------------------------------------------------
98
+ # --------------------------------------------------------------------
95
99
# - `symlink2` is a symlink directory, pointing at `real`.
96
100
# - So, `symlink2/bar.h` will be realpath'ed to `real/bar.h`.
97
101
# - main.c includes `symlink2/bar.h`.
@@ -100,18 +104,26 @@ def test_file_line_breakpoint_realpath(self):
100
104
# - 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`
101
105
# - Now setting a breakpoint for `real/bar.h` will be resolved.
102
106
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 ,
104
112
)
105
113
self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
106
114
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 ,
108
120
)
109
121
# Clear settings so that the test below won't be affected.
110
122
self .runCmd ("settings clear target.source-realpath-prefixes" )
111
123
112
124
######################################################################
113
125
# Symlink + source-map
114
- #- --------------------------------------------------------------------
126
+ # --------------------------------------------------------------------
115
127
# - `symlink2` is a symlink directory, pointing at `real`.
116
128
# - So, `symlink2/qux.h` will be realpath'ed to `real/qux.h`.
117
129
# - main.c includes `symlink2/qux.h`.
@@ -120,15 +132,27 @@ def test_file_line_breakpoint_realpath(self):
120
132
# - Setting a breakpoint for `to-be-mapped/qux.h` won't be resolved, because it doesn't match the above path.
121
133
# - 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.
122
134
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 ,
124
140
)
125
141
self .runCmd (f'settings set target.source-realpath-prefixes "{ cwd } "' )
126
142
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 ,
128
148
)
129
149
self .runCmd ('settings set target.source-map "real" "to-be-mapped"' )
130
150
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 ,
132
156
)
133
157
# Clear settings so that the test below won't be affected.
134
158
self .runCmd ("settings clear target.source-realpath-prefixes" )
0 commit comments