[Lldb-commits] [lldb] Add a scripted way to re-present a stop location (PR #158128)

via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 11 11:12:29 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,c,cpp -- lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c lldb/include/lldb/API/SBBreakpoint.h lldb/include/lldb/API/SBBreakpointLocation.h lldb/include/lldb/API/SBFrame.h lldb/include/lldb/Breakpoint/Breakpoint.h lldb/include/lldb/Breakpoint/BreakpointLocation.h lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h lldb/include/lldb/Breakpoint/BreakpointLocationList.h lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h lldb/include/lldb/Breakpoint/BreakpointSite.h lldb/include/lldb/Breakpoint/StopPointSiteList.h lldb/include/lldb/Breakpoint/StoppointSite.h lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/source/API/SBBreakpoint.cpp lldb/source/Breakpoint/Breakpoint.cpp lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Breakpoint/BreakpointLocationCollection.cpp lldb/source/Breakpoint/BreakpointLocationList.cpp lldb/source/Breakpoint/BreakpointResolverScripted.cpp lldb/source/Breakpoint/BreakpointSite.cpp lldb/source/Interpreter/ScriptInterpreter.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h lldb/source/Target/StopInfo.cpp lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h
index 3bf87a1b7..fe19ba998 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -157,12 +157,11 @@ public:
   /// Can only be called from a ScriptedBreakpointResolver...
   SBError
   AddLocation(SBAddress &address);
-  /// Add a "Facade location" to the breakpoint.  This returns the Facade 
-  /// Location that was added, which you can then use in 
+  /// Add a "Facade location" to the breakpoint.  This returns the Facade
+  /// Location that was added, which you can then use in
   /// get_location_description and was_hit in your breakpoint resolver.
   /// Can only be called from a ScriptedBreakpointResolver.
-  SBBreakpointLocation
-  AddFacadeLocation();
+  SBBreakpointLocation AddFacadeLocation();
 
   SBStructuredData SerializeToStructuredData();
 
diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h
index deda4970c..9b0d4839a 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -25,6 +25,7 @@ namespace lldb {
 
 class LLDB_API SBBreakpointLocation {
   friend class lldb_private::ScriptInterpreter;
+
 public:
   SBBreakpointLocation();
 
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 4abb44b4b..92917e57f 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -225,7 +225,7 @@ protected:
   friend class SBInstruction;
   friend class SBThread;
   friend class SBValue;
-  
+
   friend class lldb_private::ScriptInterpreter;
   friend class lldb_private::python::SWIGBridge;
   friend class lldb_private::lua::SWIGBridge;
diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 2bef6a919..bcb5d0ea7 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -248,8 +248,8 @@ public:
   ///    Returns a pointer to the new location.
   lldb::BreakpointLocationSP AddLocation(const Address &addr,
                                          bool *new_location = nullptr);
-  /// Add a `facade` location to the breakpoint's collection of facade locations.  
-  /// This is only meant to be called by the breakpoint's resolver.
+  /// Add a `facade` location to the breakpoint's collection of facade
+  /// locations. This is only meant to be called by the breakpoint's resolver.
   /// Facade locations are placeholders that a scripted breakpoint can use to
   /// represent the stop locations provided by the breakpoint.  The scripted
   /// breakpoint should record the id of the facade location, and provide
@@ -263,7 +263,7 @@ public:
   /// \return
   ///    Returns a pointer to the new location.
   lldb::BreakpointLocationSP AddFacadeLocation();
-  
+
   lldb::BreakpointLocationSP GetFacadeLocationByID(lldb::break_id_t);
 
   /// Find a breakpoint location by Address.
@@ -293,14 +293,15 @@ public:
   ///    The ID specifying the location.
   ///
   /// \param[in] use_facade
-  /// If \b true, then prefer facade locations over "real" ones if they exist.  
+  /// If \b true, then prefer facade locations over "real" ones if they exist.
   ///
   /// \return
   ///    Returns a shared pointer to the location with ID \a bp_loc_id.  The
   ///    pointer
   ///    in the shared pointer will be nullptr if there is no location with that
   ///    ID.
-  lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id, bool use_facade = true);
+  lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id,
+                                              bool use_facade = true);
 
   /// Get breakpoint locations by index.
   ///
@@ -308,13 +309,14 @@ public:
   ///    The location index.
   ///
   /// \param[in] use_facade
-  /// If \b true, then prefer facade locations over "real" ones if they exist.  
+  /// If \b true, then prefer facade locations over "real" ones if they exist.
   ///
   /// \return
   ///     Returns a shared pointer to the location with index \a
   ///     index. The shared pointer might contain nullptr if \a index is
   ///     greater than then number of actual locations.
-  lldb::BreakpointLocationSP GetLocationAtIndex(size_t index, bool use_facade = true);
+  lldb::BreakpointLocationSP GetLocationAtIndex(size_t index,
+                                                bool use_facade = true);
 
   /// Removes all invalid breakpoint locations.
   ///
@@ -436,7 +438,7 @@ public:
   /// breakpoint sites.
   ///
   /// \param[in] use_facade
-  /// If \b true, then prefer facade locations over "real" ones if they exist.  
+  /// If \b true, then prefer facade locations over "real" ones if they exist.
   ///
   /// \return
   ///     The number locations resolved breakpoint sites.
@@ -451,7 +453,7 @@ public:
   /// Return the number of breakpoint locations.
   ///
   /// \param[in] use_facade
-  /// If \b true, then prefer facade locations over "real" ones if they exist.  
+  /// If \b true, then prefer facade locations over "real" ones if they exist.
   ///
   /// \return
   ///     The number breakpoint locations.
@@ -563,17 +565,14 @@ private:
 
   enum TypeDisplay {
     eDisplayFacade = 1,
-    eDisplayReal   = 1 << 1,
+    eDisplayReal = 1 << 1,
     eDisplayHeader = 1 << 2
   };
 
   void GetDescriptionForType(Stream *s, lldb::DescriptionLevel level,
-                      uint8_t display_type, bool show_locations);
-                      
-  bool HasFacadeLocations() {
-    return m_facade_locations.GetSize() != 0;
-  }
+                             uint8_t display_type, bool show_locations);
 
