LLDB mainline
lldb_private::ScriptedPythonInterface Class Reference

#include <ScriptedPythonInterface.h>

Inheritance diagram for lldb_private::ScriptedPythonInterface:
[legend]

Classes

struct  AbstractMethodCheckerPayload

Public Types

enum class  AbstractMethodCheckerCases {
  eNotImplemented , eNotAllocated , eNotCallable , eUnknownArgumentCount ,
  eInvalidArgumentCount , eValid
}

Public Member Functions

 ScriptedPythonInterface (ScriptInterpreterPythonImpl &interpreter)
 ~ScriptedPythonInterface () override=default
llvm::Expected< FileSpecGetScriptedModulePath () override
llvm::Expected< std::map< llvm::StringLiteral, AbstractMethodCheckerPayload > > CheckAbstractMethodImplementation (const python::PythonDictionary &class_dict) const
template<typename... Args>
llvm::Expected< StructuredData::GenericSPCreatePluginObject (llvm::StringRef class_name, StructuredData::Generic *script_obj, Args... args)
template<typename T = StructuredData::ObjectSP, typename... Args>
CallStaticMethod (llvm::StringRef class_name, llvm::StringRef method_name, Status &error, Args &&...args)
 Call a static method on a Python class without creating an instance.
Public Member Functions inherited from lldb_private::ScriptedInterface
 ScriptedInterface ()=default
virtual ~ScriptedInterface ()=default
StructuredData::GenericSP GetScriptObjectInstance ()
virtual llvm::SmallVector< AbstractMethodRequirementGetAbstractMethodRequirements () const =0
llvm::SmallVector< llvm::StringLiteral > const GetAbstractMethods () const

Protected Member Functions

template<typename T = StructuredData::ObjectSP>
ExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<typename T = StructuredData::ObjectSP, typename... Args>
Dispatch (llvm::StringRef method_name, Status &error, Args &&...args)
template<typename... Args>
Status GetStatusFromMethod (llvm::StringRef method_name, Args &&...args)
template<typename T>
Transform (T object)
python::PythonObject Transform (bool arg)
python::PythonObject Transform (const Status &arg)
python::PythonObject Transform (Status &&arg)
python::PythonObject Transform (const StructuredDataImpl &arg)
python::PythonObject Transform (lldb::ExecutionContextRefSP arg)
python::PythonObject Transform (lldb::TargetSP arg)
python::PythonObject Transform (lldb::BreakpointSP arg)
python::PythonObject Transform (lldb::BreakpointLocationSP arg)
python::PythonObject Transform (lldb::ProcessSP arg)
python::PythonObject Transform (lldb::ThreadSP arg)
python::PythonObject Transform (lldb::StackFrameListSP arg)
python::PythonObject Transform (lldb::ThreadPlanSP arg)
python::PythonObject Transform (lldb::ProcessAttachInfoSP arg)
python::PythonObject Transform (lldb::ProcessLaunchInfoSP arg)
python::PythonObject Transform (Event *arg)
python::PythonObject Transform (const SymbolContext &arg)
python::PythonObject Transform (lldb::StreamSP arg)
python::PythonObject Transform (lldb::StackFrameSP arg)
python::PythonObject Transform (lldb::DataExtractorSP arg)
python::PythonObject Transform (lldb::DescriptionLevel arg)
python::PythonObject Transform (lldb::ValueObjectSP arg)
template<typename T, typename U>
void ReverseTransform (T &original_arg, U transformed_arg, Status &error)
template<typename T>
void ReverseTransform (T &original_arg, python::PythonObject transformed_arg, Status &error)
void ReverseTransform (bool &original_arg, python::PythonObject transformed_arg, Status &error)
template<std::size_t... I, typename... Args>
auto TransformTuple (const std::tuple< Args... > &args, std::index_sequence< I... >)
template<typename... Args>
auto TransformArgs (const std::tuple< Args... > &args)
template<typename T, typename U>
void TransformBack (T &original_arg, U transformed_arg, Status &error)
template<std::size_t... I, typename... Ts, typename... Us>
bool ReassignPtrsOrRefsArgs (std::tuple< Ts... > &original_args, std::tuple< Us... > &transformed_args, std::index_sequence< I... >)
template<typename... Ts, typename... Us>
bool ReassignPtrsOrRefsArgs (std::tuple< Ts... > &original_args, std::tuple< Us... > &transformed_args)
template<typename T, typename... Args>
void FormatArgs (std::string &fmt, T arg, Args... args) const
template<typename T>
void FormatArgs (std::string &fmt, T arg) const
void FormatArgs (std::string &fmt) const
template<>
Status ExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<>
EventExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<>
SymbolContext ExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<>
Status ExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<>
EventExtractValueFromPythonObject (python::PythonObject &p, Status &error)
template<>
SymbolContext ExtractValueFromPythonObject (python::PythonObject &p, Status &error)

