[Lldb-commits] [lldb] r110637 - in /lldb/trunk: include/lldb/Target/StopInfo.h source/Target/Process.cpp source/Target/StopInfo.cpp

Jim Ingham jingham at apple.com
Mon Aug 9 17:59:59 PDT 2010


Author: jingham
Date: Mon Aug  9 19:59:59 2010
New Revision: 110637

URL: http://llvm.org/viewvc/llvm-project?rev=110637&view=rev
Log:
Make breakpoint commands work again.  Added a PerformAction to the stop info - actions are run when the
stop event is pulled from the event queue.  Then made the StopInfoBreakpoint's PerformAction do the 
breakpoint command.
Also fixed the StopInfoBreakpoint's GetDescription so it gets the breakpoint location info, not the breakpoint
site info.

Modified:
    lldb/trunk/include/lldb/Target/StopInfo.h
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/StopInfo.cpp

Modified: lldb/trunk/include/lldb/Target/StopInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=110637&r1=110636&r2=110637&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StopInfo.h (original)
+++ lldb/trunk/include/lldb/Target/StopInfo.h Mon Aug  9 19:59:59 2010
@@ -54,6 +54,13 @@
 
     virtual lldb::StopReason
     GetStopReason () const = 0;
+    
+    // Perform any action that is associated with this stop.  This is done as the
+    // Event is removed from the event queue.
+    virtual void
+    PerformAction (Event *event_ptr)
+    {
+    }
 
     // Stop the thread by default. Subclasses can override this to allow
     // the thread to continue if desired.

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=110637&r1=110636&r2=110637&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Mon Aug  9 19:59:59 2010
@@ -1746,8 +1746,6 @@
         int num_threads = m_process_sp->GetThreadList().GetSize();
         int idx;
 
-        int32_t should_stop_count = -1;
-        int32_t should_run_count = -1;
         for (idx = 0; idx < num_threads; ++idx)
         {
             lldb::ThreadSP thread_sp = m_process_sp->GetThreadList().GetThreadAtIndex(idx);
@@ -1755,25 +1753,14 @@
             StopInfo *stop_info = thread_sp->GetStopInfo ();
             if (stop_info)
             {
-                if (stop_info->ShouldStop(event_ptr))
-                {
-                    if (should_stop_count < 0)
-                        should_stop_count = 1;
-                    else
-                        should_stop_count++;
-                }
-                else
-                {
-                    if (should_run_count < 0)
-                        should_run_count = 1;
-                    else
-                        should_run_count++;
-                }
+                stop_info->PerformAction(event_ptr);
             }
         }
         
-        // Are we secretly watching the private state here? Should we look at the
-        // should_run_count or the "should_stop_count" and the "should_run_count"???
+        // The stop action might restart the target.  If it does, then we want to mark that in the
+        // event so that whoever is receiving it will know to wait for the running event and reflect
+        // that state appropriately.
+
         if (m_process_sp->GetPrivateState() == eStateRunning)
             SetRestarted(true);
     }

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=110637&r1=110636&r2=110637&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Mon Aug  9 19:59:59 2010
@@ -96,6 +96,35 @@
         }
         return m_should_stop;
     }
+    
+    virtual void
+    PerformAction (Event *event_ptr)
+    {
+        BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
+        if (bp_site_sp)
+        {
+            size_t num_owners = bp_site_sp->GetNumberOfOwners();
+            for (size_t j = 0; j < num_owners; j++)
+            {
+                // The breakpoint action is an asynchronous breakpoint callback.  If we ever need to have both
+                // callbacks and actions on the same breakpoint, we'll have to split this into two.
+                lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
+                StoppointCallbackContext context (event_ptr, 
+                                                  &m_thread.GetProcess(), 
+                                                  &m_thread, 
+                                                  m_thread.GetStackFrameAtIndex(0).get(),
+                                                  false);
+                bp_loc_sp->InvokeCallback (&context);
+            }
+        }
+        else
+        {
+            Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
+
+            if (log)
+                log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
+        }
+    }
         
     virtual bool
     ShouldNotify (Event *event_ptr)
@@ -123,9 +152,20 @@
     {
         if (m_description.empty())
         {
-            StreamString strm;
-            strm.Printf("breakpoint %lli", m_value);
-            m_description.swap (strm.GetString());
+            BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
+            if (bp_site_sp)
+            {
+                StreamString strm;
+                strm.Printf("breakpoint ");
+                bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
+                m_description.swap (strm.GetString());
+            }
+            else
+            {
+                StreamString strm;
+                strm.Printf("breakpoint site %lli", m_value);
+                m_description.swap (strm.GetString());
+            }
         }
         return m_description.c_str();
     }





More information about the lldb-commits mailing list