+  bool HasFacadeLocations() { return m_facade_locations.GetSize() != 0; }
 
 public:
   bool MatchesName(const char *name) {
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index c4fa9bec5..6557a23a4 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -62,17 +62,17 @@ public:
   Target &GetTarget();
 
   /// This is a programmatic version of a breakpoint "condition".  When a
-  /// breakpoint is hit, WasHit will get called before the synchronous ShouldStop
-  /// callback is run, and if it returns an empty BreakpointLocationSP, lldb will
-  /// act as if that breakpoint wasn't hit.
+  /// breakpoint is hit, WasHit will get called before the synchronous
+  /// ShouldStop callback is run, and if it returns an empty
+  /// BreakpointLocationSP, lldb will act as if that breakpoint wasn't hit.
   ///
   /// \param[in] context
   ///   The context at the stop point
-  ///    
+  ///
   /// \return
   ///    This will return the breakpoint location that was hit on this stop.
   ///    If there was no facade location this will be the original location.
-  ///    If the shared pointer is empty, then we'll treat it as if the 
+  ///    If the shared pointer is empty, then we'll treat it as if the
   ///    breakpoint was not hit.
   lldb::BreakpointLocationSP WasHit(StoppointCallbackContext *context);
 
@@ -84,16 +84,16 @@ public:
   ///
   /// \param[in] context
   ///   The context at the stop point
-  ///    
+  ///
   /// \param[out] facade_loc_sp
   ///   If this stop should be attributed not to the location that was hit, but
   ///   to a facade location, it will be returned in this facade_loc_sp.
-  ///    
+  ///
   /// \return
   ///     \b true if this breakpoint location thinks we should stop,
   ///     \b false otherwise.
-  bool ShouldStop(StoppointCallbackContext *context, 
-          lldb::BreakpointLocationSP &facade_loc_sp);
+  bool ShouldStop(StoppointCallbackContext *context,
+                  lldb::BreakpointLocationSP &facade_loc_sp);
 
   // The next section deals with various breakpoint options.
 
@@ -373,7 +373,7 @@ private:
   /// Constructor.
   ///
   /// \param[in] loc_id
-  ///     The location id of the new location. 
+  ///     The location id of the new location.
   ///
   /// \param[in] owner
   ///     A back pointer to the breakpoint that owns this location.
@@ -390,10 +390,10 @@ private:
                      bool check_for_resolver = true);
 
   /// This is the constructor for locations with no address.  Currently this is
-  /// just used for Facade locations. 
+  /// just used for Facade locations.
   ///
   /// \param[in] loc_id
-  ///     The location id of the new location. 
+  ///     The location id of the new location.
   ///
   /// \param[in] owner
   ///     A back pointer to the breakpoint that owns this location.
@@ -403,6 +403,7 @@ public:
   BreakpointLocation(lldb::break_id_t loc_id, Breakpoint &owner);
   bool IsValid() const { return m_is_valid; }
   bool IsFacade() const { return m_is_facade; }
