[Lldb-commits] [lldb] 0a68443 - [source map] fix relative path breakpoints

Walter Erquinigo via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 29 18:36:25 PDT 2021


Author: Walter Erquinigo
Date: 2021-07-29T18:36:06-07:00
New Revision: 0a68443bd07c48dbaf554f6e3b26b3ab5ed1d383

URL: https://github.com/llvm/llvm-project/commit/0a68443bd07c48dbaf554f6e3b26b3ab5ed1d383
DIFF: https://github.com/llvm/llvm-project/commit/0a68443bd07c48dbaf554f6e3b26b3ab5ed1d383.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
    lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 1d1ac2e90bdc..be4616064f9e 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -188,7 +188,7 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
     // is 0, then we can't do this calculation.  That can happen if
     // GetStartLineSourceInfo gets an error, or if the first line number in
     // the function really is 0 - which happens for some languages.
-    
+
     // But only do this calculation if the line number we found in the SC
     // was 
diff erent from the one requested in the source file.  If we actually
     // found an exact match it must be valid.
@@ -229,18 +229,25 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
   const uint32_t line = m_location_spec.GetLine().getValueOr(0);
   const llvm::Optional<uint16_t> column = m_location_spec.GetColumn();
 
+  // We'll create a new SourceLocationSpec that can take into account the
+  // relative path case, and we'll use it to resolve the symbol context
+  // of the CUs.
   FileSpec search_file_spec = m_location_spec.GetFileSpec();
   const bool is_relative = search_file_spec.IsRelative();
   if (is_relative)
     search_file_spec.GetDirectory().Clear();
+  SourceLocationSpec search_location_spec(
+      search_file_spec, m_location_spec.GetLine().getValueOr(0),
+      m_location_spec.GetColumn(), m_location_spec.GetCheckInlines(),
+      m_location_spec.GetExactMatch());
 
   const size_t num_comp_units = context.module_sp->GetNumCompileUnits();
   for (size_t i = 0; i < num_comp_units; i++) {
     CompUnitSP cu_sp(context.module_sp->GetCompileUnitAtIndex(i));
     if (cu_sp) {
       if (filter.CompUnitPasses(*cu_sp))
-        cu_sp->ResolveSymbolContext(m_location_spec, eSymbolContextEverything,
-                                    sc_list);
+        cu_sp->ResolveSymbolContext(search_location_spec,
+                                    eSymbolContextEverything, sc_list);
     }
   }
 

diff  --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index 5f10cd751451..3fc21ad7eed9 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -18,7 +18,7 @@ class BreakpointCommandTestCase(TestBase):
 
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
     @skipIfReproducer # side_effect bypasses reproducer
-    def not_test_breakpoint_command_sequence(self):
+    def test_breakpoint_command_sequence(self):
         """Test a sequence of breakpoint command add, list, and delete."""
         self.build()
         self.breakpoint_command_sequence()
@@ -302,7 +302,7 @@ def test_breakpoint_delete_disabled(self):
         bp_id_1 = bp_1.GetID()
         bp_id_2 = bp_2.GetID()
         bp_id_3 = bp_3.GetID()
-        
+
         self.runCmd("breakpoint delete --disabled DeleteMeNot")
 
         bp_1 = target.FindBreakpointByID(bp_id_1)
@@ -320,7 +320,7 @@ def test_breakpoint_delete_disabled(self):
         bp_1.SetEnabled(False)
 
         bp_id_1 = bp_1.GetID()
-        
+
         self.runCmd("breakpoint delete --disabled")
 
         bp_1 = target.FindBreakpointByID(bp_id_1)
@@ -331,4 +331,3 @@ def test_breakpoint_delete_disabled(self):
 
         bp_3 = target.FindBreakpointByID(bp_id_3)
         self.assertFalse(bp_3.IsValid(), "Didn't delete disabled breakpoint 3")
-        


        


More information about the lldb-commits mailing list