[Lldb-commits] [lldb] r114321 - in /lldb/trunk: include/lldb/API/ include/lldb/Symbol/ lldb.xcodeproj/ scripts/ source/API/ source/Symbol/

Caroline Tice ctice at apple.com
Sun Sep 19 22:20:03 PDT 2010


Author: ctice
Date: Mon Sep 20 00:20:02 2010
New Revision: 114321

URL: http://llvm.org/viewvc/llvm-project?rev=114321&view=rev
Log:

Add GetDescription() and __repr__ () methods to most API classes, to allow
"print" from inside Python to print out the objects in a more useful
manner.


Modified:
    lldb/trunk/include/lldb/API/SBAddress.h
    lldb/trunk/include/lldb/API/SBBlock.h
    lldb/trunk/include/lldb/API/SBBreakpoint.h
    lldb/trunk/include/lldb/API/SBBreakpointLocation.h
    lldb/trunk/include/lldb/API/SBCommandReturnObject.h
    lldb/trunk/include/lldb/API/SBCompileUnit.h
    lldb/trunk/include/lldb/API/SBDebugger.h
    lldb/trunk/include/lldb/API/SBDefines.h
    lldb/trunk/include/lldb/API/SBError.h
    lldb/trunk/include/lldb/API/SBEvent.h
    lldb/trunk/include/lldb/API/SBFileSpec.h
    lldb/trunk/include/lldb/API/SBFrame.h
    lldb/trunk/include/lldb/API/SBFunction.h
    lldb/trunk/include/lldb/API/SBInstruction.h
    lldb/trunk/include/lldb/API/SBLineEntry.h
    lldb/trunk/include/lldb/API/SBModule.h
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/include/lldb/API/SBStream.h
    lldb/trunk/include/lldb/API/SBSymbol.h
    lldb/trunk/include/lldb/API/SBSymbolContext.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/include/lldb/Symbol/Block.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/scripts/lldb.swig
    lldb/trunk/source/API/SBAddress.cpp
    lldb/trunk/source/API/SBBlock.cpp
    lldb/trunk/source/API/SBBreakpoint.cpp
    lldb/trunk/source/API/SBBreakpointLocation.cpp
    lldb/trunk/source/API/SBCommandReturnObject.cpp
    lldb/trunk/source/API/SBCompileUnit.cpp
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/API/SBError.cpp
    lldb/trunk/source/API/SBEvent.cpp
    lldb/trunk/source/API/SBFileSpec.cpp
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/API/SBFunction.cpp
    lldb/trunk/source/API/SBLineEntry.cpp
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/API/SBProcess.cpp
    lldb/trunk/source/API/SBSymbol.cpp
    lldb/trunk/source/API/SBSymbolContext.cpp
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/source/Symbol/Block.cpp

Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Mon Sep 20 00:20:02 2010
@@ -44,6 +44,16 @@
     bool
     OffsetAddress (addr_t offset);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
 
     friend class SBFrame;

Modified: lldb/trunk/include/lldb/API/SBBlock.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBlock.h (original)
+++ lldb/trunk/include/lldb/API/SBBlock.h Mon Sep 20 00:20:02 2010
@@ -49,6 +49,16 @@
     lldb::SBBlock
     GetFirstChild ();
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject *, which contains a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBFrame;
     friend class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Mon Sep 20 00:20:02 2010
@@ -104,8 +104,8 @@
     size_t
     GetNumLocations() const;
 
-    void
-    GetDescription (FILE *, const char *description_level);
+    bool
+    GetDescription (const char *description_level, lldb::SBStream &description);
 
     static lldb::BreakpointEventType
     GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
@@ -116,6 +116,13 @@
     static lldb::SBBreakpointLocation
     GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
 
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBBreakpointLocation;
     friend class SBTarget;

Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Mon Sep 20 00:20:02 2010
@@ -68,12 +68,19 @@
     bool
     IsResolved ();
 
-    void
-    GetDescription (FILE *f, const char *description_level);
+    bool
+    GetDescription (const char *description_level, lldb::SBStream &description);
 
     SBBreakpoint
     GetBreakpoint ();
 
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBBreakpoint;
 

Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Mon Sep 20 00:20:02 2010
@@ -58,6 +58,16 @@
     void
     AppendMessage (const char *message);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     friend class SBCommandInterpreter;
     friend class SBOptions;

Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCompileUnit.h (original)
+++ lldb/trunk/include/lldb/API/SBCompileUnit.h Mon Sep 20 00:20:02 2010
@@ -50,6 +50,16 @@
 
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBFrame;
     friend class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Sep 20 00:20:02 2010