+
 private:
   // Data members:
   bool m_should_resolve_indirect_functions;
@@ -431,10 +432,10 @@ private:
   /// location was given somewhere in the virtual inlined call stack since the
   /// Address always resolves to the lowest entry in the stack.
   std::optional<LineEntry> m_preferred_line_entry;
-  bool m_is_valid = true;  /// Because Facade locations don't have sites
-                           /// we can't use the presence of the site to mean
-                           /// this breakpoint is valid, but must manage
-                           /// the state directly.
+  bool m_is_valid = true;   /// Because Facade locations don't have sites
+                            /// we can't use the presence of the site to mean
+                            /// this breakpoint is valid, but must manage
+                            /// the state directly.
   bool m_is_facade = false; /// Facade locations aren't directly triggered
                             /// and don't have a breakpoint site.  They are
                             /// a useful fiction when you want to represent
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
index 8ef13d304..1df4e0746 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
@@ -111,7 +111,8 @@ public:
   ///
   /// \return
   ///    \b true if we should stop, \b false otherwise.
-  bool ShouldStop(StoppointCallbackContext *context, BreakpointLocationCollection &stopped_bp_locs);
+  bool ShouldStop(StoppointCallbackContext *context,
+                  BreakpointLocationCollection &stopped_bp_locs);
 
   /// Print a description of the breakpoint locations in this list
   /// to the stream \a s.
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
index 8c8309b73..952db559d 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
@@ -140,8 +140,8 @@ public:
   ///
   /// \return
   ///     \b true if we should stop, \b false otherwise.
-  bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID, 
-      lldb::BreakpointLocationSP &bp_loc_sp);
+  bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID,
+                  lldb::BreakpointLocationSP &bp_loc_sp);
 
   /// Returns the number of elements in this breakpoint location list.
   ///
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
index 7e747ab0b..c3c1c80f4 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
@@ -45,11 +45,12 @@ public:
 
   void GetDescription(Stream *s) override;
 
-  lldb::BreakpointLocationSP WasHit(lldb::StackFrameSP frame_sp, 
+  lldb::BreakpointLocationSP WasHit(lldb::StackFrameSP frame_sp,
                                     lldb::BreakpointLocationSP bp_loc_sp);
-  
-  std::optional<std::string> GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp,
-      lldb::DescriptionLevel level);
+
+  std::optional<std::string>
+  GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp,
+                         lldb::DescriptionLevel level);
 
   void Dump(Stream *s) const override;
 
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 75b5ed9f4..a935b2441 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -99,8 +99,8 @@ public:
   ///
   /// \return
   ///    \b true if we should stop, \b false otherwise.
-  bool ShouldStop(StoppointCallbackContext *context, 
-          BreakpointLocationCollection &stopping_bp_loc) override;
+  bool ShouldStop(StoppointCallbackContext *context,
+                  BreakpointLocationCollection &stopping_bp_loc) override;
 
   /// Standard Dump method
   void Dump(Stream *s) const override;
diff --git a/lldb/include/lldb/Breakpoint/StoppointSite.h b/lldb/include/lldb/Breakpoint/StoppointSite.h
index a398aa838..2ceac4039 100644
--- a/lldb/include/lldb/Breakpoint/StoppointSite.h
+++ b/lldb/include/lldb/Breakpoint/StoppointSite.h
@@ -38,10 +38,12 @@ public:
 
   virtual bool IsHardware() const = 0;
 
-  virtual bool ShouldStop(StoppointCallbackContext* context) { return false; };
+  virtual bool ShouldStop(StoppointCallbackContext *context) { return false; };
 
-  virtual bool ShouldStop(StoppointCallbackContext* context,
-          BreakpointLocationCollection &stopping_bp_locs) { return false; };
+  virtual bool ShouldStop(StoppointCallbackContext *context,
+                          BreakpointLocationCollection &stopping_bp_locs) {
+    return false;
+  };
 
   virtual void Dump(Stream* stream) const = 0;
 
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h
index c203e7f15..d29fd8126 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedBreakpointInterface.h
@@ -27,14 +27,14 @@ public:
   virtual lldb::SearchDepth GetDepth() { return lldb::eSearchDepthModule; }
   virtual std::optional<std::string> GetShortHelp() { return nullptr; }
   /// WasHit returns the breakpoint location SP for the location that was "hit".
