Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lldb/bindings/interface/SBFrameListExtensions.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%extend lldb::SBFrameList {

#ifdef SWIGPYTHON
%nothreadallow;
#endif
std::string lldb::SBFrameList::__str__ (){
lldb::SBStream description;
if (!$self->GetDescription(description))
return std::string("<empty> lldb.SBFrameList()");
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;
return std::string(desc, desc_len);
}
#ifdef SWIGPYTHON
%clearnothreadallow;
#endif

#ifdef SWIGPYTHON
%pythoncode %{
def __iter__(self):
'''Iterate over all frames in a lldb.SBFrameList object.'''
return lldb_iter(self, 'GetSize', 'GetFrameAtIndex')

def __len__(self):
return int(self.GetSize())

def __getitem__(self, key):
if type(key) is not int:
return None
if key < 0:
count = len(self)
if -count <= key < count:
key %= count

frame = self.GetFrameAtIndex(key)
return frame if frame.IsValid() else None
%}
#endif
}
3 changes: 2 additions & 1 deletion lldb/bindings/interface/SBThreadExtensions.i
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ STRING_EXTENSION_OUTSIDE(SBThread)
def get_thread_frames(self):
'''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.'''
frames = []
for frame in self:
frame_list = self.GetFrames()
for frame in frame_list:
frames.append(frame)
return frames

Expand Down
2 changes: 2 additions & 0 deletions lldb/bindings/interfaces.swig
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
%include "lldb/API/SBFileSpecList.h"
%include "lldb/API/SBFormat.h"
%include "lldb/API/SBFrame.h"
%include "lldb/API/SBFrameList.h"
%include "lldb/API/SBFunction.h"
%include "lldb/API/SBHostOS.h"
%include "lldb/API/SBInstruction.h"
Expand Down Expand Up @@ -192,6 +193,7 @@
%include "./interface/SBFileSpecExtensions.i"
%include "./interface/SBFileSpecListExtensions.i"
%include "./interface/SBFrameExtensions.i"
%include "./interface/SBFrameListExtensions.i"
%include "./interface/SBFunctionExtensions.i"
%include "./interface/SBInstructionExtensions.i"
%include "./interface/SBInstructionListExtensions.i"
Expand Down
1 change: 1 addition & 0 deletions lldb/bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
"plugins"
FILES
"${LLDB_SOURCE_DIR}/examples/python/templates/parsed_cmd.py"
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_frame_provider.py"
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py"
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py"
"${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py"
Expand Down
5 changes: 5 additions & 0 deletions lldb/bindings/python/python-swigsafecast.swig
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
SWIGTYPE_p_lldb__SBThreadPlan);
}

PythonObject SWIGBridge::ToSWIGWrapper(lldb::StackFrameListSP frames_sp) {
return ToSWIGHelper(new lldb::SBFrameList(std::move(frames_sp)),
SWIGTYPE_p_lldb__SBFrameList);
}

PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
return ToSWIGHelper(new lldb::SBBreakpoint(std::move(breakpoint_sp)),
SWIGTYPE_p_lldb__SBBreakpoint);
Expand Down
24 changes: 24 additions & 0 deletions lldb/bindings/python/python-wrapper.swig
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,18 @@ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *
return sb_ptr;
}

void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBThread(PyObject * data) {
lldb::SBThread *sb_ptr = nullptr;

int valid_cast =
SWIG_ConvertPtr(data, (void **)&sb_ptr, SWIGTYPE_p_lldb__SBThread, 0);

if (valid_cast == -1)
return NULL;

return sb_ptr;
}

void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrame(PyObject * data) {
lldb::SBFrame *sb_ptr = nullptr;

Expand Down Expand Up @@ -556,6 +568,18 @@ void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyOb
return sb_ptr;
}

void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrameList(PyObject *data) {
lldb::SBFrameList *sb_ptr = NULL;

int valid_cast = SWIG_ConvertPtr(data, (void **)&sb_ptr,
SWIGTYPE_p_lldb__SBFrameList, 0);

if (valid_cast == -1)
return NULL;

return sb_ptr;
}

bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
const char *python_function_name, const char *session_dictionary_name,
lldb::DebuggerSP debugger, const char *args,
Expand Down
Loading