[Lldb-commits] [lldb] r109289 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ source/API/ source/Breakpoint/ source/Commands/ source/Target/

Greg Clayton gclayton at apple.com
Fri Jul 23 16:33:18 PDT 2010


Author: gclayton
Date: Fri Jul 23 18:33:17 2010
New Revision: 109289

URL: http://llvm.org/viewvc/llvm-project?rev=109289&view=rev
Log:
Added needed breakpoint functionality to the public API that includes:
  SBTarget:
    - get breakpoint count
    - get breakpoint at index
  SBBreakpoint:
    - Extract data from breakpoint events


Modified:
    lldb/trunk/include/lldb/API/SBBreakpoint.h
    lldb/trunk/include/lldb/API/SBEvent.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
    lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/API/SBBreakpoint.cpp
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointIDList.cpp
    lldb/trunk/source/Breakpoint/BreakpointList.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Fri Jul 23 18:33:17 2010
@@ -68,6 +68,9 @@
     bool
     IsEnabled ();
 
+    uint32_t
+    GetHitCount () const;
+
     void
     SetIgnoreCount (uint32_t count);
 
@@ -110,7 +113,14 @@
     void
     GetDescription (FILE *, const char *description_level, bool describe_locations = false);
 
+    static lldb::BreakpointEventType
+    GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
 
+    static lldb::SBBreakpoint
+    GetBreakpointFromEvent (const lldb::SBEvent& event);
+    
+    static lldb::SBBreakpointLocation
+    GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
 
 private:
     friend class SBBreakpointLocation;

Modified: lldb/trunk/include/lldb/API/SBEvent.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBEvent.h (original)
+++ lldb/trunk/include/lldb/API/SBEvent.h Fri Jul 23 18:33:17 2010
@@ -59,6 +59,7 @@
 protected:
     friend class SBListener;
     friend class SBBroadcaster;
+    friend class SBBreakpoint;
     friend class SBDebugger;
     friend class SBProcess;
 

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Fri Jul 23 18:33:17 2010
@@ -97,12 +97,15 @@
     lldb::SBBreakpoint
     BreakpointCreateByAddress (addr_t address);
 
+    uint32_t
+    GetNumBreakpoints () const;
+
+    lldb::SBBreakpoint
+    GetBreakpointAtIndex (uint32_t idx) const;
+
     bool
     BreakpointDelete (break_id_t break_id);
 
-    void
-    ListAllBreakpoints ();
-
     lldb::SBBreakpoint
     FindBreakpointByID (break_id_t break_id);
 

Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Fri Jul 23 18:33:17 2010
@@ -104,25 +104,14 @@
         virtual const ConstString &
         GetFlavor () const;
 
-
-        enum EventSubType
-        {
-            eBreakpointInvalidType = (1 << 0),
-            eBreakpointAdded = (1 << 1),
-            eBreakpointRemoved = (1 << 2),
-            eBreakpointLocationsAdded = (1 << 3),
-            eBreakpointLocationsRemoved = (1 << 4),
-            eBreakpointLocationResolved = (1 << 5)
-        };
-
-        BreakpointEventData (EventSubType sub_type,
+        BreakpointEventData (lldb::BreakpointEventType sub_type,
                              lldb::BreakpointSP &new_breakpoint_sp);
 
         virtual
         ~BreakpointEventData();
 
-        EventSubType
-        GetSubType () const;
+        lldb::BreakpointEventType
+        GetBreakpointEventType () const;
 
         lldb::BreakpointSP &
         GetBreakpoint ();
@@ -131,17 +120,20 @@
         virtual void
         Dump (Stream *s) const;
 
-        static BreakpointEventData *
-        GetEventDataFromEvent (const lldb::EventSP &event_sp);
-
-        static EventSubType
-        GetSubTypeFromEvent (const lldb::EventSP &event_sp);
+        static lldb::BreakpointEventType
+        GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp);
 
         static lldb::BreakpointSP
         GetBreakpointFromEvent (const lldb::EventSP &event_sp);
 
+        static lldb::BreakpointLocationSP
+        GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t loc_idx);
+
     private:
-        EventSubType m_sub_type;
+        static BreakpointEventData *
+        GetEventDataFromEvent (const lldb::EventSP &event_sp);
+
+        lldb::BreakpointEventType m_breakpoint_event;
         lldb::BreakpointSP m_new_breakpoint_sp;
         BreakpointLocationCollection m_locations;
 
@@ -324,7 +316,7 @@
     SetIgnoreCount (uint32_t count);
 
     //------------------------------------------------------------------
-    /// Return the current Ignore Count.
+    /// Return the current ignore count/
     /// @return
     ///     The number of breakpoint hits to be ignored.
     //------------------------------------------------------------------
@@ -332,6 +324,15 @@
     GetIgnoreCount () const;
 
     //------------------------------------------------------------------
+    /// Return the current hit count for all locations.
+    /// @return
+    ///     The current hit count for all locations.
+    //------------------------------------------------------------------
+    uint32_t
+    GetHitCount () const;
+
+
+    //------------------------------------------------------------------
     /// Set the valid thread to be checked when the breakpoint is hit.
     /// @param[in] thread_id
     ///    If this thread hits the breakpoint, we stop, otherwise not.

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Fri Jul 23 18:33:17 2010
@@ -47,7 +47,7 @@
     ///   Returns breakpoint id.
     //------------------------------------------------------------------
     virtual lldb::break_id_t
-    Add (lldb::BreakpointSP& bp_sp);
+    Add (lldb::BreakpointSP& bp_sp, bool notify);
 
     //------------------------------------------------------------------
     /// Standard "Dump" method.  At present it does nothing.
@@ -92,7 +92,7 @@
     ///   breakpoint doesn't exist.
     //------------------------------------------------------------------
     lldb::BreakpointSP
-    GetBreakpointByIndex (uint32_t i);
+    GetBreakpointAtIndex (uint32_t i);
 
     //------------------------------------------------------------------
     /// Returns a shared pointer to the breakpoint with index \a i, const version
@@ -105,7 +105,7 @@
     ///   breakpoint doesn't exist.
     //------------------------------------------------------------------
     const lldb::BreakpointSP
-    GetBreakpointByIndex (uint32_t i) const;
+    GetBreakpointAtIndex (uint32_t i) const;
 
     //------------------------------------------------------------------
     /// Returns the number of elements in this breakpoint list.
@@ -126,7 +126,7 @@
     ///   \b true if the breakpoint \a breakID was in the list.
     //------------------------------------------------------------------
     bool
-    Remove (lldb::break_id_t breakID);
+    Remove (lldb::break_id_t breakID, bool notify);
 
     void
     SetEnabledAll (bool enabled);
@@ -135,7 +135,7 @@
     /// Removes all the breakpoints from this list.
     //------------------------------------------------------------------
     void
-    RemoveAll ();
+    RemoveAll (bool notify);
 
     //------------------------------------------------------------------
     /// Tell all the breakpoints to update themselves due to a change in the

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h Fri Jul 23 18:33:17 2010
@@ -173,6 +173,15 @@
     GetNumResolvedLocations() const;
 
     //------------------------------------------------------------------
+    /// Returns the number hit count of all locations in this list.
+    ///
+    /// @result
+    ///     Hit count of all locations in this list.
+    //------------------------------------------------------------------
+    uint32_t
+    GetHitCount () const;
+
+    //------------------------------------------------------------------
     /// Removes the breakpoint location given by \b breakID from this
     /// list.
     ///

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jul 23 18:33:17 2010
@@ -404,18 +404,30 @@
 
 typedef enum FunctionNameType 
 {
-    eFunctionNameTypeNone       = 0,
-    eFunctionNameTypeFull       = (1 << 1), // The function name.
+    eFunctionNameTypeNone       = 0u,
+    eFunctionNameTypeFull       = (1u << 1),// The function name.
                                             // For C this is the same as just the name of the function
                                             // For C++ this is the demangled version of the mangled name.
                                             // For ObjC this is the full function signature with the + or
                                             // - and the square brackets and the class and selector
-    eFunctionNameTypeBase       = (1 << 2), // The function name only, no namespaces or arguments and no class 
+    eFunctionNameTypeBase       = (1u << 2),// The function name only, no namespaces or arguments and no class 
                                             // methods or selectors will be searched.
-    eFunctionNameTypeMethod     = (1 << 3), // Find function by method name (C++) with no namespace or arguments
-    eFunctionNameTypeSelector   = (1 << 4)  // Find function by selector name (ObjC) names
+    eFunctionNameTypeMethod     = (1u << 3),// Find function by method name (C++) with no namespace or arguments
+    eFunctionNameTypeSelector   = (1u << 4) // Find function by selector name (ObjC) names
 } FunctionNameType;
 