@@ -154,6 +154,16 @@
     static lldb::SBStringList
     GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
     uint32_t
     GetTerminalWidth () const;
 

Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Mon Sep 20 00:20:02 2010
@@ -10,6 +10,11 @@
 #ifndef LLDB_SBDefines_h_
 #define LLDB_SBDefines_h_
 
+// In order to guarantee correct working with Python, Python.h *MUST* be
+// the *FIRST* header file included:
+
+#include <Python.h>
+
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
@@ -49,6 +54,7 @@
 class SBModule;
 class SBProcess;
 class SBSourceManager;
+class SBStream;
 class SBStringList;
 class SBSymbol;
 class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBError.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBError.h (original)
+++ lldb/trunk/include/lldb/API/SBError.h Mon Sep 20 00:20:02 2010
@@ -65,6 +65,16 @@
     bool
     IsValid () const;
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     friend class SBArguments;
     friend class SBDebugger;

Modified: lldb/trunk/include/lldb/API/SBEvent.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBEvent.h (original)
+++ lldb/trunk/include/lldb/API/SBEvent.h Mon Sep 20 00:20:02 2010
@@ -10,10 +10,11 @@
 #ifndef LLDB_SBEvent_h_
 #define LLDB_SBEvent_h_
 
+#include "lldb/API/SBDefines.h"
+
 #include <stdio.h>
 #include <vector>
 
-#include "lldb/API/SBDefines.h"
 
 namespace lldb {
 
@@ -53,6 +54,16 @@
     static const char *
     GetCStringFromEvent (const lldb::SBEvent &event);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+   PyObject *
+   __repr__ ();
+
 protected:
     friend class SBListener;
     friend class SBBroadcaster;

Modified: lldb/trunk/include/lldb/API/SBFileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFileSpec.h (original)
+++ lldb/trunk/include/lldb/API/SBFileSpec.h Mon Sep 20 00:20:02 2010
@@ -51,6 +51,16 @@
     static int
     ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBBlock;
     friend class SBCompileUnit;

Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Mon Sep 20 00:20:02 2010
@@ -112,6 +112,16 @@
     lldb::SBValue
     LookupVarInScope (const char *var_name, const char *scope);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     friend class SBValue;
 

Modified: lldb/trunk/include/lldb/API/SBFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFunction.h (original)
+++ lldb/trunk/include/lldb/API/SBFunction.h Mon Sep 20 00:20:02 2010
@@ -39,6 +39,16 @@
     operator != (const lldb::SBFunction &rhs) const;
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBFrame;
     friend class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBInstruction.h (original)
+++ lldb/trunk/include/lldb/API/SBInstruction.h Mon Sep 20 00:20:02 2010
@@ -46,6 +46,16 @@
     void
     Print (FILE *out);
 
+    //bool
+    //GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    //PyObject *
+    //__repr__ ();
+
 private:
 
     //lldb_private::Disassembler::Instruction::SharedPtr  m_opaque_sp;

Modified: lldb/trunk/include/lldb/API/SBLineEntry.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBLineEntry.h (original)
+++ lldb/trunk/include/lldb/API/SBLineEntry.h Mon Sep 20 00:20:02 2010
@@ -58,6 +58,16 @@
 
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBCompileUnit;
     friend class SBFrame;

Modified: lldb/trunk/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBModule.h (original)
+++ lldb/trunk/include/lldb/API/SBModule.h Mon Sep 20 00:20:02 2010
@@ -49,6 +49,16 @@
     ResolveSymbolContextForAddress (const lldb::SBAddress& addr, 
                                     uint32_t resolve_scope);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     friend class SBSymbolContext;
     friend class SBTarget;

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Mon Sep 20 00:20:02 2010
@@ -152,6 +152,16 @@
     lldb::SBBroadcaster
     GetBroadcaster () const;
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It take no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     friend class SBAddress;
     friend class SBBreakpoint;

Modified: lldb/trunk/include/lldb/API/SBStream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBStream.h (original)
+++ lldb/trunk/include/lldb/API/SBStream.h Mon Sep 20 00:20:02 2010
@@ -55,6 +55,19 @@
     Clear ();
 
 protected:
+    friend class SBAddress;
+    friend class SBBlock;
+    friend class SBBreakpoint;
+    friend class SBBreakpointLocation;
+    friend class SBCompileUnit;
+    friend class SBEvent;
+    friend class SBFrame;
+    friend class SBFunction;
+    friend class SBModule;
+    friend class SBSymbol;
+    friend class SBSymbolContext;
+    friend class SBTarget;
+    friend class SBThread;
 
 #ifndef SWIG
 

Modified: lldb/trunk/include/lldb/API/SBSymbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbol.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbol.h Mon Sep 20 00:20:02 2010
@@ -40,6 +40,15 @@
     operator != (const lldb::SBSymbol &rhs) const;
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
 
 private:
     friend class SBSymbolContext;

Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbolContext.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbolContext.h Mon Sep 20 00:20:02 2010
@@ -71,6 +71,16 @@
     void
     SetSymbolContext (const lldb_private::SymbolContext *sc_ptr);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 private:
     std::auto_ptr<lldb_private::SymbolContext> m_opaque_ap;
 };

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Mon Sep 20 00:20:02 2010
@@ -142,6 +142,16 @@
 
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     friend class SBAddress;
     friend class SBDebugger;

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Mon Sep 20 00:20:02 2010
@@ -88,6 +88,15 @@
 
 #endif
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
 
 protected:
     friend class SBBreakpoint;

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Mon Sep 20 00:20:02 2010
@@ -54,6 +54,16 @@
     static bool
     IsPointerType (void *opaque_type);
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It takes no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
+
 protected:
     void *m_ast;
     void *m_type;

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Mon Sep 20 00:20:02 2010
@@ -85,6 +85,15 @@
     bool
     TypeIsPtrType ();
 
