[Lldb-commits] [lldb] r106262 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointOptions.h include/lldb/Target/Thread.h include/lldb/Target/ThreadSpec.h source/Breakpoint/Breakpoint.cpp source/Breakpoint/BreakpointLocation.cpp source/Breakpoint/BreakpointOptions.cpp source/Target/Thread.cpp source/Target/ThreadSpec.cpp

Jim Ingham jingham at apple.com
Thu Jun 17 18:00:58 PDT 2010


Author: jingham
Date: Thu Jun 17 20:00:58 2010
New Revision: 106262

URL: http://llvm.org/viewvc/llvm-project?rev=106262&view=rev
Log:
Change the Breakpoint & BreakpointLocation GetDescription methods so they call the BreakpointOptions::GetDescription rather
than picking bits out of the breakpoint options.  Added BreakpointOptions::GetDescription to do this job.  Some more mucking
around to keep the breakpoint listing from getting too verbose.

Modified:
    lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/Target/ThreadSpec.h
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
    lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
    lldb/trunk/source/Target/Thread.cpp
    lldb/trunk/source/Target/ThreadSpec.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Thu Jun 17 20:00:58 2010
@@ -39,7 +39,8 @@
     BreakpointOptions();
     BreakpointOptions(const BreakpointOptions& rhs);
 
-    
+    static BreakpointOptions *
+    CopyOptionsNoCallback (BreakpointOptions &rhs);
     //------------------------------------------------------------------
     /// This constructor allows you to specify all the breakpoint options.
     ///
@@ -142,6 +143,15 @@
     
     void
     SetThreadID(lldb::tid_t thread_id);
+    
+    void
+    GetDescription (Stream *s, lldb::DescriptionLevel level) const;
+    
+    //------------------------------------------------------------------
+    /// Returns true if the breakpoint option has a callback set.
+    //------------------------------------------------------------------
+    bool
+    HasCallback();
 
     //------------------------------------------------------------------
     /// This is the default empty callback.

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Thu Jun 17 20:00:58 2010
@@ -263,6 +263,11 @@
     lldb::Vote
     ShouldReportRun (Event *event_ptr);
     
+    // Return whether this thread matches the specification in ThreadSpec.  This is a virtual
+    // method because at some point we may extend the thread spec with a platform specific
+    // dictionary of attributes, which then only the platform specific Thread implementation
+    // would know how to match.  For now, this just calls through to the ThreadSpec's 
+    // ThreadPassesBasicTests method.
     virtual bool
     MatchesSpec (const ThreadSpec *spec);
 

Modified: lldb/trunk/include/lldb/Target/ThreadSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadSpec.h?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadSpec.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadSpec.h Thu Jun 17 20:00:58 2010
@@ -121,6 +121,15 @@
             return m_queue_name == queue_name;
     }
     
+    bool
+    ThreadPassesBasicTests (Thread *thread) const;
+    
+    bool
+    HasSpecification () const;
+    
+    void
+    GetDescription (Stream *s, lldb::DescriptionLevel level) const;
+
 protected:
 private:
     uint32_t m_index;

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Thu Jun 17 20:00:58 2010
@@ -380,28 +380,21 @@
             s->Printf(" with 0 locations (Pending Breakpoint).");
         }
 
+        GetOptions()->GetDescription(s, level);
+        
         if (level == lldb::eDescriptionLevelFull)
         {
-            Baton *baton = GetOptions()->GetBaton();
-            if (baton)
-            {
-                s->EOL ();
-                s->Indent();
-                baton->GetDescription(s, level);
-            }
+            s->IndentLess();
+            s->EOL();
         }
         break;
 
     case lldb::eDescriptionLevelVerbose:
         // Verbose mode does a debug dump of the breakpoint
         Dump (s);
-        Baton *baton = GetOptions()->GetBaton();
-        if (baton)
-        {
-            s->EOL ();
-            s->Indent();
-            baton->GetDescription(s, level);
-        }
+        s->EOL ();
+        s->Indent();
+        GetOptions()->GetDescription(s, level);
         break;
     }
 
@@ -420,7 +413,8 @@
     }
 }
 
-Breakpoint::BreakpointEventData::BreakpointEventData (Breakpoint::BreakpointEventData::EventSubType sub_type, BreakpointSP &new_breakpoint_sp) :
+Breakpoint::BreakpointEventData::BreakpointEventData (Breakpoint::BreakpointEventData::EventSubType sub_type, 
+                                                      BreakpointSP &new_breakpoint_sp) :
     EventData (),
     m_sub_type (sub_type),
     m_new_breakpoint_sp (new_breakpoint_sp)

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Thu Jun 17 20:00:58 2010
@@ -109,15 +109,10 @@
 bool
 BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
 {
-    bool owner_result;
-
-    owner_result = m_owner.InvokeCallback (context, GetID());
-    if (owner_result == false)
-        return false;
-    else if (m_options_ap.get() != NULL)
+    if (m_options_ap.get() != NULL && m_options_ap->HasCallback())
         return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
-    else
-        return true;
+    else    
+        return m_owner.InvokeCallback (context, GetID());
 }
 
 void
@@ -166,9 +161,12 @@
 BreakpointOptions *
 BreakpointLocation::GetLocationOptions ()
 {
+    // If we make the copy we don't copy the callbacks because that is potentially 
+    // expensive and we don't want to do that for the simple case where someone is
+    // just disabling the location.
     if (m_options_ap.get() == NULL)
-        m_options_ap.reset(new BreakpointOptions (*m_owner.GetOptions ()));
-
+        m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
+    
     return m_options_ap.get();
 }
 
@@ -257,7 +255,8 @@
 {
     if (m_bp_site_sp.get())
     {
-        m_owner.GetTarget().GetProcessSP()->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(), GetID(), m_bp_site_sp);
+        m_owner.GetTarget().GetProcessSP()->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(), 
+                                                                           GetID(), m_bp_site_sp);
         m_bp_site_sp.reset();
         return true;
     }
@@ -353,29 +352,25 @@
         s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
 
         s->Indent();
-        s->Printf("enabled = %s\n", IsEnabled() ? "true" : "false");
-
-        s->Indent();
         s->Printf ("hit count = %-4u\n", GetHitCount());
 
         if (m_options_ap.get())
         {
-            Baton *baton = m_options_ap->GetBaton();
-            if (baton)
-            {
-                s->Indent();
-                baton->GetDescription (s, level);
-                s->EOL();
-            }
+            s->Indent();
+            m_options_ap->GetDescription (s, level);
+            s->EOL();
         }
         s->IndentLess();
     }
     else
     {
-        s->Printf(", %sresolved, %s, hit count = %u",
+        s->Printf(", %sresolved, hit count = %u ",
                   (IsResolved() ? "" : "un"),
-                  (IsEnabled() ? "enabled" : "disabled"),
                   GetHitCount());
+        if (m_options_ap.get())
+        {
+            m_options_ap->GetDescription (s, level);
+        }
     }
 }
 
@@ -385,7 +380,8 @@
     if (s == NULL)
         return;
 
-    s->Printf("BreakpointLocation %u: tid = %4.4x  load addr = 0x%8.8llx  state = %s  type = %s breakpoint  hw_index = %i  hit_count = %-4u  ignore_count = %-4u",
+    s->Printf("BreakpointLocation %u: tid = %4.4x  load addr = 0x%8.8llx  state = %s  type = %s breakpoint  "
+              "hw_index = %i  hit_count = %-4u  ignore_count = %-4u",
             GetID(),
             GetOptionsNoCopy()->GetThreadSpec()->GetTID(),
             (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()),

Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Thu Jun 17 20:00:58 2010
@@ -71,6 +71,21 @@
     return *this;
 }
 
+BreakpointOptions *
+BreakpointOptions::CopyOptionsNoCallback (BreakpointOptions &orig)
+{
+    BreakpointHitCallback orig_callback = orig.m_callback;
+    lldb::BatonSP orig_callback_baton_sp = orig.m_callback_baton_sp;
+    bool orig_is_sync = orig.m_callback_is_synchronous;
+    
+    orig.ClearCallback();
+    BreakpointOptions *ret_val = new BreakpointOptions(orig);
+    
+    orig.SetCallback (orig_callback, orig_callback_baton_sp, orig_is_sync);
+    
+    return ret_val;
+}
+
 //----------------------------------------------------------------------
 // Destructor
 //----------------------------------------------------------------------
@@ -124,6 +139,12 @@
         return true;
 }
 
+bool
+BreakpointOptions::HasCallback ()
+{
+    return m_callback != BreakpointOptions::NullCallback;
+}
+
 //------------------------------------------------------------------
 // Enabled/Ignore Count
 //------------------------------------------------------------------
@@ -173,10 +194,68 @@
 }
 
 void
+BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const
+{
+
+    // Figure out if there are any options not at their default value, and only print 
+    // anything if there are:
+    
+    if (m_ignore_count != 0 || !m_enabled || (GetThreadSpec() != NULL && GetThreadSpec()->HasSpecification ()))
+    {
+        if (level == lldb::eDescriptionLevelVerbose)
+        {
+            s->EOL ();
+            s->IndentMore();
+            s->Indent();
+            s->PutCString("Breakpoint Options:\n");
+            s->IndentMore();
+            s->Indent();
+        }
+        else
+            s->PutCString(" Options: ");
+                
+        if (m_ignore_count > 0)
+            s->Printf("ignore: %d ", m_ignore_count);
+        s->Printf("%sabled ", m_enabled ? "en" : "dis");
+        
+        if (m_thread_spec_ap.get())
+            m_thread_spec_ap->GetDescription (s, level);
+        else if (level == eDescriptionLevelBrief)
+            s->PutCString ("thread spec: no ");
+        if (level == lldb::eDescriptionLevelFull)
+        {
+            s->IndentLess();
+            s->IndentMore();
+        }
+    }
+            
+    if (m_callback_baton_sp.get())
+    {
+        if (level != eDescriptionLevelBrief)
+            s->EOL();
+        m_callback_baton_sp->GetDescription (s, level);
+    }
+    else if (level == eDescriptionLevelBrief)
+        s->PutCString ("commands: no ");
+    
+}
+
+void
 BreakpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLevel level) const
 {
-    s->Indent("Breakpoint commands:\n");
     CommandData *data = (CommandData *)m_data;
+
+    if (level == eDescriptionLevelBrief)
+    {
+        if (data && data->user_source.GetSize() > 0)
+            s->PutCString("commands: yes ");
+        else
+            s->PutCString("commands: no ");
+        return;
+    }
+    
+    s->IndentMore ();
+    s->Indent("Breakpoint commands:\n");
     
     s->IndentMore ();
     if (data && data->user_source.GetSize() > 0)
@@ -193,5 +272,6 @@
         s->PutCString ("No commands.\n");
     }
     s->IndentLess ();
+    s->IndentLess ();
 }
 

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Thu Jun 17 20:00:58 2010
@@ -617,20 +617,8 @@
 {
     if (spec == NULL)
         return true;
-    
-    if (!spec->TIDMatches(GetID()))
-        return false;
         
-    if (!spec->IndexMatches(GetIndexID()))
-        return false;
-        
-    if (!spec->NameMatches (GetName()))
-        return false;
-        
-    if (!spec->QueueNameMatches (GetQueueName()))
-        return false;
-        
-    return true;
+    return spec->ThreadPassesBasicTests(this);    
 }
 
 void

Modified: lldb/trunk/source/Target/ThreadSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=106262&r1=106261&r2=106262&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadSpec.cpp (original)
+++ lldb/trunk/source/Target/ThreadSpec.cpp Thu Jun 17 20:00:58 2010
@@ -56,3 +56,67 @@
     else
         return m_queue_name.c_str();
 }
+
+bool
+ThreadSpec::ThreadPassesBasicTests (Thread *thread) const
+{
+
+    if (!HasSpecification())
+        return true;
+        
+    if (!TIDMatches(thread->GetID()))
+        return false;
+        
+    if (!IndexMatches(thread->GetIndexID()))
+        return false;
+        
+    if (!NameMatches (thread->GetName()))
+        return false;
+        
+    if (!QueueNameMatches (thread->GetQueueName()))
+        return false;
+        
+    return true;
+
+}
+
+bool
+ThreadSpec::HasSpecification() const
+{
+    return (m_index != -1 || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty());
+}
+void
+ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const
+{
+    if (!HasSpecification())
+    {
+        if (level == eDescriptionLevelBrief)
+        {
+            s->PutCString("thread spec: no ");
+        }
+    }
+    else
+    {
+        if (level == eDescriptionLevelBrief)
+        {
+            s->PutCString("thread spec: yes ");
+        }
+        else
+        {
+            if (GetTID() != LLDB_INVALID_THREAD_ID)
+                s->Printf("tid: 0x%llx ", GetTID());
+                
+            if (GetIndex() != -1)
+                s->Printf("index: %d ", GetIndex());
+                
+            const char *name = GetName();
+            if (name)
+                s->Printf ("thread name: \"%s\" ", name);
+                
+            const char *queue_name = GetQueueName();
+            if (queue_name)
+                s->Printf ("queue name: \"%s\" ", queue_name);
+        }
+
+    }
+}





More information about the lldb-commits mailing list