-  virtual lldb::BreakpointLocationSP WasHit(lldb::StackFrameSP frame_sp, 
-                          lldb::BreakpointLocationSP bp_loc_sp) { 
-      return LLDB_INVALID_BREAK_ID;
+  virtual lldb::BreakpointLocationSP
+  WasHit(lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp) {
+    return LLDB_INVALID_BREAK_ID;
   }
-  virtual std::optional<std::string> 
-      GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp, 
-                             lldb::DescriptionLevel level) { 
-      return {};
+  virtual std::optional<std::string>
+  GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp,
+                         lldb::DescriptionLevel level) {
+    return {};
   }
 };
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 554f81283..6c0054a1e 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -581,8 +581,8 @@ public:
   lldb::BreakpointSP
   GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const;
 
-  lldb::BreakpointLocationSP
-  GetOpaqueTypeFromSBBreakpointLocation(const lldb::SBBreakpointLocation &break_loc) const;
+  lldb::BreakpointLocationSP GetOpaqueTypeFromSBBreakpointLocation(
+      const lldb::SBBreakpointLocation &break_loc) const;
 
   lldb::ProcessAttachInfoSP
   GetOpaqueTypeFromSBAttachInfo(const lldb::SBAttachInfo &attach_info) const;
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 93748dd46..3777cfc7a 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -567,8 +567,7 @@ SBError SBBreakpoint::AddLocation(SBAddress &address) {
   return error;
 }
 