Protected Attributes

ScriptInterpreterPythonImplm_interpreter
Protected Attributes inherited from lldb_private::ScriptedInterface
StructuredData::GenericSP m_object_instance_sp

Additional Inherited Members

Static Public Member Functions inherited from lldb_private::ScriptedInterface
template<typename Ret>
static Ret ErrorWithMessage (llvm::StringRef caller_name, llvm::StringRef error_msg, Status &error, LLDBLog log_category=LLDBLog::Process)
template<typename T = StructuredData::ObjectSP>
static bool CheckStructuredDataObject (llvm::StringRef caller, T obj, Status &error)
static bool CreateInstance (lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)

Detailed Description

Definition at line 27 of file ScriptedPythonInterface.h.

Member Enumeration Documentation

◆ AbstractMethodCheckerCases

Enumerator
eNotImplemented 
eNotAllocated 
eNotCallable 
eUnknownArgumentCount 
eInvalidArgumentCount 
eValid 

Definition at line 32 of file ScriptedPythonInterface.h.

Constructor & Destructor Documentation

◆ ScriptedPythonInterface()

◆ ~ScriptedPythonInterface()

lldb_private::ScriptedPythonInterface::~ScriptedPythonInterface ( )
overridedefault

Member Function Documentation

◆ CallStaticMethod()

template<typename T = StructuredData::ObjectSP, typename... Args>
T lldb_private::ScriptedPythonInterface::CallStaticMethod ( llvm::StringRef class_name,
llvm::StringRef method_name,
Status & error,
Args &&... args )
inline

Call a static method on a Python class without creating an instance.

This method resolves a Python class by name and calls a static method on it, returning the result. This is useful for calling class-level methods that don't require an instance.

Parameters
class_nameThe fully-qualified name of the Python class.
method_nameThe name of the static method to call.
errorOutput parameter to receive error information if the call fails.
argsArguments to pass to the static method.
Returns
The return value of the static method call, or an error value.

Definition at line 401 of file ScriptedPythonInterface.h.

References lldb_private::ScriptInterpreterPythonImpl::Locker::AcquireLock, error(), lldb_private::ScriptedInterface::ErrorWithMessage(), ExtractValueFromPythonObject(), lldb_private::ScriptInterpreterPythonImpl::Locker::FreeLock, lldb_private::Status::FromError(), m_interpreter, lldb_private::ScriptInterpreterPythonImpl::Locker::NoSTDIN, ReassignPtrsOrRefsArgs(), and TransformArgs().

Referenced by lldb_private::ScriptedFrameProviderPythonInterface::AppliesToThread(), lldb_private::ScriptedFrameProviderPythonInterface::GetDescription(), and lldb_private::ScriptedFrameProviderPythonInterface::GetPriority().

◆ CheckAbstractMethodImplementation()

◆ CreatePluginObject()

◆ Dispatch()

template<typename T = StructuredData::ObjectSP, typename... Args>
T lldb_private::ScriptedPythonInterface::Dispatch ( llvm::StringRef method_name,
Status & error,
Args &&... args )
inlineprotected

Definition at line 500 of file ScriptedPythonInterface.h.