+
+typedef enum BreakpointEventType
+{
+    eBreakpointEventTypeInvalidType         = (1u << 0),
+    eBreakpointEventTypeAdded               = (1u << 1),
+    eBreakpointEventTypeRemoved             = (1u << 2),
+    eBreakpointEventTypeLocationsAdded      = (1u << 3),
+    eBreakpointEventTypeLocationsRemoved    = (1u << 4),
+    eBreakpointEventTypeLocationsResolved   = (1u << 5)
+} BreakpointEventType;
+
+
 } // namespace lldb
 
 

Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Fri Jul 23 18:33:17 2010
@@ -10,6 +10,7 @@
 #include "lldb/API/SBBreakpoint.h"
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEvent.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBThread.h"
 
@@ -242,6 +243,15 @@
 }
 
 uint32_t
+SBBreakpoint::GetHitCount () const
+{
+    if (m_opaque_sp)
+        return m_opaque_sp->GetHitCount();
+    else
+        return 0;
+}
+
+uint32_t
 SBBreakpoint::GetIgnoreCount () const
 {
     if (m_opaque_sp)
@@ -457,3 +467,30 @@
     return m_opaque_sp;
 }
 
+BreakpointEventType
+SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event)
+{
+    if (event.IsValid())
+        return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP());
+    return eBreakpointEventTypeInvalidType;
+}
+
+SBBreakpoint
+SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event)
+{
+    SBBreakpoint sb_breakpoint;
+    if (event.IsValid())
+        sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP());
+    return sb_breakpoint;
+}
+
+SBBreakpointLocation
+SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx)
+{
+    SBBreakpointLocation sb_breakpoint_loc;
+    if (event.IsValid())
+        sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx));
+    return sb_breakpoint_loc;
+}
+
+

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Fri Jul 23 18:33:17 2010
@@ -277,36 +277,32 @@
     return sb_bp;
 }
 
-void
-SBTarget::ListAllBreakpoints ()
+SBBreakpoint
+SBTarget::FindBreakpointByID (break_id_t bp_id)
 {
-    FILE *out_file = m_opaque_sp->GetDebugger().GetOutputFileHandle();
-    
-    if (out_file == NULL)
-        return;
+    SBBreakpoint sb_breakpoint;
+    if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
+        *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
+    return sb_breakpoint;
+}
 
+uint32_t
+SBTarget::GetNumBreakpoints () const
+{
     if (m_opaque_sp)
-    {
-        const BreakpointList &bp_list = m_opaque_sp->GetBreakpointList();
-        size_t num_bps = bp_list.GetSize();
-        for (size_t i = 0; i < num_bps; ++i)
-        {
-            SBBreakpoint sb_breakpoint (bp_list.GetBreakpointByIndex (i));
-            sb_breakpoint.GetDescription (out_file, "full");
-        }
-    }
+        return m_opaque_sp->GetBreakpointList().GetSize();
+    return 0;
 }
 
 SBBreakpoint
-SBTarget::FindBreakpointByID (break_id_t bp_id)
+SBTarget::GetBreakpointAtIndex (uint32_t idx) const
 {
     SBBreakpoint sb_breakpoint;
-    if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
-        *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
+    if (m_opaque_sp)
+        *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
     return sb_breakpoint;
 }
 
-
 bool
 SBTarget::BreakpointDelete (break_id_t bp_id)
 {

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri Jul 23 18:33:17 2010
@@ -164,6 +164,12 @@
     return m_options.GetIgnoreCount();
 }
 
