[Lldb-commits] [lldb] r125050 - in /lldb/branches/apple/calcite/lldb: include/lldb/Core/Broadcaster.h include/lldb/Core/Listener.h source/Core/Broadcaster.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Jim Ingham jingham at apple.com
Mon Feb 7 12:55:13 PST 2011


Author: jingham
Date: Mon Feb  7 14:55:13 2011
New Revision: 125050

URL: http://llvm.org/viewvc/llvm-project?rev=125050&view=rev
Log:
The hijacking listeners have to be a stack, since you can end up calling a function (like ObjC method resolution) in order to
implement calling another function.

Modified:
    lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h
    lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h
    lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp
    lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h?rev=125050&r1=125049&r2=125050&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h (original)
+++ lldb/branches/apple/calcite/lldb/include/lldb/Core/Broadcaster.h Mon Feb  7 14:55:13 2011
@@ -222,8 +222,8 @@
     bool
     IsHijackedForEvent (uint32_t event_mask)
     {
-        if (m_hijacking_listener)
-            return (event_mask & m_hijacking_mask) != 0;
+        if (m_hijacking_listeners.size() > 0)
+            return (event_mask & m_hijacking_masks.back()) != 0;
         return false;
     }
 
@@ -251,8 +251,8 @@
     event_names_map m_event_names;  ///< Optionally define event names for readability and logging for each event bit
     collection m_listeners;     ///< A list of Listener / event_mask pairs that are listening to this broadcaster.
     Mutex m_listeners_mutex;    ///< A mutex that protects \a m_listeners.
-    Listener *m_hijacking_listener;         // A simple mechanism to intercept events in lieu of a real Listener collection stack.
-    uint32_t m_hijacking_mask;
+    std::vector<Listener *> m_hijacking_listeners;  // A simple mechanism to intercept events in 
+    std::vector<uint32_t> m_hijacking_masks;
     
 private:
     //------------------------------------------------------------------

Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h?rev=125050&r1=125049&r2=125050&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h (original)
+++ lldb/branches/apple/calcite/lldb/include/lldb/Core/Listener.h Mon Feb  7 14:55:13 2011
@@ -46,6 +46,12 @@
     void
     Clear ();
 
+    const char *
+    GetName ()
+    {
+        return m_name.c_str();
+    }
+
     uint32_t
     StartListeningForEvents (Broadcaster* broadcaster,
                              uint32_t event_mask);

Modified: lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp?rev=125050&r1=125049&r2=125050&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Core/Broadcaster.cpp Mon Feb  7 14:55:13 2011
@@ -25,8 +25,8 @@
     m_broadcaster_name (name),
     m_listeners (),
     m_listeners_mutex (Mutex::eMutexTypeRecursive),
-    m_hijacking_listener(NULL),
-    m_hijacking_mask(UINT32_MAX)
+    m_hijacking_listeners(),
+    m_hijacking_masks()
 {
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
     if (log)
@@ -153,7 +153,7 @@
 {
     Mutex::Locker locker (m_listeners_mutex);
     
-    if (m_hijacking_listener != NULL && event_type & m_hijacking_mask)
+    if (m_hijacking_listeners.size() > 0 && event_type & m_hijacking_masks.back())
         return true;
         
     if (m_listeners.empty())
@@ -224,19 +224,22 @@
                      m_broadcaster_name.AsCString(""),
                      event_description.GetData(),
                      unique,
-                     m_hijacking_listener);
+                     m_hijacking_listeners.back());
     }
 
-    if (m_hijacking_listener != NULL && m_hijacking_mask & event_type)
+    if (m_hijacking_listeners.size() > 0 && m_hijacking_masks.back() & event_type)
     {
+        Listener *hijacking_listener = m_hijacking_listeners.back();
         // FIXME: REMOVE THIS EXTRA LOGGING
         LogSP log_process(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS));
         if (log_process)
-            log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\").", m_broadcaster_name.AsCString(""));
+            log_process->Printf ("Hijacking event delivery for Broadcaster(\"%s\") to Listener(\"%s\").", 
+                                 m_broadcaster_name.AsCString(""),
+                                 hijacking_listener->GetName());
             
-        if (unique && m_hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type))
+        if (unique && hijacking_listener->PeekAtNextEventForBroadcasterWithType (this, event_type))
             return;
-        m_hijacking_listener->AddEvent (event_sp);
+        hijacking_listener->AddEvent (event_sp);
     }
     else
     {
@@ -276,13 +279,9 @@
 Broadcaster::HijackBroadcaster (Listener *listener, uint32_t event_mask)
 {
     Mutex::Locker event_types_locker(m_listeners_mutex);
-    assert (m_hijacking_listener == NULL);
     
-    if (m_hijacking_listener != NULL)
-        return false;
-    
-    m_hijacking_listener = listener;
-    m_hijacking_mask = event_mask;
+    m_hijacking_listeners.push_back(listener);
+    m_hijacking_masks.push_back(event_mask);
     return true;
 }
 
@@ -290,7 +289,7 @@
 Broadcaster::RestoreBroadcaster ()
 {
     Mutex::Locker event_types_locker(m_listeners_mutex);
-    m_hijacking_listener = NULL;
-    m_hijacking_mask = 0;
+    m_hijacking_listeners.pop_back();
+    m_hijacking_masks.pop_back();
 }
 

Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125050&r1=125049&r2=125050&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb  7 14:55:13 2011
@@ -2361,6 +2361,7 @@
     static const char *bp_names[] =
     {
         "start_wqthread",
+        "_pthread_wqthread",
         "_pthread_start",
         NULL
     };
@@ -2407,18 +2408,18 @@
 bool
 ProcessGDBRemote::StopNoticingNewThreads()
 {   
+    LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+    if (log)
+        log->Printf ("Disabling new thread notification breakpoint.");
+
     size_t num_bps = m_thread_observation_bps.size();
     if (num_bps != 0)
     {
         for (int i = 0; i < num_bps; i++)
         {
-            LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
-            
             lldb::BreakpointSP break_sp = m_target.GetBreakpointByID(m_thread_observation_bps[i]);
             if (break_sp)
             {
-                if (log)
-                    log->Printf ("Disabling new thread notification breakpoint.");
                 break_sp->SetEnabled(false);
             }
         }





More information about the lldb-commits mailing list