References lldb_private::ScriptInterpreterPythonImpl::Locker::AcquireLock, error(), lldb_private::ScriptedInterface::ErrorWithMessage(), ExtractValueFromPythonObject(), lldb_private::ScriptInterpreterPythonImpl::Locker::FreeLock, lldb_private::Status::FromError(), lldb_private::ScriptedInterface::GetAbstractMethods(), m_interpreter, lldb_private::ScriptedInterface::m_object_instance_sp, lldb_private::ScriptInterpreterPythonImpl::Locker::NoSTDIN, ReassignPtrsOrRefsArgs(), and TransformArgs().

Referenced by lldb_private::ScriptedProcessPythonInterface::CreateBreakpoint(), lldb_private::OperatingSystemPythonInterface::CreateThread(), lldb_private::OperatingSystemPythonInterface::DoesPluginReportAllThreads(), lldb_private::ScriptedThreadPlanPythonInterface::ExplainsStop(), lldb_private::ScriptedProcessPythonInterface::GetCapabilities(), lldb_private::ScriptedBreakpointPythonInterface::GetDepth(), lldb_private::ScriptedFramePythonInterface::GetDisplayFunctionName(), lldb_private::ScriptedThreadPythonInterface::GetExtendedInfo(), lldb_private::ScriptedFrameProviderPythonInterface::GetFrameAtIndex(), lldb_private::ScriptedFramePythonInterface::GetFunctionName(), lldb_private::ScriptedFramePythonInterface::GetID(), lldb_private::ScriptedProcessPythonInterface::GetLoadedImages(), lldb_private::ScriptedBreakpointPythonInterface::GetLocationDescription(), lldb_private::ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(), lldb_private::ScriptedProcessPythonInterface::GetMetadata(), lldb_private::ScriptedThreadPythonInterface::GetName(), lldb_private::ScriptedFramePythonInterface::GetPC(), lldb_private::ScriptedProcessPythonInterface::GetProcessID(), lldb_private::ScriptedPlatformPythonInterface::GetProcessInfo(), lldb_private::ScriptedThreadPythonInterface::GetQueue(), lldb_private::ScriptedFramePythonInterface::GetRegisterContext(), lldb_private::ScriptedThreadPythonInterface::GetRegisterContext(), lldb_private::OperatingSystemPythonInterface::GetRegisterContextForTID(), lldb_private::ScriptedFramePythonInterface::GetRegisterInfo(), lldb_private::ScriptedThreadPythonInterface::GetRegisterInfo(), lldb_private::ScriptedThreadPlanPythonInterface::GetRunState(), lldb_private::ScriptedThreadPythonInterface::GetScriptedFramePluginName(), lldb_private::ScriptedProcessPythonInterface::GetScriptedThreadPluginName(), lldb_private::ScriptedBreakpointPythonInterface::GetShortHelp(), lldb_private::ScriptedThreadPythonInterface::GetStackFrames(), lldb_private::ScriptedThreadPythonInterface::GetState(), GetStatusFromMethod(), lldb_private::ScriptedThreadPlanPythonInterface::GetStopDescription(), lldb_private::ScriptedThreadPythonInterface::GetStopReason(), lldb_private::ScriptedFramePythonInterface::GetSymbolContext(), lldb_private::ScriptedThreadPythonInterface::GetThreadID(), lldb_private::OperatingSystemPythonInterface::GetThreadInfo(), lldb_private::ScriptedProcessPythonInterface::GetThreadsInfo(), lldb_private::ScriptedFramePythonInterface::GetValueObjectForVariableExpression(), lldb_private::ScriptedFramePythonInterface::GetVariables(), lldb_private::ScriptedStopHookPythonInterface::HandleStop(), lldb_private::ScriptedProcessPythonInterface::IsAlive(), lldb_private::ScriptedFramePythonInterface::IsArtificial(), lldb_private::ScriptedFramePythonInterface::IsHidden(), lldb_private::ScriptedFramePythonInterface::IsInlined(), lldb_private::ScriptedThreadPlanPythonInterface::IsStale(), lldb_private::ScriptedPlatformPythonInterface::ListProcesses(), lldb_private::ScriptedProcessPythonInterface::ReadMemoryAtAddress(), lldb_private::ScriptedBreakpointPythonInterface::ResolverCallback(), lldb_private::ScriptedThreadPlanPythonInterface::ShouldStop(), lldb_private::ScriptedBreakpointPythonInterface::WasHit(), and lldb_private::ScriptedProcessPythonInterface::WriteMemoryAtAddress().

