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.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@106262 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp
index b3576b6..fb277b2 100644
--- a/source/Breakpoint/Breakpoint.cpp
+++ b/source/Breakpoint/Breakpoint.cpp
@@ -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)
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index e00afca..ef9c431 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -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()),
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index 695f4ee..c362514 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -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 ();
 }