+uint32_t
+Breakpoint::GetHitCount () const
+{
+    return m_locations.GetHitCount();
+}
+
 void
 Breakpoint::SetThreadID (lldb::tid_t thread_id)
 {
@@ -405,10 +411,10 @@
     }
 }
 
-Breakpoint::BreakpointEventData::BreakpointEventData (Breakpoint::BreakpointEventData::EventSubType sub_type, 
+Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_type, 
                                                       BreakpointSP &new_breakpoint_sp) :
     EventData (),
-    m_sub_type (sub_type),
+    m_breakpoint_event (sub_type),
     m_new_breakpoint_sp (new_breakpoint_sp)
 {
 }
@@ -437,10 +443,10 @@
     return m_new_breakpoint_sp;
 }
 
-Breakpoint::BreakpointEventData::EventSubType
-Breakpoint::BreakpointEventData::GetSubType () const
+BreakpointEventType
+Breakpoint::BreakpointEventData::GetBreakpointEventType () const
 {
-    return m_sub_type;
+    return m_breakpoint_event;
 }
 
 void
@@ -460,29 +466,43 @@
     return NULL;
 }
 
-Breakpoint::BreakpointEventData::EventSubType
-Breakpoint::BreakpointEventData::GetSubTypeFromEvent (const EventSP &event_sp)
+BreakpointEventType
+Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP &event_sp)
 {
     BreakpointEventData *data = GetEventDataFromEvent (event_sp);
 
     if (data == NULL)
-        return eBreakpointInvalidType;
+        return eBreakpointEventTypeInvalidType;
     else
-        return data->GetSubType();
+        return data->GetBreakpointEventType();
 }
 
 BreakpointSP
 Breakpoint::BreakpointEventData::GetBreakpointFromEvent (const EventSP &event_sp)
 {
+    BreakpointSP bp_sp;
+
     BreakpointEventData *data = GetEventDataFromEvent (event_sp);
+    if (data)
+        bp_sp = data->GetBreakpoint();
 
-    if (data == NULL)
+    return bp_sp;
+}
+
+lldb::BreakpointLocationSP
+Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t bp_loc_idx)
+{
+    lldb::BreakpointLocationSP bp_loc_sp;
+
+    BreakpointEventData *data = GetEventDataFromEvent (event_sp);
+    if (data)
     {
-        BreakpointSP ret_val;
-        return ret_val;
+        Breakpoint *bp = data->GetBreakpoint().get();
+        if (bp)
+            bp_loc_sp = bp->GetLocationAtIndex(bp_loc_idx);
     }
-    else
-        return data->GetBreakpoint();
+
+    return bp_loc_sp;
 }
 
 

Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Fri Jul 23 18:33:17 2010
@@ -231,7 +231,7 @@
             const size_t num_breakpoints = breakpoints.GetSize();
             for (size_t j = 0; j < num_breakpoints; ++j)
             {
-                Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (j).get();
+                Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (j).get();
                 break_id_t cur_bp_id = breakpoint->GetID();
 
                 if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id))

Modified: lldb/trunk/source/Breakpoint/BreakpointList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointList.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointList.cpp Fri Jul 23 18:33:17 2010
@@ -13,6 +13,7 @@
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
+#include "lldb/Target/Target.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -31,23 +32,37 @@
 
 
 break_id_t
-BreakpointList::Add (BreakpointSP &bp)
+BreakpointList::Add (BreakpointSP &bp_sp, bool notify)
 {
     Mutex::Locker locker(m_mutex);
     // Internal breakpoint IDs are negative, normal ones are positive
-    bp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id);
-    m_breakpoints.push_back(bp);
-    return bp->GetID();
+    bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id);
+    
+    m_breakpoints.push_back(bp_sp);
+    if (notify)
+    {
+        if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+            bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
+                                               new Breakpoint::BreakpointEventData (eBreakpointEventTypeAdded, bp_sp));
+    }
+    return bp_sp->GetID();
 }
 
 bool
-BreakpointList::Remove (break_id_t break_id)
+BreakpointList::Remove (break_id_t break_id, bool notify)
 {
     Mutex::Locker locker(m_mutex);
     bp_collection::iterator pos = GetBreakpointIDIterator(break_id);    // Predicate
     if (pos != m_breakpoints.end())
     {
+        BreakpointSP bp_sp (*pos);
         m_breakpoints.erase(pos);
+        if (notify)
+        {
+            if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+                bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
+                                                   new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, bp_sp));
+        }
         return true;
     }
     return false;