+    bool
+    GetDescription (lldb::SBStream &description);
+
+    // The following function gets called by Python when a user tries to print
+    // an object of this class.  It take no arguments and returns a
+    // PyObject * representing a char * (and it must be named "__repr__");
+
+    PyObject *
+    __repr__ ();
 
 protected:
     friend class SBValueList;

Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 20 00:20:02 2010
@@ -185,6 +185,10 @@
     DumpSymbolContext(Stream *s);
 
     void
+    DumpAddressRanges (Stream *s,
+                       lldb::addr_t base_addr);
+                      
+    void
     GetDescription (Stream *s, 
                     Function *function, 
                     lldb::DescriptionLevel level, 

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Sep 20 00:20:02 2010
@@ -2974,6 +2974,7 @@
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
+				HEADER_SEARCH_PATHS = /usr/include/python2.6;
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
@@ -3063,6 +3064,7 @@
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
+				HEADER_SEARCH_PATHS = /usr/include/python2.6;
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
@@ -3102,6 +3104,7 @@
 				GCC_MODEL_TUNING = G5;
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				GCC_VERSION = 4.2;
+				HEADER_SEARCH_PATHS = /usr/include/python2.6;
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";

Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Mon Sep 20 00:20:02 2010
@@ -90,6 +90,7 @@
 #include "lldb/API/SBModule.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBSourceManager.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBSymbol.h"
 #include "lldb/API/SBSymbolContext.h"
@@ -143,6 +144,7 @@
 %include "lldb/API/SBModule.h"
 %include "lldb/API/SBProcess.h"
 %include "lldb/API/SBSourceManager.h"
+%include "lldb/API/SBStream.h"
 %include "lldb/API/SBStringList.h"
 %include "lldb/API/SBSymbol.h"
 %include "lldb/API/SBSymbolContext.h"

Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Mon Sep 20 00:20:02 2010
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBProcess.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/Address.h"
 
 using namespace lldb;
@@ -136,3 +137,24 @@
 }
 
 
+bool
+SBAddress::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+      {
+        m_opaque_ap->DumpDebug (description.get());
+      }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBAddress::__repr__ ()
+{
+    SBStream description;
+    description.ref();            // Make sure it contains a valid StreamString.
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBlock.cpp (original)
+++ lldb/trunk/source/API/SBBlock.cpp Mon Sep 20 00:20:02 2010
@@ -9,8 +9,10 @@
 
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -132,4 +134,36 @@
 }
 
 
