@@ -125,20 +125,18 @@ def test_set_and_clear(self):
125
125
# Set 3 breakpoints and verify that they got set correctly
126
126
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
127
127
line_to_id = {}
128
- if response :
129
- breakpoints = response ["body" ]["breakpoints" ]
130
- self .assertEqual (
131
- len (breakpoints ),
132
- len (lines ),
133
- "expect %u source breakpoints" % (len (lines )),
134
- )
135
- for breakpoint , index in zip (breakpoints , range (len (lines ))):
136
- line = breakpoint ["line" ]
137
- self .assertTrue (line , lines [index ])
138
- # Store the "id" of the breakpoint that was set for later
139
- line_to_id [line ] = breakpoint ["id" ]
140
- self .assertIn (line , lines , "line expected in lines array" )
141
- self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
128
+ breakpoints = response ["body" ]["breakpoints" ]
129
+ self .assertEqual (
130
+ len (breakpoints ),
131
+ len (lines ),
132
+ "expect %u source breakpoints" % (len (lines )),
133
+ )
134
+ for index , breakpoint in enumerate (breakpoints ):
135
+ line = breakpoint ["line" ]
136
+ self .assertEqual (line , lines [index ])
137
+ # Store the "id" of the breakpoint that was set for later
138
+ line_to_id [line ] = breakpoint ["id" ]
139
+ self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
142
140
143
141
# There is no breakpoint delete packet, clients just send another
144
142
# setBreakpoints packet with the same source file with fewer lines.
@@ -151,75 +149,66 @@ def test_set_and_clear(self):
151
149
# Set 2 breakpoints and verify that the previous breakpoints that were
152
150
# set above are still set.
153
151
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
154
- if response :
155
- breakpoints = response ["body" ]["breakpoints" ]
152
+ breakpoints = response ["body" ]["breakpoints" ]
153
+ self .assertEqual (
154
+ len (breakpoints ),
155
+ len (lines ),
156
+ "expect %u source breakpoints" % (len (lines )),
157
+ )
158
+ for index , breakpoint in enumerate (breakpoints ):
159
+ line = breakpoint ["line" ]
160
+ self .assertEqual (line , lines [index ])
161
+ # Verify the same breakpoints are still set within LLDB by
162
+ # making sure the breakpoint ID didn't change
156
163
self .assertEqual (
157
- len ( breakpoints ) ,
158
- len ( lines ) ,
159
- "expect %u source breakpoints" % ( len ( lines )) ,
164
+ line_to_id [ line ] ,
165
+ breakpoint [ "id" ] ,
166
+ "verify previous breakpoints stayed the same" ,
160
167
)
161
- for breakpoint , index in zip (breakpoints , range (len (lines ))):
162
- line = breakpoint ["line" ]
163
- self .assertTrue (line , lines [index ])
164
- # Verify the same breakpoints are still set within LLDB by
165
- # making sure the breakpoint ID didn't change
166
- self .assertEqual (
167
- line_to_id [line ],
168
- breakpoint ["id" ],
169
- "verify previous breakpoints stayed the same" ,
170
- )
171
- self .assertIn (line , lines , "line expected in lines array" )
172
- self .assertTrue (
173
- breakpoint ["verified" ], "expect breakpoint still verified"
174
- )
168
+ self .assertTrue (breakpoint ["verified" ], "expect breakpoint still verified" )
175
169
176
170
# Now get the full list of breakpoints set in the target and verify
177
171
# we have only 2 breakpoints set. The response above could have told
178
172
# us about 2 breakpoints, but we want to make sure we don't have the
179
173
# third one still set in the target
180
174
response = self .dap_server .request_testGetTargetBreakpoints ()
181
- if response :
182
- breakpoints = response ["body" ]["breakpoints" ]
175
+ breakpoints = response ["body" ]["breakpoints" ]
176
+ self .assertEqual (
177
+ len (breakpoints ),
178
+ len (lines ),
179
+ "expect %u source breakpoints" % (len (lines )),
180
+ )
181
+ for breakpoint in breakpoints :
182
+ line = breakpoint ["line" ]
183
+ # Verify the same breakpoints are still set within LLDB by
184
+ # making sure the breakpoint ID didn't change
183
185
self .assertEqual (
184
- len ( breakpoints ) ,
185
- len ( lines ) ,
186
- "expect %u source breakpoints" % ( len ( lines )) ,
186
+ line_to_id [ line ] ,
187
+ breakpoint [ "id" ] ,
188
+ "verify previous breakpoints stayed the same" ,
187
189
)
188
- for breakpoint in breakpoints :
189
- line = breakpoint ["line" ]
190
- # Verify the same breakpoints are still set within LLDB by
191
- # making sure the breakpoint ID didn't change
192
- self .assertEqual (
193
- line_to_id [line ],
194
- breakpoint ["id" ],
195
- "verify previous breakpoints stayed the same" ,
196
- )
197
- self .assertIn (line , lines , "line expected in lines array" )
198
- self .assertTrue (
199
- breakpoint ["verified" ], "expect breakpoint still verified"
200
- )
190
+ self .assertIn (line , lines , "line expected in lines array" )
191
+ self .assertTrue (breakpoint ["verified" ], "expect breakpoint still verified" )
201
192
202
193
# Now clear all breakpoints for the source file by passing down an
203
194
# empty lines array
204
195
lines = []
205
196
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
206
- if response :
207
- breakpoints = response ["body" ]["breakpoints" ]
208
- self .assertEqual (
209
- len (breakpoints ),
210
- len (lines ),
211
- "expect %u source breakpoints" % (len (lines )),
212
- )
197
+ breakpoints = response ["body" ]["breakpoints" ]
198
+ self .assertEqual (
199
+ len (breakpoints ),
200
+ len (lines ),
201
+ "expect %u source breakpoints" % (len (lines )),
202
+ )
213
203
214
204
# Verify with the target that all breakpoints have been cleared
215
205
response = self .dap_server .request_testGetTargetBreakpoints ()
216
- if response :
217
- breakpoints = response ["body" ]["breakpoints" ]
218
- self .assertEqual (
219
- len (breakpoints ),
220
- len (lines ),
221
- "expect %u source breakpoints" % (len (lines )),
222
- )
206
+ breakpoints = response ["body" ]["breakpoints" ]
207
+ self .assertEqual (
208
+ len (breakpoints ),
209
+ len (lines ),
210
+ "expect %u source breakpoints" % (len (lines )),
211
+ )
223
212
224
213
# Now set a breakpoint again in the same source file and verify it
225
214
# was added.
@@ -281,12 +270,11 @@ def test_clear_breakpoints_unset_breakpoints(self):
281
270
self .assertEqual (
282
271
len (breakpoints ), len (lines ), "expect %u source breakpoints" % (len (lines ))
283
272
)
284
- for breakpoint , index in zip (breakpoints , range ( len ( lines )) ):
273
+ for index , breakpoint in enumerate (breakpoints ):
285
274
line = breakpoint ["line" ]
286
- self .assertTrue (line , lines [index ])
275
+ self .assertEqual (line , lines [index ])
287
276
# Store the "id" of the breakpoint that was set for later
288
277
line_to_id [line ] = breakpoint ["id" ]
289
- self .assertIn (line , lines , "line expected in lines array" )
290
278
self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
291
279
292
280
# Now clear all breakpoints for the source file by not setting the
@@ -356,3 +344,49 @@ def test_functionality(self):
356
344
self .continue_to_breakpoints (breakpoint_ids )
357
345
i = int (self .dap_server .get_local_variable_value ("i" ))
358
346
self .assertEqual (i , 7 , "i != 7 showing post hitCondition hits every time" )
347
+
348
+ @skipIfWindows
349
+ def test_column_breakpoints (self ):
350
+ """Test setting multiple breakpoints in the same line at different columns."""
351
+ loop_line = line_number ("main.cpp" , "// break loop" )
352
+
353
+ program = self .getBuildArtifact ("a.out" )
354
+ self .build_and_launch (program )
355
+
356
+ # Set two breakpoints on the loop line at different columns.
357
+ columns = [13 , 39 ]
358
+ response = self .dap_server .request_setBreakpoints (
359
+ self .main_path , [loop_line , loop_line ], list ({"column" : c } for c in columns )
360
+ )
361
+
362
+ # Verify the breakpoints were set correctly
363
+ breakpoints = response ["body" ]["breakpoints" ]
364
+ breakpoint_ids = []
365
+ self .assertEqual (
366
+ len (breakpoints ),
367
+ len (columns ),
368
+ "expect %u source breakpoints" % (len (columns )),
369
+ )
370
+ for index , breakpoint in enumerate (breakpoints ):
371
+ self .assertEqual (breakpoint ["line" ], loop_line )
372
+ self .assertEqual (breakpoint ["column" ], columns [index ])
373
+ self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
374
+ breakpoint_ids .append (breakpoint ["id" ])
375
+
376
+ # Continue to the first breakpoint,
377
+ self .continue_to_breakpoints ([breakpoint_ids [0 ]])
378
+
379
+ # We should have stopped right before the call to `twelve`.
380
+ # Step into and check we are inside `twelve`.
381
+ self .stepIn ()
382
+ func_name = self .get_stackFrames ()[0 ]["name" ]
383
+ self .assertEqual (func_name , "twelve(int)" )
384
+
385
+ # Continue to the second breakpoint.
386
+ self .continue_to_breakpoints ([breakpoint_ids [1 ]])
387
+
388
+ # We should have stopped right before the call to `fourteen`.
389
+ # Step into and check we are inside `fourteen`.
390
+ self .stepIn ()
391
+ func_name = self .get_stackFrames ()[0 ]["name" ]
392
+ self .assertEqual (func_name , "a::fourteen(int)" )
0 commit comments