Skip to content

Commit c0fcec0

Browse files
Walter Erquinigoadrian-prantl
authored andcommitted
[source map] fix relative path breakpoints
https://reviews.llvm.org/D45592 added a nice feature to be able to specify a breakpoint by a relative path. E.g. passing foo.cpp or bar/foo.cpp or zaz/bar/foo.cpp is fine. However, https://reviews.llvm.org/D68671 by mistake disabled the test that ensured this functionality works. With time, someone made a small mistake and fully broke the functionality. So, I'm making a very simple fix and the test passes. Differential Revision: https://reviews.llvm.org/D107126 (cherry picked from commit 0a68443)
1 parent c3a2138 commit c0fcec0

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lldb/source/Breakpoint/BreakpointResolverFileLine.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
188188
// is 0, then we can't do this calculation. That can happen if
189189
// GetStartLineSourceInfo gets an error, or if the first line number in
190190
// the function really is 0 - which happens for some languages.
191-
191+
192192
// But only do this calculation if the line number we found in the SC
193193
// was different from the one requested in the source file. If we actually
194194
// found an exact match it must be valid.
@@ -229,18 +229,25 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
229229
const uint32_t line = m_location_spec.GetLine().getValueOr(0);
230230
const llvm::Optional<uint16_t> column = m_location_spec.GetColumn();
231231

232+
// We'll create a new SourceLocationSpec that can take into account the
233+
// relative path case, and we'll use it to resolve the symbol context
234+
// of the CUs.
232235
FileSpec search_file_spec = m_location_spec.GetFileSpec();
233236
const bool is_relative = search_file_spec.IsRelative();
234237
if (is_relative)
235238
search_file_spec.GetDirectory().Clear();
239+
SourceLocationSpec search_location_spec(
240+
search_file_spec, m_location_spec.GetLine().getValueOr(0),
241+
m_location_spec.GetColumn(), m_location_spec.GetCheckInlines(),
242+
m_location_spec.GetExactMatch());
236243

237244
const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
238245
for (size_t i = 0; i < num_comp_units; i++) {
239246
CompUnitSP cu_sp(context.module_sp->GetCompileUnitAtIndex(i));
240247
if (cu_sp) {
241248
if (filter.CompUnitPasses(*cu_sp))
242-
cu_sp->ResolveSymbolContext(m_location_spec, eSymbolContextEverything,
243-
sc_list);
249+
cu_sp->ResolveSymbolContext(search_location_spec,
250+
eSymbolContextEverything, sc_list);
244251
}
245252
}
246253

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BreakpointCommandTestCase(TestBase):
1818

1919
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
2020
@skipIfReproducer # side_effect bypasses reproducer
21-
def not_test_breakpoint_command_sequence(self):
21+
def test_breakpoint_command_sequence(self):
2222
"""Test a sequence of breakpoint command add, list, and delete."""
2323
self.build()
2424
self.breakpoint_command_sequence()
@@ -302,7 +302,7 @@ def test_breakpoint_delete_disabled(self):
302302
bp_id_1 = bp_1.GetID()
303303
bp_id_2 = bp_2.GetID()
304304
bp_id_3 = bp_3.GetID()
305-
305+
306306
self.runCmd("breakpoint delete --disabled DeleteMeNot")
307307

308308
bp_1 = target.FindBreakpointByID(bp_id_1)
@@ -320,7 +320,7 @@ def test_breakpoint_delete_disabled(self):
320320
bp_1.SetEnabled(False)
321321

322322
bp_id_1 = bp_1.GetID()
323-
323+
324324
self.runCmd("breakpoint delete --disabled")
325325

326326
bp_1 = target.FindBreakpointByID(bp_id_1)
@@ -331,4 +331,3 @@ def test_breakpoint_delete_disabled(self):
331331

332332
bp_3 = target.FindBreakpointByID(bp_id_3)
333333
self.assertFalse(bp_3.IsValid(), "Didn't delete disabled breakpoint 3")
334-

0 commit comments

Comments
 (0)