-
+bool
+SBBlock::GetDescription (SBStream &description)
+{
+    if (m_opaque_ptr)
+      {
+        lldb::user_id_t id = m_opaque_ptr->GetID();
+        description.Printf ("Block: {id: %d} ", id);
+        if (IsInlined())
+          {
+            description.Printf (" (inlined, '%s') ", GetInlinedName());
+          }
+        lldb_private::SymbolContext sc;
+        m_opaque_ptr->CalculateSymbolContext (&sc);
+        if (sc.function)
+          {
+            m_opaque_ptr->DumpAddressRanges (description.get(), 
+                                             sc.function->GetAddressRange().GetBaseAddress().GetFileAddress());
+          }
+      }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+PyObject *
+SBBlock::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Mon Sep 20 00:20:02 2010
@@ -12,6 +12,7 @@
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBProcess.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/API/SBThread.h"
 
 #include "lldb/Breakpoint/Breakpoint.h"
@@ -321,12 +322,9 @@
         return 0;
 }
 
-void
-SBBreakpoint::GetDescription (FILE *f, const char *description_level)
+bool
+SBBreakpoint::GetDescription (const char *description_level, SBStream &description)
 {
-    if (f == NULL)
-        return;
-
     if (m_opaque_sp)
     {
         DescriptionLevel level;
@@ -339,11 +337,23 @@
         else
             level = eDescriptionLevelBrief;
 
-        StreamFile str (f);
 
-        m_opaque_sp->GetDescription (&str, level);
-        str.EOL();
+        m_opaque_sp->GetDescription (description.get(), level);
+        description.get()->EOL();
     }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBBreakpoint::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription ("full", description);
+    return PyString_FromString (description.GetData());
 }
 
 bool

Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpointLocation.cpp (original)
+++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Sep 20 00:20:02 2010
@@ -7,9 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
+// In order to guarantee correct working with Python, Python.h *MUST* be
+// the *FIRST* header file included:
+
+#include <Python.h>
+
 #include "lldb/API/SBBreakpointLocation.h"
 #include "lldb/API/SBDefines.h"
 #include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBStream.h"
 
 #include "lldb/lldb-types.h"
 #include "lldb/lldb-defines.h"
@@ -191,12 +197,9 @@
     m_opaque_sp = break_loc_sp;
 }
 
-void
-SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
+bool
+SBBreakpointLocation::GetDescription (const char *description_level, SBStream &description)
 {
-    if (f == NULL)
-        return;
-
     if (m_opaque_sp)
     {
         DescriptionLevel level;
@@ -209,11 +212,22 @@
         else
             level = eDescriptionLevelBrief;
 
-        StreamFile str (f);
-
-        m_opaque_sp->GetDescription (&str, level);
-        str.EOL();
+        m_opaque_sp->GetDescription (description.get(), level);
+        description.get()->EOL();
     }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBBreakpointLocation::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription ("full", description);
+    return PyString_FromString (description.GetData());
 }
 
 SBBreakpoint

Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCommandReturnObject.cpp (original)
+++ lldb/trunk/source/API/SBCommandReturnObject.cpp Mon Sep 20 00:20:02 2010
@@ -7,9 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Interpreter/CommandReturnObject.h"
-
 #include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBStream.h"
+
+#include "lldb/Interpreter/CommandReturnObject.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -160,3 +161,38 @@
         m_opaque_ap.reset (ptr);
 }
 