◆ ExtractValueFromPythonObject() [1/7]

template<>
Status lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

◆ ExtractValueFromPythonObject() [2/7]

template<>
Event * lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

◆ ExtractValueFromPythonObject() [3/7]

template<>
SymbolContext lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

◆ ExtractValueFromPythonObject() [4/7]

template<typename T = StructuredData::ObjectSP>
T lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
inlineprotected

Definition at line 495 of file ScriptedPythonInterface.h.

References lldb_private::python::PythonObject::CreateStructuredObject(), and error().

Referenced by CallStaticMethod(), Dispatch(), ReverseTransform(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::BreakpointLocationSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::BreakpointLocationSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::BreakpointSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::BreakpointSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::DataExtractorSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::DataExtractorSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::DescriptionLevel >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::DescriptionLevel >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ExecutionContextRefSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ExecutionContextRefSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ProcessAttachInfoSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ProcessAttachInfoSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ProcessLaunchInfoSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ProcessLaunchInfoSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StackFrameListSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StackFrameListSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StackFrameSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StackFrameSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StreamSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::StreamSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ThreadSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ThreadSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ValueObjectListSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ValueObjectListSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ValueObjectSP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ValueObjectSP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< StructuredData::ArraySP >(), lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< StructuredData::ArraySP >(), ScriptedPythonInterface::ExtractValueFromPythonObject< StructuredData::DictionarySP >(), and lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject< StructuredData::DictionarySP >().

◆ ExtractValueFromPythonObject() [5/7]

template<>
Status lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

References error().

◆ ExtractValueFromPythonObject() [6/7]

template<>
Event * lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

References error().

◆ ExtractValueFromPythonObject() [7/7]

template<>
SymbolContext lldb_private::ScriptedPythonInterface::ExtractValueFromPythonObject ( python::PythonObject & p,
Status & error )
protected

References error().

◆ FormatArgs() [1/3]

void lldb_private::ScriptedPythonInterface::FormatArgs ( std::string & fmt) const
inlineprotected

Definition at line 731 of file ScriptedPythonInterface.h.

◆ FormatArgs() [2/3]

template<typename T>
void lldb_private::ScriptedPythonInterface::FormatArgs ( std::string & fmt,
T arg ) const
inlineprotected

Definition at line 727 of file ScriptedPythonInterface.h.

◆ FormatArgs() [3/3]

template<typename T, typename... Args>
void lldb_private::ScriptedPythonInterface::FormatArgs ( std::string & fmt,
T arg,
Args... args ) const
inlineprotected

Definition at line 722 of file ScriptedPythonInterface.h.

References FormatArgs().

Referenced by FormatArgs().

◆ GetScriptedModulePath()

◆ GetStatusFromMethod()

◆ ReassignPtrsOrRefsArgs() [1/2]

template<typename... Ts, typename... Us>
bool lldb_private::ScriptedPythonInterface::ReassignPtrsOrRefsArgs ( std::tuple< Ts... > & original_args,
std::tuple< Us... > & transformed_args )
inlineprotected

Definition at line 712 of file ScriptedPythonInterface.h.

References ReassignPtrsOrRefsArgs().

◆ ReassignPtrsOrRefsArgs() [2/2]

template<std::size_t... I, typename... Ts, typename... Us>
bool lldb_private::ScriptedPythonInterface::ReassignPtrsOrRefsArgs ( std::tuple< Ts... > & original_args,
std::tuple< Us... > & transformed_args,
std::index_sequence< I... >  )
inlineprotected

Definition at line 701 of file ScriptedPythonInterface.h.

References error(), and TransformBack().

Referenced by CallStaticMethod(), Dispatch(), and ReassignPtrsOrRefsArgs().

◆ ReverseTransform() [1/3]

◆ ReverseTransform() [2/3]

template<typename T>
void lldb_private::ScriptedPythonInterface::ReverseTransform ( T & original_arg,
python::PythonObject transformed_arg,
Status & error )
inlineprotected

Definition at line 666 of file ScriptedPythonInterface.h.

References error(), and ExtractValueFromPythonObject().

◆ ReverseTransform() [3/3]

template<typename T, typename U>
void lldb_private::ScriptedPythonInterface::ReverseTransform ( T & original_arg,
U transformed_arg,
Status & error )
inlineprotected

Definition at line 661 of file ScriptedPythonInterface.h.

References error().

Referenced by TransformBack().

◆ Transform() [1/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( bool arg)
inlineprotected

Definition at line 575 of file ScriptedPythonInterface.h.

◆ Transform() [2/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( const Status & arg)
inlineprotected

◆ Transform() [3/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( const StructuredDataImpl & arg)
inlineprotected

◆ Transform() [4/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( const SymbolContext & arg)
inlineprotected

◆ Transform() [5/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( Event * arg)
inlineprotected

◆ Transform() [6/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::BreakpointLocationSP arg)
inlineprotected

◆ Transform() [7/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::BreakpointSP arg)
inlineprotected

◆ Transform() [8/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::DataExtractorSP arg)
inlineprotected

◆ Transform() [9/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::DescriptionLevel arg)
inlineprotected

◆ Transform() [10/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ExecutionContextRefSP arg)
inlineprotected

◆ Transform() [11/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ProcessAttachInfoSP arg)
inlineprotected

◆ Transform() [12/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ProcessLaunchInfoSP arg)
inlineprotected

◆ Transform() [13/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ProcessSP arg)
inlineprotected

◆ Transform() [14/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::StackFrameListSP arg)
inlineprotected

◆ Transform() [15/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::StackFrameSP arg)
inlineprotected

◆ Transform() [16/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::StreamSP arg)
inlineprotected

◆ Transform() [17/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::TargetSP arg)
inlineprotected

◆ Transform() [18/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ThreadPlanSP arg)
inlineprotected

◆ Transform() [19/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ThreadSP arg)
inlineprotected

◆ Transform() [20/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( lldb::ValueObjectSP arg)
inlineprotected

◆ Transform() [21/22]

python::PythonObject lldb_private::ScriptedPythonInterface::Transform ( Status && arg)
inlineprotected

◆ Transform() [22/22]

template<typename T>
T lldb_private::ScriptedPythonInterface::Transform ( T object)
inlineprotected

Definition at line 570 of file ScriptedPythonInterface.h.

Referenced by TransformTuple().

◆ TransformArgs()

template<typename... Args>
auto lldb_private::ScriptedPythonInterface::TransformArgs ( const std::tuple< Args... > & args)
inlineprotected

Definition at line 691 of file ScriptedPythonInterface.h.

References TransformTuple().

Referenced by CallStaticMethod(), CreatePluginObject(), and Dispatch().

◆ TransformBack()

template<typename T, typename U>
void lldb_private::ScriptedPythonInterface::TransformBack ( T & original_arg,
U transformed_arg,
Status & error )
inlineprotected

Definition at line 696 of file ScriptedPythonInterface.h.

References error(), and ReverseTransform().

Referenced by ReassignPtrsOrRefsArgs().

◆ TransformTuple()

template<std::size_t... I, typename... Args>
auto lldb_private::ScriptedPythonInterface::TransformTuple ( const std::tuple< Args... > & args,
std::index_sequence< I... >  )
inlineprotected

Definition at line 683 of file ScriptedPythonInterface.h.

References Transform().

Referenced by TransformArgs().

Member Data Documentation

◆ m_interpreter


The documentation for this class was generated from the following files: