[Lldb-commits] [lldb] r130147 - in /lldb/trunk: include/lldb/API/SBBreakpointLocation.h scripts/Python/python-extensions.swig source/API/SBBreakpointLocation.cpp test/lldbutil.py test/python_api/target/TestTargetAPI.py

Johnny Chen johnny.chen at apple.com
Mon Apr 25 13:23:05 PDT 2011


Author: johnny
Date: Mon Apr 25 15:23:05 2011
New Revision: 130147

URL: http://llvm.org/viewvc/llvm-project?rev=130147&view=rev
Log:
Make SBBreakpointLocation::GetDescription() API to be consistent with SBTarget,
i.e., with 'SBStream &description' first, followed by 'DescriptionLevel level'.

Modify lldbutil.py so that get_description() for a target or breakpoint location
can just take the lldb object itself without specifying an option to mean option
lldb.eDescriptionLevelBrief.  Modify TestTargetAPI.py to exercise this logic path.

Modified:
    lldb/trunk/include/lldb/API/SBBreakpointLocation.h
    lldb/trunk/scripts/Python/python-extensions.swig
    lldb/trunk/source/API/SBBreakpointLocation.cpp
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/python_api/target/TestTargetAPI.py

Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=130147&r1=130146&r2=130147&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Apr 25 15:23:05 2011
@@ -82,7 +82,7 @@
     IsResolved ();
 
     bool
-    GetDescription (DescriptionLevel level, lldb::SBStream &description);
+    GetDescription (lldb::SBStream &description, DescriptionLevel level);
 
     SBBreakpoint
     GetBreakpoint ();

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=130147&r1=130146&r2=130147&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Mon Apr 25 15:23:05 2011
@@ -23,7 +23,7 @@
 %extend lldb::SBBreakpointLocation {
         PyObject *lldb::SBBreakpointLocation::__repr__ (){
                 lldb::SBStream description;
-                $self->GetDescription (lldb::eDescriptionLevelFull, description);
+                $self->GetDescription (description, lldb::eDescriptionLevelFull);
                 return PyString_FromString (description.GetData());
         }
 }

Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=130147&r1=130146&r2=130147&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpointLocation.cpp (original)
+++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Apr 25 15:23:05 2011
@@ -40,7 +40,7 @@
     if (log)
     {
         SBStream sstr;
-        GetDescription (lldb::eDescriptionLevelBrief, sstr);
+        GetDescription (sstr, lldb::eDescriptionLevelBrief);
         log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp"
                      "=%p)  => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
     }
@@ -263,7 +263,7 @@
 }
 
 bool
-SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description)
+SBBreakpointLocation::GetDescription (SBStream &description, DescriptionLevel level)
 {
     if (m_opaque_sp)
     {

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130147&r1=130146&r2=130147&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Mon Apr 25 15:23:05 2011
@@ -171,11 +171,22 @@
 # ==============================================================
 # Get the description of an lldb object or None if not available
 # ==============================================================
-def get_description(lldb_obj, option=None):
-    """Calls lldb_obj.GetDescription() and returns a string, or None."""
-    method = getattr(lldb_obj, 'GetDescription')
+def get_description(obj, option=None):
+    """Calls lldb_obj.GetDescription() and returns a string, or None.
+
+    For SBTarget and SBBreakpointLocation lldb objects, an extra option can be
+    passed in to describe the detailed level of description desired:
+        o lldb.eDescriptionLevelBrief
+        o lldb.eDescriptionLevelFull
+        o lldb.eDescriptionLevelVerbose
+    """
+    method = getattr(obj, 'GetDescription')
     if not method:
         return None
+    if isinstance(obj, lldb.SBTarget) or isinstance(obj, lldb.SBBreakpointLocation):
+        if option is None:
+            option = lldb.eDescriptionLevelBrief
+
     stream = lldb.SBStream()
     if option is None:
         success = method(stream)

Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=130147&r1=130146&r2=130147&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Mon Apr 25 15:23:05 2011
@@ -67,7 +67,10 @@
         self.assertTrue(target.IsValid(), VALID_TARGET)
 
         from lldbutil import get_description
-        desc = get_description(target, option=lldb.eDescriptionLevelBrief)
+
+        # get_description() allows no option to mean lldb.eDescriptionLevelBrief.
+        desc = get_description(target)
+        #desc = get_description(target, option=lldb.eDescriptionLevelBrief)
         if not desc:
             self.fail("SBTarget.GetDescription() failed")
         self.expect(desc, exe=False,





More information about the lldb-commits mailing list