Skip to content
Merged
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
12 changes: 0 additions & 12 deletions lldb/bindings/python/python-wrapper.swig
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,6 @@ 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
47 changes: 0 additions & 47 deletions lldb/examples/python/templates/scripted_frame_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,54 +31,7 @@ class ScriptedFrameProvider(metaclass=ABCMeta):
)
"""

@staticmethod
def applies_to_thread(thread):
"""Determine if this frame provider should be used for a given thread.

This static method is called before creating an instance of the frame
provider to determine if it should be applied to a specific thread.
Override this method to provide custom filtering logic.

Args:
thread (lldb.SBThread): The thread to check.

Returns:
bool: True if this frame provider should be used for the thread,
False otherwise. The default implementation returns True for
all threads.

Example:

.. code-block:: python

@staticmethod
def applies_to_thread(thread):
# Only apply to thread 1
return thread.GetIndexID() == 1
"""
return True

@staticmethod
@abstractmethod
def get_description():
"""Get a description of this frame provider.

This method should return a human-readable string describing what
this frame provider does. The description is used for debugging
and display purposes.

Returns:
str: A description of the frame provider.

Example:

.. code-block:: python

def get_description(self):
return "Crash log frame provider for thread 1"
"""
pass

def __init__(self, input_frames, args):
"""Construct a scripted frame provider.

Expand Down
47 changes: 16 additions & 31 deletions lldb/examples/python/templates/scripted_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def __init__(self, process, args):
key/value pairs used by the scripted thread.
"""
self.target = None
self.arch = None
self.originating_process = None
self.process = None
self.args = None
Expand All @@ -267,9 +266,6 @@ def __init__(self, process, args):
and process.IsValid()
):
self.target = process.target
triple = self.target.triple
if triple:
self.arch = triple.split("-")[0]
self.originating_process = process
self.process = self.target.GetProcess()
self.get_register_info()
Expand Down Expand Up @@ -356,14 +352,17 @@ def get_stackframes(self):
def get_register_info(self):
if self.register_info is None:
self.register_info = dict()
if "x86_64" in self.arch:
if "x86_64" in self.originating_process.arch:
self.register_info["sets"] = ["General Purpose Registers"]
self.register_info["registers"] = INTEL64_GPR
elif "arm64" in self.arch or self.arch == "aarch64":
elif (
"arm64" in self.originating_process.arch
or self.originating_process.arch == "aarch64"
):
self.register_info["sets"] = ["General Purpose Registers"]
self.register_info["registers"] = ARM64_GPR
else:
raise ValueError("Unknown architecture", self.arch)
raise ValueError("Unknown architecture", self.originating_process.arch)
return self.register_info

@abstractmethod
Expand Down Expand Up @@ -406,12 +405,11 @@ def __init__(self, thread, args):
"""Construct a scripted frame.

