Author: Ebuka Ezike
Date: 2026-07-10T13:17:05+01:00
New Revision: c3cb6961edea526dcac75618f611f78618e33b5b

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

LOG: [lldb] Fix data race when setting a breakpoint in mulitple debuggers. 
(#208485)

When you have two SBDebugger with a target for the same `a.out` and you
try to add a breakpoint at the same location.

The data race happens in `CompileUnit::GetSupportFiles()` one debugger
sees the there is no support files. it sets the parsed flag and parses
the support file. The other debugger sees the parsed flag is set and
will not set the breakpoint since the support file is still parsing and
and will assume the symbol file does not have support files.

Added: 
    

Modified: 
    lldb/source/Breakpoint/BreakpointResolverFileLine.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index a38a4d6c8cc41..4c84a4f3e2a41 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -301,13 +302,15 @@ Searcher::CallbackReturn 
BreakpointResolverFileLine::SearchCallback(
   Target &target = GetBreakpoint()->GetTarget();
   RealpathPrefixes realpath_prefixes = target.GetSourceRealpathPrefixes();
 
-  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))
+  if (const auto sym_file = context.module_sp->GetSymbolFileLocked()) {
+    const size_t num_comp_units = sym_file->GetNumCompileUnits();
+    for (size_t i = 0; i < num_comp_units; i++) {
+
+      if (const auto cu_sp = sym_file->GetCompileUnitAtIndex(i);
+          cu_sp && filter.CompUnitPasses(*cu_sp)) {
         cu_sp->ResolveSymbolContext(m_location_spec, eSymbolContextEverything,
                                     sc_list, &realpath_prefixes);
+      }
     }
   }
 


        
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to