diff options
author | Caroline Tice <ctice@apple.com> | 2010-09-20 05:20:02 +0000 |
---|---|---|
committer | Caroline Tice <ctice@apple.com> | 2010-09-20 05:20:02 +0000 |
commit | dde9cff32aee03e98a5ed91fc8425f241058c771 (patch) | |
tree | d207dc97f063865b8addf9c4b01d6cbed2386f9e /lldb/source/API/SBLineEntry.cpp | |
parent | fd02aa84dc5e5b96e44e1f93b4f57b206e6180b2 (diff) | |
download | bcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.tar.gz bcm5719-llvm-dde9cff32aee03e98a5ed91fc8425f241058c771.zip |
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.
llvm-svn: 114321
Diffstat (limited to 'lldb/source/API/SBLineEntry.cpp')
-rw-r--r-- | lldb/source/API/SBLineEntry.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index a35f94a8b54..27f01d5a2da 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/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()); +} |