@@ -64,11 +79,19 @@
 
 
 void
-BreakpointList::RemoveAll ()
+BreakpointList::RemoveAll (bool notify)
 {
     Mutex::Locker locker(m_mutex);
     ClearAllBreakpointSites ();
 
+    if (notify)
+    {
+        bp_collection::iterator pos, end = m_breakpoints.end();
+        for (pos = m_breakpoints.begin(); pos != end; ++pos)
+            if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+                (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged,
+                                                    new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, *pos));
+    }
     m_breakpoints.erase (m_breakpoints.begin(), m_breakpoints.end());
 }
 
@@ -144,7 +167,7 @@
 
 
 BreakpointSP
-BreakpointList::GetBreakpointByIndex (uint32_t i)
+BreakpointList::GetBreakpointAtIndex (uint32_t i)
 {
     Mutex::Locker locker(m_mutex);
     BreakpointSP stop_sp;
@@ -160,7 +183,7 @@
 }
 
 const BreakpointSP
-BreakpointList::GetBreakpointByIndex (uint32_t i) const
+BreakpointList::GetBreakpointAtIndex (uint32_t i) const
 {
     Mutex::Locker locker(m_mutex);
     BreakpointSP stop_sp;

Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Fri Jul 23 18:33:17 2010
@@ -263,6 +263,17 @@
         (*pos)->ResolveBreakpointSite();
 }
 
+uint32_t
+BreakpointLocationList::GetHitCount () const
+{
+    uint32_t hit_count = 0;
+    Mutex::Locker locker (m_mutex);
+    collection::const_iterator pos, end = m_locations.end();
+    for (pos = m_locations.begin(); pos != end; ++pos)
+        hit_count += (*pos)->GetHitCount();
+    return hit_count;
+}
+
 size_t
 BreakpointLocationList::GetNumResolvedLocations() const
 {

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Jul 23 18:33:17 2010
@@ -735,7 +735,7 @@
         result.AppendMessage ("Current breakpoints:");
         for (size_t i = 0; i < num_breakpoints; ++i)
         {
-            Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (i).get();
+            Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
             AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
         }
         result.SetStatus (eReturnStatusSuccessFinishNoResult);

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=109289&r1=109288&r2=109289&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Jul 23 18:33:17 2010
@@ -231,9 +231,9 @@
         resolver_sp->SetBreakpoint (bp_sp.get());
 
         if (internal)
-            m_internal_breakpoint_list.Add (bp_sp);
+            m_internal_breakpoint_list.Add (bp_sp, false);
         else
-            m_breakpoint_list.Add (bp_sp);
+            m_breakpoint_list.Add (bp_sp, true);
 
         Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
         if (log)
@@ -243,13 +243,6 @@
             log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData());
         }
 
-        // Broadcast the breakpoint creation event.
-        if (!internal && EventTypeHasListeners(eBroadcastBitBreakpointChanged))
-        {
-            BroadcastEvent (eBroadcastBitBreakpointChanged,
-                            new Breakpoint::BreakpointEventData (Breakpoint::BreakpointEventData::eBreakpointAdded, bp_sp));
-        }
-
         bp_sp->ResolveBreakpoint();
     }
     return bp_sp;
@@ -262,9 +255,9 @@
     if (log)
         log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
 
-    m_breakpoint_list.RemoveAll();
+    m_breakpoint_list.RemoveAll (true);
     if (internal_also)
-        m_internal_breakpoint_list.RemoveAll();
+        m_internal_breakpoint_list.RemoveAll (false);
 }
 
 void
@@ -301,9 +294,9 @@
     if (DisableBreakpointByID (break_id))
     {
         if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
-            m_internal_breakpoint_list.Remove(break_id);
+            m_internal_breakpoint_list.Remove(break_id, false);
         else
-            m_breakpoint_list.Remove(break_id);
+            m_breakpoint_list.Remove(break_id, true);
         return true;
     }
     return false;





More information about the lldb-commits mailing list