[Lldb-commits] [lldb] r149466 - in /lldb/trunk/scripts/Python: interface/SBThread.i python-extensions.swig
Greg Clayton
gclayton at apple.com
Tue Jan 31 18:30:27 PST 2012
Author: gclayton
Date: Tue Jan 31 20:30:27 2012
New Revision: 149466
URL: http://llvm.org/viewvc/llvm-project?rev=149466&view=rev
Log:
Added a new convenience property on lldb.SBThread names "frames" which always returns a complete list of all lldb.SBFrame objects:
(lldb) script
>>> frames = lldb.thread.frames
>>> for frame in frames:
... print frame
Also changed all of the "__repr__" methods to strip any trailing newline characters so we don't end up with entra newlines.
Modified:
lldb/trunk/scripts/Python/interface/SBThread.i
lldb/trunk/scripts/Python/python-extensions.swig
Modified: lldb/trunk/scripts/Python/interface/SBThread.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=149466&r1=149465&r2=149466&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBThread.i (original)
+++ lldb/trunk/scripts/Python/interface/SBThread.i Tue Jan 31 20:30:27 2012
@@ -175,6 +175,13 @@
GetDescription (lldb::SBStream &description) const;
%pythoncode %{
+ def get_thread_frames(self):
+ frames = []
+ for frame in self:
+ frames.append(frame)
+ return frames
+
+
__swig_getmethods__["id"] = GetThreadID
if _newclass: x = property(GetThreadID, None)
@@ -190,6 +197,9 @@
__swig_getmethods__["num_frames"] = GetNumFrames
if _newclass: x = property(GetNumFrames, None)
+ __swig_getmethods__["frames"] = get_thread_frames
+ if _newclass: x = property(get_thread_frames, None)
+
__swig_getmethods__["name"] = GetName
if _newclass: x = property(GetName, None)
Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=149466&r1=149465&r2=149466&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Tue Jan 31 20:30:27 2012
@@ -3,182 +3,338 @@
PyObject *lldb::SBAddress::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBBlock {
PyObject *lldb::SBBlock::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBBreakpoint {
PyObject *lldb::SBBreakpoint::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBBreakpointLocation {
PyObject *lldb::SBBreakpointLocation::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelFull);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBCommandReturnObject {
PyObject *lldb::SBCommandReturnObject::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBCompileUnit {
PyObject *lldb::SBCompileUnit::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBData {
PyObject *lldb::SBData::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBDebugger {
PyObject *lldb::SBDebugger::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBError {
PyObject *lldb::SBError::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBFileSpec {
PyObject *lldb::SBFileSpec::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBFrame {
PyObject *lldb::SBFrame::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBFunction {
PyObject *lldb::SBFunction::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBInstruction {
PyObject *lldb::SBInstruction::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBInstructionList {
PyObject *lldb::SBInstructionList::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBLineEntry {
PyObject *lldb::SBLineEntry::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBModule {
PyObject *lldb::SBModule::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBProcess {
PyObject *lldb::SBProcess::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBSection {
PyObject *lldb::SBSection::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBSymbol {
PyObject *lldb::SBSymbol::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBSymbolContext {
PyObject *lldb::SBSymbolContext::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBTarget {
PyObject *lldb::SBTarget::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBType {
PyObject *lldb::SBType::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBTypeMember {
PyObject *lldb::SBTypeMember::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelBrief);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBThread {
PyObject *lldb::SBThread::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBValue {
PyObject *lldb::SBValue::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
%extend lldb::SBWatchpoint {
PyObject *lldb::SBWatchpoint::__repr__ (){
lldb::SBStream description;
$self->GetDescription (description, lldb::eDescriptionLevelVerbose);
- return PyString_FromString (description.GetData());
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ if (desc_len > 0)
+ return PyString_FromStringAndSize (desc, desc_len);
+ return Py_None;
}
}
More information about the lldb-commits
mailing list