+bool
+SBCommandReturnObject::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+    {
+        description.Printf ("Status:  ");
+        lldb::ReturnStatus status = m_opaque_ap->GetStatus();
+        if (status == lldb::eReturnStatusStarted)
+            description.Printf ("Started");
+        else if (status == lldb::eReturnStatusInvalid)
+            description.Printf ("Invalid");
+        else if (m_opaque_ap->Succeeded())
+            description.Printf ("Success");
+        else
+            description.Printf ("Fail");
+
+        if (GetOutputSize() > 0)
+            description.Printf ("\nOutput Message:\n%s", GetOutput());
+
+        if (GetErrorSize() > 0)
+            description.Printf ("\nError Message:\n%s", GetError());
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBCommandReturnObject::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBCompileUnit.cpp (original)
+++ lldb/trunk/source/API/SBCompileUnit.cpp Mon Sep 20 00:20:02 2010
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBCompileUnit.h"
 #include "lldb/API/SBLineEntry.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineEntry.h"
 #include "lldb/Symbol/LineTable.h"
@@ -118,3 +119,25 @@
 {
     return *m_opaque_ptr;
 }
+
+bool
+SBCompileUnit::GetDescription (SBStream &description)
+{
+    if (m_opaque_ptr)
+      {
+        m_opaque_ptr->Dump (description.get(), false);
+      }
+    else
+      description.Printf ("No Value");
+    
+    return true;
+}
+
+PyObject *
+SBCompileUnit::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Sep 20 00:20:02 2010
@@ -25,6 +25,7 @@
 #include "lldb/API/SBInputReader.h"
 #include "lldb/API/SBProcess.h"
 #include "lldb/API/SBSourceManager.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBThread.h"
@@ -669,3 +670,26 @@
         return false;
 }
 
+bool
+SBDebugger::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        const char *name = m_opaque_sp->GetInstanceName().AsCString();
+        lldb::user_id_t id = m_opaque_sp->GetID();
+        description.Printf ("Debugger (instance: '%s', id: %d)", name, id);
+    }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+
+PyObject *
+SBDebugger::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBError.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBError.cpp (original)
+++ lldb/trunk/source/API/SBError.cpp Mon Sep 20 00:20:02 2010
@@ -8,7 +8,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBError.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/Error.h"
+
 #include <stdarg.h>
 
 using namespace lldb;
@@ -178,3 +180,29 @@
     return *m_opaque_ap;
 }
 
+bool
+SBError::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+    {
+        if (Success())
+            description.Printf ("Status: Success");
+        else
+        {
+            const char * err_string = GetCString();
+            description.Printf ("Status:  Error: %s",  (err_string != NULL ? err_string : ""));
+        }
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+} 
+
+PyObject *
+SBError::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBEvent.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBEvent.cpp (original)
+++ lldb/trunk/source/API/SBEvent.cpp Mon Sep 20 00:20:02 2010
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBBroadcaster.h"
+#include "lldb/API/SBStream.h"
 
 #include "lldb/Core/Event.h"
 #include "lldb/Core/Stream.h"
@@ -150,3 +151,24 @@
 }
 
 
+bool
+SBEvent::GetDescription (SBStream &description)
+{
+    if (m_opaque)
+      {
+        m_opaque->Dump (description.get());
+      }
+    else
+      description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBEvent::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBFileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFileSpec.cpp (original)
+++ lldb/trunk/source/API/SBFileSpec.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/FileSpec.h"
 
 using namespace lldb;
@@ -138,3 +139,30 @@
         m_opaque_ap.reset (new FileSpec (fs));
 }
 
+bool
+SBFileSpec::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+    {
+        const char *filename = GetFilename();
+        const char *dir_name = GetDirectory();
+        if (!filename && !dir_name)
+            description.Printf ("No value");
+        else if (!dir_name)
+            description.Printf ("%s", filename);
+        else
+            description.Printf ("%s/%s", dir_name, filename);
+    }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+PyObject *
+SBFileSpec::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Mon Sep 20 00:20:02 2010
@@ -34,6 +34,7 @@
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBValue.h"
 #include "lldb/API/SBAddress.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/API/SBSymbolContext.h"
 #include "lldb/API/SBThread.h"
 
@@ -203,7 +204,13 @@
         if (!found)
             var_sp.reset();
     }
-    SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp)));
+    if (var_sp)
+    {
+        SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp)));
+        return sb_value;
+    }
+    
+    SBValue sb_value;
     return sb_value;
 }
 
@@ -249,7 +256,14 @@
                 var_sp.reset();
         }
     }
-    SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp)));
+    
+    if (var_sp)
+    {
+        SBValue sb_value (ValueObjectSP (new ValueObjectVariable (var_sp)));
+        return sb_value;
+    }
+    
+    SBValue sb_value;
     return sb_value;
 }
 
@@ -375,3 +389,24 @@
     return value_list;
 }
 
