aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
committerCaroline Tice <ctice@apple.com>2010-09-20 05:20:02 +0000
commit98f930f429160f9777f626c3ac6aa609f4e965d2 (patch)
tree77b842560db4cab879d1f4187b979e745cceb62b
parentcfaa3f64cbe8fbe3955bc79bd8a460b037c2d7b5 (diff)
downloadlldb-98f930f429160f9777f626c3ac6aa609f4e965d2.tar.gz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114321 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/lldb/API/SBAddress.h10
-rw-r--r--include/lldb/API/SBBlock.h10
-rw-r--r--include/lldb/API/SBBreakpoint.h11
-rw-r--r--include/lldb/API/SBBreakpointLocation.h11
-rw-r--r--include/lldb/API/SBCommandReturnObject.h10
-rw-r--r--include/lldb/API/SBCompileUnit.h10
-rw-r--r--include/lldb/API/SBDebugger.h10
-rw-r--r--include/lldb/API/SBDefines.h6
-rw-r--r--include/lldb/API/SBError.h10
-rw-r--r--include/lldb/API/SBEvent.h13
-rw-r--r--include/lldb/API/SBFileSpec.h10
-rw-r--r--include/lldb/API/SBFrame.h10
-rw-r--r--include/lldb/API/SBFunction.h10
-rw-r--r--include/lldb/API/SBInstruction.h10
-rw-r--r--include/lldb/API/SBLineEntry.h10
-rw-r--r--include/lldb/API/SBModule.h10
-rw-r--r--include/lldb/API/SBProcess.h10
-rw-r--r--include/lldb/API/SBStream.h13
-rw-r--r--include/lldb/API/SBSymbol.h9
-rw-r--r--include/lldb/API/SBSymbolContext.h10
-rw-r--r--include/lldb/API/SBTarget.h10
-rw-r--r--include/lldb/API/SBThread.h9
-rw-r--r--include/lldb/API/SBType.h10
-rw-r--r--include/lldb/API/SBValue.h9
-rw-r--r--include/lldb/Symbol/Block.h4
-rw-r--r--lldb.xcodeproj/project.pbxproj3
-rw-r--r--scripts/lldb.swig2
-rw-r--r--source/API/SBAddress.cpp22
-rw-r--r--source/API/SBBlock.cpp34
-rw-r--r--source/API/SBBreakpoint.cpp26
-rw-r--r--source/API/SBBreakpointLocation.cpp32
-rw-r--r--source/API/SBCommandReturnObject.cpp40
-rw-r--r--source/API/SBCompileUnit.cpp23
-rw-r--r--source/API/SBDebugger.cpp24
-rw-r--r--source/API/SBError.cpp28
-rw-r--r--source/API/SBEvent.cpp22
-rw-r--r--source/API/SBFileSpec.cpp28
-rw-r--r--source/API/SBFrame.cpp39
-rw-r--r--source/API/SBFunction.cpp23
-rw-r--r--source/API/SBLineEntry.cpp28
-rw-r--r--source/API/SBModule.cpp22
-rw-r--r--source/API/SBProcess.cpp27
-rw-r--r--source/API/SBSymbol.cpp23
-rw-r--r--source/API/SBSymbolContext.cpp20
-rw-r--r--source/API/SBTarget.cpp23
-rw-r--r--source/API/SBThread.cpp24
-rw-r--r--source/API/SBType.cpp48
-rw-r--r--source/API/SBValue.cpp33
-rw-r--r--source/Symbol/Block.cpp11
49 files changed, 822 insertions, 28 deletions
diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h
index 9032d2046..d9d4ace70 100644
--- a/include/lldb/API/SBAddress.h
+++ b/include/lldb/API/SBAddress.h
@@ -44,6 +44,16 @@ public:
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;
diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h
index efab64295..c49c9a17a 100644
--- a/include/lldb/API/SBBlock.h
+++ b/include/lldb/API/SBBlock.h
@@ -49,6 +49,16 @@ public:
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;
diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h
index de2d478ca..b24515b6a 100644
--- a/include/lldb/API/SBBreakpoint.h
+++ b/include/lldb/API/SBBreakpoint.h
@@ -104,8 +104,8 @@ public:
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 @@ public:
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;
diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h
index fc866546f..32e83f245 100644
--- a/include/lldb/API/SBBreakpointLocation.h
+++ b/include/lldb/API/SBBreakpointLocation.h
@@ -68,12 +68,19 @@ public:
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;
diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h
index 6ce8bfbee..5d52dc1c2 100644
--- a/include/lldb/API/SBCommandReturnObject.h
+++ b/include/lldb/API/SBCommandReturnObject.h
@@ -58,6 +58,16 @@ public:
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;
diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h
index 43be8192e..5c7d6a45f 100644
--- a/include/lldb/API/SBCompileUnit.h
+++ b/include/lldb/API/SBCompileUnit.h
@@ -50,6 +50,16 @@ public:
#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;
diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h
index ff14931fd..3f119073e 100644
--- a/include/lldb/API/SBDebugger.h
+++ b/include/lldb/API/SBDebugger.h
@@ -154,6 +154,16 @@ public:
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;
diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h
index 703b111b7..3a2ad79b7 100644
--- a/include/lldb/API/SBDefines.h
+++ b/include/lldb/API/SBDefines.h
@@ -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 SBListener;
class SBModule;
class SBProcess;
class SBSourceManager;
+class SBStream;
class SBStringList;
class SBSymbol;
class SBSymbolContext;
diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h
index 12a4de1b1..3fedd13ff 100644
--- a/include/lldb/API/SBError.h
+++ b/include/lldb/API/SBError.h
@@ -65,6 +65,16 @@ public:
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;
diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h
index 0ae23dde1..9f6a42505 100644
--- a/include/lldb/API/SBEvent.h
+++ b/include/lldb/API/SBEvent.h
@@ -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 @@ public:
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;
diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h
index ffbeba87a..fa8564df2 100644
--- a/include/lldb/API/SBFileSpec.h
+++ b/include/lldb/API/SBFileSpec.h
@@ -51,6 +51,16 @@ public:
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;
diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h
index edafcfb97..ae12452e6 100644
--- a/include/lldb/API/SBFrame.h
+++ b/include/lldb/API/SBFrame.h
@@ -112,6 +112,16 @@ public:
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;
diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h
index 6f4a90a2d..4e7ae8081 100644
--- a/include/lldb/API/SBFunction.h
+++ b/include/lldb/API/SBFunction.h
@@ -39,6 +39,16 @@ public:
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;
diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h
index 4d3af965b..0461ce34e 100644
--- a/include/lldb/API/SBInstruction.h
+++ b/include/lldb/API/SBInstruction.h
@@ -46,6 +46,16 @@ public:
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;
diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h
index 68fba3e19..619884ed3 100644
--- a/include/lldb/API/SBLineEntry.h
+++ b/include/lldb/API/SBLineEntry.h
@@ -58,6 +58,16 @@ public:
#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;
diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h
index 559e94bd2..6231d13a3 100644
--- a/include/lldb/API/SBModule.h
+++ b/include/lldb/API/SBModule.h
@@ -49,6 +49,16 @@ public:
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;
diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h
index 98962717d..3543ee1e9 100644
--- a/include/lldb/API/SBProcess.h
+++ b/include/lldb/API/SBProcess.h
@@ -152,6 +152,16 @@ public:
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;
diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h
index abc4afdd0..6c46c1a04 100644
--- a/include/lldb/API/SBStream.h
+++ b/include/lldb/API/SBStream.h
@@ -55,6 +55,19 @@ public:
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
diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h
index f939bfa4a..a51cb424c 100644
--- a/include/lldb/API/SBSymbol.h
+++ b/include/lldb/API/SBSymbol.h
@@ -40,6 +40,15 @@ public:
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;
diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h
index db6555e08..659683f91 100644
--- a/include/lldb/API/SBSymbolContext.h
+++ b/include/lldb/API/SBSymbolContext.h
@@ -71,6 +71,16 @@ protected:
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;
};
diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h
index 97ddcccd0..1b4c09ab3 100644
--- a/include/lldb/API/SBTarget.h
+++ b/include/lldb/API/SBTarget.h
@@ -142,6 +142,16 @@ public:
#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;
diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h
index 2a9dd2a4d..ead395ae5 100644
--- a/include/lldb/API/SBThread.h
+++ b/include/lldb/API/SBThread.h
@@ -88,6 +88,15 @@ public:
#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;
diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h
index 0008c487f..c74598936 100644
--- a/include/lldb/API/SBType.h
+++ b/include/lldb/API/SBType.h
@@ -54,6 +54,16 @@ public:
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;
diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h
index 2c817fff5..78b4ea9bb 100644
--- a/include/lldb/API/SBValue.h
+++ b/include/lldb/API/SBValue.h
@@ -85,6 +85,15 @@ public:
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;
diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h
index 53fb741da..ff1d503b2 100644
--- a/include/lldb/Symbol/Block.h
+++ b/include/lldb/Symbol/Block.h
@@ -185,6 +185,10 @@ public:
DumpSymbolContext(Stream *s);
void
+ DumpAddressRanges (Stream *s,
+ lldb::addr_t base_addr);
+
+ void
GetDescription (Stream *s,
Function *function,
lldb::DescriptionLevel level,
diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index b491e4224..23839b5ff 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/lldb.xcodeproj/project.pbxproj
@@ -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)";
diff --git a/scripts/lldb.swig b/scripts/lldb.swig
index 32b387e08..adaa09484 100644
--- a/scripts/lldb.swig
+++ b/scripts/lldb.swig
@@ -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 @@ typedef int StopReason;
%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"
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index 61e1ec152..bcf387f70 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -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 @@ SBAddress::operator*() const
}
+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());
+}
diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp
index 961e8d846..5d6172b61 100644
--- a/source/API/SBBlock.cpp
+++ b/source/API/SBBlock.cpp
@@ -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 @@ SBBlock::GetFirstChild ()
}
+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());
+}
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index 1e3c71238..aa84575be 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -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 @@ SBBreakpoint::GetNumLocations() const
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 @@ SBBreakpoint::GetDescription (FILE *f, const char *description_level)
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
diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp
index 948b78f0c..f7e059ba9 100644
--- a/source/API/SBBreakpointLocation.cpp
+++ b/source/API/SBBreakpointLocation.cpp
@@ -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 @@ SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_s
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 @@ SBBreakpointLocation::GetDescription (FILE *f, const char *description_level)
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
diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp
index 5742c5c93..458ce504e 100644
--- a/source/API/SBCommandReturnObject.cpp
+++ b/source/API/SBCommandReturnObject.cpp
@@ -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 @@ SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr)
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());
+}
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index dc873e365..24a686d88 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -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 @@ SBCompileUnit::operator*() const
{
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());
+}
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index 0f12890aa..acf98dd8f 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -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 @@ SBDebugger::UseExternalEditor ()
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());
+}
diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp
index e91c94d2c..136561981 100644
--- a/source/API/SBError.cpp
+++ b/source/API/SBError.cpp
@@ -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 @@ SBError::operator*() const
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());
+}
diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp
index 543383b1a..0799b8bad 100644
--- a/source/API/SBEvent.cpp
+++ b/source/API/SBEvent.cpp
@@ -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 @@ SBEvent::GetCStringFromEvent (const SBEvent &event)
}
+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());
+}
diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp
index 5ec93f3b4..1edd9468b 100644
--- a/source/API/SBFileSpec.cpp
+++ b/source/API/SBFileSpec.cpp
@@ -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 @@ SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs)
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());
+}
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 5d9bd6e01..90952691d 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -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 @@ SBFrame::LookupVar (const char *var_name)
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 @@ SBFrame::LookupVarInScope (const char *var_name, const char *scope)
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 @@ SBFrame::GetRegisters ()
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());
+}
diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index c4beff1a1..210340ef2 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -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 @@ SBFunction::operator != (const SBFunction &rhs) const
{
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());
+}
diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp
index a35f94a8b..27f01d5a2 100644
--- a/source/API/SBLineEntry.cpp
+++ b/source/API/SBLineEntry.cpp
@@ -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 @@ SBLineEntry::operator*() const
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());
+}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index e338101c4..a0b340a9c 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -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 @@ SBModule::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolv
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());
+}
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index 0cae975de..d2c85ba90 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -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 @@ SBProcess::get() const
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());
+}
diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp
index 502efaa09..3c700e170 100644
--- a/source/API/SBSymbol.cpp
+++ b/source/API/SBSymbol.cpp
@@ -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 @@ SBSymbol::operator != (const SBSymbol &rhs) const
{
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());
+}
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index 1c2b52c6a..4381994c7 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -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 @@ SBSymbolContext::get() const
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());
+}
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 9e5c1ab27..f779c33b8 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -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 @@ SBTarget::Disassemble (const char *function_name, const char *module_name)
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());
+}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 3c75e4d68..aa621fb13 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -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 @@ SBThread::operator*()
{
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());
+}
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 1a44633d1..d34e94a14 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -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 @@ SBType::GetPointeeType ()
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),
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index e9d970baf..e2fdffab5 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -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 @@ SBValue::operator*() const
{
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());
+}
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index a2193891c..1731bf466 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -236,6 +236,17 @@ Block::DumpSymbolContext(Stream *s)
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
{