Args:
thread (ScriptedThread/lldb.SBThread): The thread owning this frame.
thread (ScriptedThread): The thread owning this frame.
args (lldb.SBStructuredData): A Dictionary holding arbitrary
key/value pairs used by the scripted frame.
"""
self.target = None
self.arch = None
self.originating_thread = None
self.thread = None
self.args = None
Expand All @@ -421,17 +419,15 @@ def __init__(self, thread, args):
self.register_ctx = {}
self.variables = []

if isinstance(thread, ScriptedThread) or (
isinstance(thread, lldb.SBThread) and thread.IsValid()
if (
isinstance(thread, ScriptedThread)
or isinstance(thread, lldb.SBThread)
and thread.IsValid()
):
self.target = thread.target
self.process = thread.process
self.target = self.process.target
triple = self.target.triple
if triple:
self.arch = triple.split("-")[0]
tid = thread.tid if isinstance(thread, ScriptedThread) else thread.id
self.originating_thread = thread
self.thread = self.process.GetThreadByIndexID(tid)
self.thread = self.process.GetThreadByIndexID(thread.tid)
self.get_register_info()

@abstractmethod
Expand Down Expand Up @@ -512,18 +508,7 @@ def get_variables(self, filters):

def get_register_info(self):
if self.register_info is None:
if isinstance(self.originating_thread, ScriptedThread):
self.register_info = self.originating_thread.get_register_info()
elif isinstance(self.originating_thread, lldb.SBThread):
self.register_info = dict()
if "x86_64" in self.arch:
self.register_info["sets"] = ["General Purpose Registers"]
self.register_info["registers"] = INTEL64_GPR
elif "arm64" in self.arch or self.arch == "aarch64":
self.register_info["sets"] = ["General Purpose Registers"]
self.register_info["registers"] = ARM64_GPR
else:
raise ValueError("Unknown architecture", self.arch)
self.register_info = self.originating_thread.get_register_info()
return self.register_info

@abstractmethod
Expand Down Expand Up @@ -657,12 +642,12 @@ def get_stop_reason(self):

# TODO: Passthrough stop reason from driving process
if self.driving_thread.GetStopReason() != lldb.eStopReasonNone:
if "arm64" in self.arch:
if "arm64" in self.originating_process.arch:
stop_reason["type"] = lldb.eStopReasonException
stop_reason["data"]["desc"] = (
self.driving_thread.GetStopDescription(100)
)
elif self.arch == "x86_64":
elif self.originating_process.arch == "x86_64":
stop_reason["type"] = lldb.eStopReasonSignal
stop_reason["data"]["signal"] = signal.SIGTRAP
else:
Expand Down
30 changes: 0 additions & 30 deletions lldb/include/lldb/API/SBTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBStatisticsOptions.h"
#include "lldb/API/SBSymbolContextList.h"
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBType.h"
#include "lldb/API/SBValue.h"
#include "lldb/API/SBWatchpoint.h"
Expand Down Expand Up @@ -987,35 +986,6 @@ class LLDB_API SBTarget {

lldb::SBMutex GetAPIMutex() const;

/// Register a scripted frame provider for this target.
/// If a scripted frame provider with the same name and same argument
/// dictionary is already registered on this target, it will be overwritten.
///
/// \param[in] class_name
/// The name of the Python class that implements the frame provider.
///
/// \param[in] args_dict
/// A dictionary of arguments to pass to the frame provider class.
///
/// \param[out] error
/// An error object indicating success or failure.
///
/// \return
/// A unique identifier for the frame provider descriptor that was
/// registered. 0 if the registration failed.
uint32_t RegisterScriptedFrameProvider(const char *class_name,
lldb::SBStructuredData args_dict,
lldb::SBError &error);

/// Remove a scripted frame provider from this target by name.
///
/// \param[in] provider_id
/// The id of the frame provider class to remove.
///
/// \return
/// An error object indicating success or failure.
lldb::SBError RemoveScriptedFrameProvider(uint32_t provider_id);

protected:
friend class SBAddress;
friend class SBAddressRange;
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/API/SBThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ class LLDB_API SBThread {
friend class SBThreadPlan;
friend class SBTrace;

friend class lldb_private::ScriptInterpreter;
friend class lldb_private::python::SWIGBridge;

SBThread(const lldb::ThreadSP &lldb_object_sp);
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/API/SBThreadCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LLDB_API SBThreadCollection {
void SetOpaque(const lldb::ThreadCollectionSP &threads);

private:
friend class SBTarget;
friend class SBProcess;
friend class SBThread;
friend class SBSaveCoreOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,11 @@
namespace lldb_private {
class ScriptedFrameProviderInterface : public ScriptedInterface {
public:
virtual bool AppliesToThread(llvm::StringRef class_name,
lldb::ThreadSP thread_sp) {
return true;
}

virtual llvm::Expected<StructuredData::GenericSP>
CreatePluginObject(llvm::StringRef class_name,
lldb::StackFrameListSP input_frames,
StructuredData::DictionarySP args_sp) = 0;

/// Get a description string for the frame provider.
///
/// This is called by the descriptor to fetch a description from the
/// scripted implementation. Implementations should call a static method
/// on the scripting class to retrieve the description.
///
/// \param class_name The name of the scripting class implementing the
/// provider.
///
/// \return A string describing what this frame provider does, or an
/// empty string if no description is available.
virtual std::string GetDescription(llvm::StringRef class_name) { return {}; }

virtual StructuredData::ObjectSP GetFrameAtIndex(uint32_t index) {
return {};
}
Expand Down
3 changes: 0 additions & 3 deletions lldb/include/lldb/Interpreter/ScriptInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBSymbolContext.h"
#include "lldb/API/SBThread.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/SearchFilter.h"
Expand Down Expand Up @@ -581,8 +580,6 @@ class ScriptInterpreter : public PluginInterface {

lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;

lldb::ThreadSP GetOpaqueTypeFromSBThread(const lldb::SBThread &exe_ctx) const;

lldb::StackFrameSP GetOpaqueTypeFromSBFrame(const lldb::SBFrame &frame) const;

SymbolContext
Expand Down
7 changes: 2 additions & 5 deletions lldb/include/lldb/Target/StackFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,8 @@ class StackFrame : public ExecutionContextScope,
/// frames are included in this frame index count.
uint32_t GetFrameIndex() const;

/// Set this frame's frame index.
void SetFrameIndex(uint32_t index) {
m_frame_index = index;
m_concrete_frame_index = index;
}
/// Set this frame's synthetic frame index.
void SetFrameIndex(uint32_t index) { m_frame_index = index; }

/// Query this frame to find what frame it is in this Thread's
/// StackFrameList, not counting inlined frames.
Expand Down
36 changes: 5 additions & 31 deletions lldb/include/lldb/Target/StackFrameList.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace lldb_private {

class ScriptedThread;

class StackFrameList : public std::enable_shared_from_this<StackFrameList> {
class StackFrameList {
public:
// Constructors and Destructors
StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames);

virtual ~StackFrameList();
~StackFrameList();

/// Get the number of visible frames. Frames may be created if \p can_create
/// is true. Synthetic (inline) frames expanded from the concrete frame #0
Expand Down Expand Up @@ -106,7 +106,6 @@ class StackFrameList : public std::enable_shared_from_this<StackFrameList> {

protected:
friend class Thread;
friend class ScriptedFrameProvider;
friend class ScriptedThread;

/// Use this API to build a stack frame list (used for scripted threads, for
Expand Down Expand Up @@ -212,51 +211,26 @@ class StackFrameList : public std::enable_shared_from_this<StackFrameList> {
/// Whether or not to show synthetic (inline) frames. Immutable.
const bool m_show_inlined_frames;

/// Returns true if fetching frames was interrupted, false otherwise.
virtual bool FetchFramesUpTo(uint32_t end_idx,
InterruptionControl allow_interrupt);

private:
uint32_t SetSelectedFrameNoLock(lldb_private::StackFrame *frame);
lldb::StackFrameSP
GetFrameAtIndexNoLock(uint32_t idx,
std::shared_lock<std::shared_mutex> &guard);

/// @{
/// These two Fetch frames APIs and SynthesizeTailCallFrames are called in
/// GetFramesUpTo, they are the ones that actually add frames. They must be
/// called with the writer end of the list mutex held.
///

/// Returns true if fetching frames was interrupted, false otherwise.
bool FetchFramesUpTo(uint32_t end_idx, InterruptionControl allow_interrupt);
/// Not currently interruptible so returns void.
/// }@
void FetchOnlyConcreteFramesUpTo(uint32_t end_idx);
void SynthesizeTailCallFrames(StackFrame &next_frame);

StackFrameList(const StackFrameList &) = delete;
const StackFrameList &operator=(const StackFrameList &) = delete;
};

/// A StackFrameList that wraps another StackFrameList and uses a
/// SyntheticFrameProvider to lazily provide frames from either the provider
/// or the underlying real stack frame list.
class SyntheticStackFrameList : public StackFrameList {
public:
SyntheticStackFrameList(Thread &thread, lldb::StackFrameListSP input_frames,
const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames);

protected:
/// Override FetchFramesUpTo to lazily return frames from the provider
/// or from the actual stack frame list.
bool FetchFramesUpTo(uint32_t end_idx,
InterruptionControl allow_interrupt) override;

private:
/// The input stack frame list that the provider transforms.
/// This could be a real StackFrameList or another SyntheticStackFrameList.
lldb::StackFrameListSP m_input_frames;
};

} // namespace lldb_private

#endif // LLDB_TARGET_STACKFRAMELIST_H
Loading
Loading