+bool
+SBFrame::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->Dump (description.get(), true, false);
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBFrame::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFunction.cpp (original)
+++ lldb/trunk/source/API/SBFunction.cpp Mon Sep 20 00:20:02 2010
@@ -9,6 +9,7 @@
 
 #include "lldb/API/SBFunction.h"
 #include "lldb/API/SBProcess.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/Function.h"
 
 using namespace lldb;
@@ -62,3 +63,25 @@
 {
     return m_opaque_ptr != rhs.m_opaque_ptr;
 }
+
+bool
+SBFunction::GetDescription (SBStream &description)
+{
+    if (m_opaque_ptr)
+    {
+        m_opaque_ptr->Dump (description.get(), false);
+    }
+    else
+      description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBFunction::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBLineEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLineEntry.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBLineEntry.cpp (original)
+++ lldb/trunk/source/API/SBLineEntry.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBLineEntry.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/LineEntry.h"
 
 using namespace lldb;
@@ -152,7 +153,30 @@
     return *m_opaque_ap;
 }
 
+bool
+SBLineEntry::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+    {
+        // Line entry:  File, line x {, column y}:  Addresses: <start_addr> - <end_addr>
+        char file_path[PATH_MAX*2];
+        m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
+        description.Printf ("Line entry: %s, line %d", file_path, GetLine());
+        if (GetColumn() > 0)
+            description.Printf (", column %d", GetColumn());
+        description.Printf (":  Addresses:  0x%p - 0x%p", GetStartAddress().GetFileAddress() , 
+                            GetEndAddress().GetFileAddress());
+    }
+    else
+        description.Printf ("No value");
 
+    return true;
+}
 
-
-
+PyObject *
+SBLineEntry::__repr__ ()
+{
+    SBStream description; 
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Mon Sep 20 00:20:02 2010
@@ -11,6 +11,7 @@
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/Module.h"
 
 using namespace lldb;
@@ -127,3 +128,24 @@
     return sb_sc;
 }
 
+bool
+SBModule::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->Dump (description.get());
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBModule::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Mon Sep 20 00:20:02 2010
@@ -30,6 +30,7 @@
 #include "lldb/API/SBCommandReturnObject.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBThread.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 
 using namespace lldb;
@@ -466,3 +467,29 @@
     return m_opaque_sp.get();
 }
 
+bool
+SBProcess::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        char path[PATH_MAX];
+        GetTarget().GetExecutable().GetPath (path, sizeof(path));
+        description.Printf ("Process {pid: %d, executable %s\n", (int) GetProcessID(), path);
+        description.Printf ("         instance name: %s, state: %s, thread cnt: %d}", 
+                            m_opaque_sp->GetInstanceName().AsCString(), 
+                            SBDebugger::StateAsCString (GetState()), 
+                            GetNumThreads());
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBProcess::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbol.cpp (original)
+++ lldb/trunk/source/API/SBSymbol.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBSymbol.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/Symbol.h"
 
 using namespace lldb;
@@ -62,3 +63,25 @@
 {
     return m_opaque_ptr != rhs.m_opaque_ptr;
 }
+
+bool
+SBSymbol::GetDescription (SBStream &description)
+{
+    if (m_opaque_ptr)
+    {
+        m_opaque_ptr->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
+    }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+PyObject *
+SBSymbol::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBSymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbolContext.cpp (original)
+++ lldb/trunk/source/API/SBSymbolContext.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Symbol/SymbolContext.h"
 
 using namespace lldb;
@@ -146,5 +147,24 @@
     return m_opaque_ap.get();
 }
 
+bool
+SBSymbolContext::GetDescription (SBStream &description)
+{
+    if (m_opaque_ap.get())
+    {
+        m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
+    }
+    else
+        description.Printf ("No value");
 
+    return true;
+}
 
+PyObject *
+SBSymbolContext::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Mon Sep 20 00:20:02 2010
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBModule.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Breakpoint/BreakpointID.h"
 #include "lldb/Breakpoint/BreakpointIDList.h"
 #include "lldb/Breakpoint/BreakpointList.h"
@@ -500,3 +501,25 @@
                                    out_stream);
     }
 }