-SBBreakpointLocation
-SBBreakpoint::AddFacadeLocation() {
+SBBreakpointLocation SBBreakpoint::AddFacadeLocation() {
   BreakpointSP bkpt_sp = GetSP();
   if (!bkpt_sp) {
     return {};
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index d6d2f8aa1..b665bfc4c 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -61,7 +61,8 @@ Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
 Breakpoint::~Breakpoint() {
   for (BreakpointLocationSP location_sp : m_locations.BreakpointLocations())
     location_sp->SetInvalid();
-  for (BreakpointLocationSP location_sp : m_facade_locations.BreakpointLocations())
+  for (BreakpointLocationSP location_sp :
+       m_facade_locations.BreakpointLocations())
     location_sp->SetInvalid();
 }
 
@@ -309,14 +310,15 @@ BreakpointLocationSP Breakpoint::AddLocation(const Address &addr,
 
 BreakpointLocationSP Breakpoint::AddFacadeLocation() {
   size_t next_id = m_facade_locations.GetSize() + 1;
-  BreakpointLocationSP break_loc_sp 
-      = std::make_shared<BreakpointLocation>(next_id, *this);
+  BreakpointLocationSP break_loc_sp =
+      std::make_shared<BreakpointLocation>(next_id, *this);
   break_loc_sp->m_is_facade = true;
   m_facade_locations.Add(break_loc_sp);
   return break_loc_sp;
 }
 
-BreakpointLocationSP Breakpoint::GetFacadeLocationByID(lldb::break_id_t loc_id) {
+BreakpointLocationSP
+Breakpoint::GetFacadeLocationByID(lldb::break_id_t loc_id) {
   return m_facade_locations.GetByIndex(loc_id - 1);
 }
 
@@ -328,13 +330,15 @@ break_id_t Breakpoint::FindLocationIDByAddress(const Address &addr) {
   return m_locations.FindIDByAddress(addr);
 }
 
-BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id, bool use_facade) {
+BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id,
+                                                  bool use_facade) {
   if (use_facade && m_facade_locations.GetSize())
     return GetFacadeLocationByID(bp_loc_id);
   return m_locations.FindByID(bp_loc_id);
 }
 
-BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index, bool use_facade) {
+BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index,
+                                                    bool use_facade) {
   if (use_facade && m_facade_locations.GetSize() > 0)
     return m_facade_locations.GetByIndex(index);
   return m_locations.GetByIndex(index);
@@ -904,13 +908,13 @@ bool Breakpoint::HasResolvedLocations() const {
   return GetNumResolvedLocations() > 0;
 }
 
-size_t Breakpoint::GetNumLocations(bool use_facade) const { 
+size_t Breakpoint::GetNumLocations(bool use_facade) const {
   if (use_facade) {
     size_t num_facade_locs = m_facade_locations.GetSize();
     if (num_facade_locs > 0)
       return num_facade_locs;
   }
-  return m_locations.GetSize(); 
+  return m_locations.GetSize();
 }
 
 void Breakpoint::AddName(llvm::StringRef new_name) {
@@ -936,14 +940,14 @@ void Breakpoint::GetDescription(Stream *s, lldb::DescriptionLevel level,
     s->Printf("Kind: %s\n", GetBreakpointKind());
   }
 
-  bool show_both_types = level == eDescriptionLevelVerbose 
-    && HasFacadeLocations() && show_locations;
+  bool show_both_types = level == eDescriptionLevelVerbose &&
+                         HasFacadeLocations() && show_locations;
   uint8_t display_mask = eDisplayFacade;
   if (show_both_types)
     display_mask |= eDisplayHeader;
-    
+
   GetDescriptionForType(s, level, display_mask, show_locations);
-  
+
   if (show_both_types) {
     display_mask = eDisplayReal | eDisplayHeader;
     GetDescriptionForType(s, level, display_mask, show_locations);
@@ -954,9 +958,10 @@ void Breakpoint::GetDescription(Stream *s, lldb::DescriptionLevel level,
                         GetTarget().GetDebugger().GetDisabledAnsiSuffix())
                         .c_str());
 }
-  
+
 void Breakpoint::GetDescriptionForType(Stream *s, lldb::DescriptionLevel level,
-                                       uint8_t display_type, bool show_locations) {
+                                       uint8_t display_type,
+                                       bool show_locations) {
   bool use_facade = (display_type & eDisplayFacade) != 0;
   const size_t num_locations = GetNumLocations(use_facade);
   const size_t num_resolved_locations = GetNumResolvedLocations(use_facade);
@@ -1052,7 +1057,6 @@ void Breakpoint::GetDescriptionForType(Stream *s, lldb::DescriptionLevel level,
     }
     s->IndentLess();
   }
-
 }
 
 void Breakpoint::GetResolverDescription(Stream *s) {
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 829ed0339..2505fb26e 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -381,11 +381,12 @@ bool BreakpointLocation::ValidForThisThread(Thread &thread) {
           .GetThreadSpecNoCreate());
 }
 
-BreakpointLocationSP BreakpointLocation::WasHit(StoppointCallbackContext *context)
-{
+BreakpointLocationSP
+BreakpointLocation::WasHit(StoppointCallbackContext *context) {
   // Only the BreakpointResolverScripted provides WasHit.
   BreakpointResolverSP resolver_sp = GetBreakpoint().GetResolver();
-  BreakpointResolverScripted *scripted = llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
+  BreakpointResolverScripted *scripted =
+      llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
   if (!scripted)
     return shared_from_this();
 
@@ -393,7 +394,8 @@ BreakpointLocationSP BreakpointLocation::WasHit(StoppointCallbackContext *contex
   if (!frame_sp)
     return shared_from_this();
 
-  BreakpointLocationSP return_loc_sp = scripted->WasHit(frame_sp, shared_from_this());
+  BreakpointLocationSP return_loc_sp =
+      scripted->WasHit(frame_sp, shared_from_this());
   // If this is a facade location, then we won't have bumped its hit count
   // while processing the original location hit.  Do so here.  We don't need
   // to bump the breakpoint's hit count, however, since hitting the real
@@ -401,10 +403,10 @@ BreakpointLocationSP BreakpointLocation::WasHit(StoppointCallbackContext *contex
   // Also we have to check the enabled state here, since we would never have
   // gotten here with a real location...
   if (return_loc_sp && return_loc_sp->IsFacade()) {
-     if (return_loc_sp->IsEnabled())
-       return_loc_sp->m_hit_counter.Increment();
-     else
-       return {};
+    if (return_loc_sp->IsEnabled())
+      return_loc_sp->m_hit_counter.Increment();
+    else
+      return {};
   }
   return return_loc_sp;
 }
@@ -414,8 +416,8 @@ BreakpointLocationSP BreakpointLocation::WasHit(StoppointCallbackContext *contex
 // here, since if the breakpoint is not for this thread, then the event won't
 // even get reported, so the check is redundant.
 
-bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context, 
-        lldb::BreakpointLocationSP &facade_loc_sp) {
+bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context,
+                                    lldb::BreakpointLocationSP &facade_loc_sp) {
   bool should_stop = true;
   Log *log = GetLog(LLDBLog::Breakpoints);
 
@@ -426,7 +428,7 @@ bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context,
 
   // Next check WasHit:
   BreakpointLocationSP loc_hit_sp = WasHit(context);
-  
+
   if (!loc_hit_sp) {
     // We bump the hit counts in StopInfoBreakpoint::ShouldStopSynchronous,
     // before we call into each location's ShouldStop.  So we need to undo
@@ -434,7 +436,7 @@ bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context,
     UndoBumpHitCount();
     return false;
   }
-  
+
   // If the location hit was not us, it was a facade location, in which case
   // we should use the facade location's callbacks, etc.  Those will all be
   // run in the asynchronous phase, so for now we just have to record the fact
@@ -494,7 +496,7 @@ lldb::BreakpointSiteSP BreakpointLocation::GetBreakpointSite() const {
 llvm::Error BreakpointLocation::ResolveBreakpointSite() {
   // This might be a facade location, which doesn't have an address.
   // In that case, don't attempt to make a site.
-  if (m_bp_site_sp  || IsFacade())
+  if (m_bp_site_sp || IsFacade())
     return llvm::Error::success();
 
   Process *process = m_owner.GetTarget().GetProcessSP().get();
@@ -547,15 +549,15 @@ llvm::Error BreakpointLocation::ClearBreakpointSite() {
 void BreakpointLocation::GetDescription(Stream *s,
                                         lldb::DescriptionLevel level) {
   SymbolContext sc;
-  
+
   // If this is a scripted breakpoint, give it a chance to describe its
   // locations:
   std::optional<std::string> scripted_opt;
   BreakpointResolverSP resolver_sp = GetBreakpoint().GetResolver();
-  BreakpointResolverScripted *scripted = 
+  BreakpointResolverScripted *scripted =
       llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
   if (scripted)
-        scripted_opt = scripted->GetLocationDescription(shared_from_this(), level);
+    scripted_opt = scripted->GetLocationDescription(shared_from_this(), level);
 
   bool is_scripted_desc = scripted_opt.has_value();
 
@@ -694,10 +696,10 @@ void BreakpointLocation::GetDescription(Stream *s,
   // If they don't add any scripted locations, we shouldn't consider them
   // resolved.
   bool is_resolved = is_scripted_desc || IsResolved();
-  // A scripted breakpoint might be resolved but not have a site.  Be sure to 
+  // A scripted breakpoint might be resolved but not have a site.  Be sure to
   // check for that.
-  bool is_hardware = !is_scripted_desc && IsResolved() && m_bp_site_sp 
-      && m_bp_site_sp->IsHardware();
+  bool is_hardware = !is_scripted_desc && IsResolved() && m_bp_site_sp &&
+                     m_bp_site_sp->IsHardware();
 
   if (level == lldb::eDescriptionLevelVerbose) {
     s->EOL();
diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp
index 5a791d436..ea431aa3b 100644
--- a/lldb/source/Breakpoint/BreakpointLocationList.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp
@@ -32,9 +32,9 @@ BreakpointLocationList::Create(const Address &addr,
   std::lock_guard<std::recursive_mutex> guard(m_mutex);
   // The location ID is just the size of the location list + 1
   lldb::break_id_t bp_loc_id = ++m_next_id;
-  BreakpointLocationSP bp_loc_sp(new 
-      BreakpointLocation(bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, 
-      resolve_indirect_symbols));
+  BreakpointLocationSP bp_loc_sp(
+      new BreakpointLocation(bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID,
+                             resolve_indirect_symbols));
   m_locations.push_back(bp_loc_sp);
   m_address_to_location[addr] = bp_loc_sp;
   return bp_loc_sp;
diff --git a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
index b1e45d761..a4969a07b 100644
--- a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -160,17 +160,17 @@ void BreakpointResolverScripted::GetDescription(Stream *s) {
     s->Printf("python class = %s", m_class_name.c_str());
 }
 
-std::optional<std::string> 
-BreakpointResolverScripted::GetLocationDescription(
+std::optional<std::string> BreakpointResolverScripted::GetLocationDescription(
     lldb::BreakpointLocationSP bp_loc_sp, lldb::DescriptionLevel level) {
   CreateImplementationIfNeeded(GetBreakpoint());
-  if (m_interface_sp) 
+  if (m_interface_sp)
     return m_interface_sp->GetLocationDescription(bp_loc_sp, level);
   return {};
 }
 
 lldb::BreakpointLocationSP
-BreakpointResolverScripted::WasHit(lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp) {
+BreakpointResolverScripted::WasHit(lldb::StackFrameSP frame_sp,
+                                   lldb::BreakpointLocationSP bp_loc_sp) {
   if (m_interface_sp)
     return m_interface_sp->WasHit(frame_sp, bp_loc_sp);
 
diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp
index 52100b91d..fd7666be6 100644
--- a/lldb/source/Breakpoint/BreakpointSite.cpp
+++ b/lldb/source/Breakpoint/BreakpointSite.cpp
@@ -45,8 +45,9 @@ break_id_t BreakpointSite::GetNextID() {
 // RETURNS - true if we should stop at this breakpoint, false if we
 // should continue.
 
-bool BreakpointSite::ShouldStop(StoppointCallbackContext *context,
-        BreakpointLocationCollection &stopping_bp_locs) {
+bool BreakpointSite::ShouldStop(
+    StoppointCallbackContext *context,
+    BreakpointLocationCollection &stopping_bp_locs) {
   m_hit_counter.Increment();
   // ShouldStop can do a lot of work, and might even come back and hit
   // this breakpoint site again.  So don't hold the m_constituents_mutex the
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 51475db27..b5ad85d26 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -81,7 +81,8 @@ lldb::BreakpointSP ScriptInterpreter::GetOpaqueTypeFromSBBreakpoint(
   return breakpoint.m_opaque_wp.lock();
 }
 
-lldb::BreakpointLocationSP ScriptInterpreter::GetOpaqueTypeFromSBBreakpointLocation(
+lldb::BreakpointLocationSP
+ScriptInterpreter::GetOpaqueTypeFromSBBreakpointLocation(
     const lldb::SBBreakpointLocation &break_loc) const {
   return break_loc.m_opaque_wp.lock();
 }
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp
index 0c6d23b10..c9bb38d21 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp
@@ -81,11 +81,11 @@ std::optional<std::string> ScriptedBreakpointPythonInterface::GetShortHelp() {
   return obj->GetAsString()->GetValue().str();
 }
 
-lldb::BreakpointLocationSP
-ScriptedBreakpointPythonInterface::WasHit(lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp) {
+lldb::BreakpointLocationSP ScriptedBreakpointPythonInterface::WasHit(
+    lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp) {
   Status py_error;
-  lldb::BreakpointLocationSP loc_sp 
-    = Dispatch<lldb::BreakpointLocationSP>("was_hit", py_error, frame_sp, bp_loc_sp);
+  lldb::BreakpointLocationSP loc_sp = Dispatch<lldb::BreakpointLocationSP>(
+      "was_hit", py_error, frame_sp, bp_loc_sp);
 
   if (py_error.Fail())
     return bp_loc_sp;
@@ -93,12 +93,12 @@ ScriptedBreakpointPythonInterface::WasHit(lldb::StackFrameSP frame_sp, lldb::Bre
   return loc_sp;
 }
 
-std::optional<std::string> 
+std::optional<std::string>
 ScriptedBreakpointPythonInterface::GetLocationDescription(
-    lldb::BreakpointLocationSP bp_loc_sp, 
-    lldb::DescriptionLevel level) {
+    lldb::BreakpointLocationSP bp_loc_sp, lldb::DescriptionLevel level) {
   Status error;
-  StructuredData::ObjectSP obj = Dispatch("get_location_description", error, bp_loc_sp, level);
+  StructuredData::ObjectSP obj =
+      Dispatch("get_location_description", error, bp_loc_sp, level);
 
   if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
                                                     error))
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h
index b8c121927..72da0a195 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.h
@@ -36,12 +36,12 @@ public:
   bool ResolverCallback(SymbolContext sym_ctx) override;
   lldb::SearchDepth GetDepth() override;
   std::optional<std::string> GetShortHelp() override;
-  lldb::BreakpointLocationSP WasHit(lldb::StackFrameSP frame_sp, 
-                  lldb::BreakpointLocationSP bp_loc_sp) override;
-  virtual std::optional<std::string> 
-      GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp, 
-                             lldb::DescriptionLevel level) override;
-
+  lldb::BreakpointLocationSP
+  WasHit(lldb::StackFrameSP frame_sp,
+         lldb::BreakpointLocationSP bp_loc_sp) override;
+  virtual std::optional<std::string>
+  GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp,
+                         lldb::DescriptionLevel level) override;
 
   static void Initialize();
 
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
index cda8185ef..4fdf2b12a 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
@@ -141,14 +141,16 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
 
 template <>
 lldb::BreakpointLocationSP
-ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointLocationSP>(
-    python::PythonObject &p, Status &error) {
-  lldb::SBBreakpointLocation *sb_break_loc = reinterpret_cast<lldb::SBBreakpointLocation *>(
-      python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get()));
+ScriptedPythonInterface::ExtractValueFromPythonObject<
+    lldb::BreakpointLocationSP>(python::PythonObject &p, Status &error) {
+  lldb::SBBreakpointLocation *sb_break_loc =
+      reinterpret_cast<lldb::SBBreakpointLocation *>(
+          python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get()));
 
   if (!sb_break_loc) {
     error = Status::FromErrorStringWithFormat(
-        "Couldn't cast lldb::SBBreakpointLocation to lldb::BreakpointLocationSP.");
+        "Couldn't cast lldb::SBBreakpointLocation to "
+        "lldb::BreakpointLocationSP.");
     return nullptr;
   }
 
@@ -225,20 +227,20 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<
 
 template <>
 lldb::DescriptionLevel
-ScriptedPythonInterface::ExtractValueFromPythonObject<
-    lldb::DescriptionLevel>(python::PythonObject &p, Status &error) {
-    lldb::DescriptionLevel ret_val = lldb::eDescriptionLevelBrief;
-    llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong();
-    if (!unsigned_or_err) {
-      error = (Status::FromError(unsigned_or_err.takeError()));
-      return ret_val;
-    }
-    unsigned long long unsigned_val = *unsigned_or_err;
-    if (unsigned_val >= lldb::DescriptionLevel::kNumDescriptionLevels) {
-      error = Status("value too large for lldb::DescriptionLevel.");
-      return ret_val;
-    }
-    return static_cast<lldb::DescriptionLevel>(unsigned_val);
+ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>(
+    python::PythonObject &p, Status &error) {
+  lldb::DescriptionLevel ret_val = lldb::eDescriptionLevelBrief;
+  llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong();
+  if (!unsigned_or_err) {
+    error = (Status::FromError(unsigned_or_err.takeError()));
+    return ret_val;
+  }
+  unsigned long long unsigned_val = *unsigned_or_err;
+  if (unsigned_val >= lldb::DescriptionLevel::kNumDescriptionLevels) {
+    error = Status("value too large for lldb::DescriptionLevel.");
+    return ret_val;
+  }
+  return static_cast<lldb::DescriptionLevel>(unsigned_val);
 }
 
 #endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 57d22d44e..2335b2ef0 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -597,8 +597,8 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
 
 template <>
 lldb::BreakpointLocationSP
-ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointLocationSP>(
-    python::PythonObject &p, Status &error);
+ScriptedPythonInterface::ExtractValueFromPythonObject<
+    lldb::BreakpointLocationSP>(python::PythonObject &p, Status &error);
 
 template <>
 lldb::ProcessAttachInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject<
@@ -625,8 +625,8 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<
 
 template <>
 lldb::DescriptionLevel
-ScriptedPythonInterface::ExtractValueFromPythonObject<
-    lldb::DescriptionLevel>(python::PythonObject &p, Status &error);
+ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>(
+    python::PythonObject &p, Status &error);
 
 } // namespace lldb_private
 
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index b864159ba..7fa1fc5d7 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -157,7 +157,8 @@ public:
           ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
           StoppointCallbackContext context(event_ptr, exe_ctx, true);
           bp_site_sp->BumpHitCounts();
-          m_should_stop = bp_site_sp->ShouldStop(&context, m_async_stopped_locs);
+          m_should_stop =
+              bp_site_sp->ShouldStop(&context, m_async_stopped_locs);
         } else {
           Log *log = GetLog(LLDBLog::Process);
 
@@ -345,8 +346,7 @@ protected:
         // local list.  That way if one of the breakpoint actions changes the
         // site, then we won't be operating on a bad list.
         BreakpointLocationCollection site_locations;
-        size_t num_constituents =
-            m_async_stopped_locs.GetSize();
+        size_t num_constituents = m_async_stopped_locs.GetSize();
 
         if (num_constituents == 0) {
           m_should_stop = true;
@@ -445,7 +445,7 @@ protected:
           // breakpoints, and the locations don't keep their constituents alive.
           // I'm just sticking the BreakpointSP's in a vector since I'm only
           // using it to locally increment their retain counts.
-          
+
           // We are holding onto the breakpoint locations that were hit
           // by this stop info between the "synchonous" ShouldStop and now.
           // But an intervening action might have deleted one of the breakpoints
@@ -465,8 +465,7 @@ protected:
 
           size_t num_valid_locs = valid_locs.GetSize();
           for (size_t j = 0; j < num_valid_locs; j++) {
-            lldb::BreakpointLocationSP bp_loc_sp 
-                = valid_locs.GetByIndex(j);
+            lldb::BreakpointLocationSP bp_loc_sp = valid_locs.GetByIndex(j);
             StreamString loc_desc;
             if (log) {
               bp_loc_sp->GetDescription(&loc_desc, eDescriptionLevelBrief);
diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c
index 762553109..b8f977e49 100644
--- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c
+++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/was_hit/main.c
@@ -1,15 +1,12 @@
 #include <stdio.h>
 
-int
-stop_symbol() {
+int stop_symbol() {
   static int s_cnt = 0;
   printf("I am in the stop symbol: %d\n", s_cnt++);
   return s_cnt;
 }
 
-int
-main()
-{
+int main() {
   for (int i = 0; i < 100; i++) {
     stop_symbol();
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/158128


More information about the lldb-commits mailing list