[Lldb-commits] [lldb] r164432 - in /lldb/trunk: include/lldb/lldb-enumerations.h source/Breakpoint/Breakpoint.cpp source/Breakpoint/BreakpointLocation.cpp source/Commands/CommandObjectBreakpoint.cpp

Jim Ingham jingham at apple.com
Fri Sep 21 17:04:04 PDT 2012


Author: jingham
Date: Fri Sep 21 19:04:04 2012
New Revision: 164432

URL: http://llvm.org/viewvc/llvm-project?rev=164432&view=rev
Log:
Change the new breakpoint creation output (primarily from "break set") to something more useful.

<rdar://problem/11333623>

Modified:
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=164432&r1=164431&r2=164432&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep 21 19:04:04 2012
@@ -137,6 +137,7 @@
         eDescriptionLevelBrief = 0,
         eDescriptionLevelFull,
         eDescriptionLevelVerbose,
+        eDescriptionLevelInitial,
         kNumDescriptionLevels
     } DescriptionLevel;
 

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=164432&r1=164431&r2=164432&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri Sep 21 19:04:04 2012
@@ -511,14 +511,22 @@
 void
 Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations)
 {
-    assert (s != NULL);
-    s->Printf("%i: ", GetID());
-    GetResolverDescription (s);
-    GetFilterDescription (s);
-
     const size_t num_locations = GetNumLocations ();
     const size_t num_resolved_locations = GetNumResolvedLocations ();
 
+    assert (s != NULL);
+    
+
+    
+    // They just made the breakpoint, they don't need to be told HOW they made it...
+    // Also, we'll print the breakpoint number differently depending on whether there is 1 or more locations.
+    if (level != eDescriptionLevelInitial)
+    {
+        s->Printf("%i: ", GetID());
+        GetResolverDescription (s);
+        GetFilterDescription (s);
+    }
+    
     switch (level)
     {
     case lldb::eDescriptionLevelBrief:
@@ -545,7 +553,32 @@
             s->EOL();
         }
         break;
-
+        
+    case lldb::eDescriptionLevelInitial:
+        s->Printf ("Breakpoint %i: ", GetID());
+        if (num_locations == 0)
+        {
+            s->Printf ("no locations (pending).");
+        }
+        else if (num_locations == 1)
+        {
+            // If there is one location only, we'll just print that location information.  But don't do this if
+            // show locations is true, then that will be handled below.
+            if (show_locations == false)
+            {
+                GetLocationAtIndex(0)->GetDescription(s, level);
+            }
+            else
+            {
+                s->Printf ("%zd locations.", num_locations);
+            }
+        }
+        else
+        {
+            s->Printf ("%zd locations.", num_locations);
+        }
+        s->EOL();
+        break;
     case lldb::eDescriptionLevelVerbose:
         // Verbose mode does a debug dump of the breakpoint
         Dump (s);

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=164432&r1=164431&r2=164432&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Fri Sep 21 19:04:04 2012
@@ -410,13 +410,20 @@
 BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
 {
     SymbolContext sc;
-    s->Indent();
-    BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
-
+    
+    // If the description level is "initial" then the breakpoint is printing out our initial state,
+    // and we should let it decide how it wants to print our label.
+    if (level != eDescriptionLevelInitial)
+    {
+        s->Indent();
+        BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
+    }
+    
     if (level == lldb::eDescriptionLevelBrief)
         return;
 
-    s->PutCString(": ");
+    if (level != eDescriptionLevelInitial)
+        s->PutCString(": ");
 
     if (level == lldb::eDescriptionLevelVerbose)
         s->IndentMore();
@@ -425,7 +432,7 @@
     {
         m_address.CalculateSymbolContext(&sc);
 
-        if (level == lldb::eDescriptionLevelFull)
+        if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
         {
             s->PutCString("where = ");
             sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false);
@@ -478,7 +485,11 @@
         s->EOL();
         s->Indent();
     }
-    s->Printf ("%saddress = ", (level == lldb::eDescriptionLevelFull && m_address.IsSectionOffset()) ? ", " : "");
+    
+    if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
+        s->Printf (", ");
+    s->Printf ("address = ");
+    
     ExecutionContextScope *exe_scope = NULL;
     Target *target = &m_owner.GetTarget();
     if (target)
@@ -486,7 +497,10 @@
     if (exe_scope == NULL)
         exe_scope = target;
 
-    m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+    if (eDescriptionLevelInitial)
+        m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
+    else
+        m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
 
     if (level == lldb::eDescriptionLevelVerbose)
     {
@@ -505,7 +519,7 @@
         }
         s->IndentLess();
     }
-    else
+    else if (level != eDescriptionLevelInitial)
     {
         s->Printf(", %sresolved, hit count = %u ",
                   (IsResolved() ? "" : "un"),

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=164432&r1=164431&r2=164432&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Sep 21 19:04:04 2012
@@ -516,9 +516,8 @@
         if (bp)
         {
             Stream &output_stream = result.GetOutputStream();
-            output_stream.Printf ("Breakpoint created: ");
-            bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
-            output_stream.EOL();
+            const bool show_locations = false;
+            bp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations);
             // Don't print out this warning for exception breakpoints.  They can get set before the target
             // is set, but we won't know how to actually set the breakpoint till we run.
             if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)





More information about the lldb-commits mailing list