+
+bool
+SBTarget::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+      {
+        m_opaque_sp->Dump (description.get());
+      }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+PyObject *
+SBTarget::__repr__ ()
+{
+    SBStream description;
+    description.ref();
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Mon Sep 20 00:20:02 2010
@@ -11,6 +11,7 @@
 
 #include "lldb/API/SBSymbolContext.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/StreamFile.h"
@@ -412,3 +413,26 @@
 {
     return *m_opaque_sp;
 }
+
+bool
+SBThread::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        m_opaque_sp->DumpInfo (description.ref(), true, true, true, LLDB_INVALID_INDEX32);
+        description.Printf (" %d frames, (instance name: %s)", GetNumFrames(), 
+                            m_opaque_sp->GetInstanceName().AsCString());
+    }
+    else
+        description.Printf ("No value");
+    
+    return true;
+}
+
+PyObject *
+SBThread::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBType.h"
+#include "lldb/API/SBStream.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTType.h"
@@ -144,6 +145,53 @@
     return SBType (pointee_type ? m_ast : NULL, pointee_type);
 }
 
+bool
+SBType::GetDescription (SBStream &description)
+{
+    const char *name = GetName();
+    uint64_t byte_size = GetByteSize();
+    uint64_t num_children = GetNumberChildren (true);
+    bool is_ptr = IsPointerType ();
+
+    description.Printf ("type_name: %s, size: %d bytes", (name != NULL ? name : "<unknown type name>"), byte_size);
+    if (is_ptr)
+    {
+        SBType pointee_type = GetPointeeType();
+        const char *pointee_name = pointee_type.GetName();
+        description.Printf (", (* %s)", (pointee_name != NULL ? pointee_name : "<unknown type name>"));
+    }
+    else if (num_children > 0)
+    {
+        description.Printf (", %d members:\n", num_children);
+        for (uint32_t i = 0; i < num_children; ++i)
+        {
+            SBTypeMember field;
+            GetChildAtIndex (true, i, field);
+            const char *field_name = field.GetName();
+            SBType field_type = field.GetType();
+            const char *field_type_name = field_type.GetName();
+            
+            description.Printf ("     %s (type: %s", (field_name != NULL ? field_name : "<unknown member name>"), 
+                                (field_type_name != NULL ? field_type_name : "<unknown type name>"));
+
+            if (field.IsBitfield())
+            {
+                size_t width = field.GetBitfieldWidth ();
+                description.Printf (" , %d bits", (int) width);
+            }
+            description.Printf (")\n");
+        }
+    }
+    return true;
+}
+
+PyObject *
+SBType::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}
 
 SBTypeMember::SBTypeMember () :
     m_ast (NULL),

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Mon Sep 20 00:20:02 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/API/SBValue.h"
+#include "lldb/API/SBStream.h"
 
 #include "lldb/Core/DataExtractor.h"
 #include "lldb/Core/Module.h"
@@ -268,3 +269,35 @@
 {
     return m_opaque_sp;
 }
+
+bool
+SBValue::GetDescription (SBStream &description)
+{
+    if (m_opaque_sp)
+    {
+        const char *name = GetName();
+        const char *type_name = GetTypeName ();
+        size_t byte_size = GetByteSize ();
+        uint32_t num_children = GetNumChildren ();
+        bool is_stale = ValueIsStale ();
+        description.Printf ("name: '%s', type: %s, size: %d", (name != NULL ? name : "<unknown name>"),
+                            (type_name != NULL ? type_name : "<unknown type name>"), (int) byte_size);
+        if (num_children > 0)
+            description.Printf (", num_children: %d", num_children);
+
+        if (is_stale)
+            description.Printf (" [value is stale]");
+    }
+    else
+        description.Printf ("No value");
+
+    return true;
+}
+
+PyObject *
+SBValue::__repr__ ()
+{
+    SBStream description;
+    GetDescription (description);
+    return PyString_FromString (description.GetData());
+}

Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=114321&r1=114320&r2=114321&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 20 00:20:02 2010
@@ -236,6 +236,17 @@
     s->Printf(", Block{0x%8.8x}", GetID());
 }
 
+void
+Block::DumpAddressRanges (Stream *s, lldb::addr_t base_addr)
+{
+    if (!m_ranges.empty())
+    {
+        std::vector<VMRange>::const_iterator pos, end = m_ranges.end();
+        for (pos = m_ranges.begin(); pos != end; ++pos)
+            pos->Dump (s, base_addr);
+    }
+}
+
 bool
 Block::Contains (addr_t range_offset) const
 {





More information about the lldb-commits mailing list