41#include "llvm/Support/ErrorHandling.h"
55llvm::Expected<std::shared_ptr<ScriptedFrame>>
60 if (!thread_sp || !thread_sp->IsValid())
61 return llvm::createStringError(
"invalid thread");
63 ProcessSP process_sp = thread_sp->GetProcess();
64 if (!process_sp || !process_sp->IsValid())
65 return llvm::createStringError(
"invalid process");
68 process_sp->GetTarget().GetDebugger().GetScriptInterpreter();
70 return llvm::createStringError(
"no script interpreter");
73 if (!scripted_frame_interface)
74 return llvm::createStringError(
"failed to create scripted frame interface");
76 llvm::StringRef frame_class_name;
80 if (scripted_thread_interface_sp) {
81 std::optional<std::string> class_name =
82 scripted_thread_interface_sp->GetScriptedFramePluginName();
83 if (!class_name || class_name->empty())
84 return llvm::createStringError(
85 "failed to get scripted frame class name");
86 frame_class_name = *class_name;
88 return llvm::createStringError(
89 "no script object provided and no scripted thread interface");
94 auto obj_or_err = scripted_frame_interface->CreatePluginObject(
95 frame_class_name, exe_ctx, args_sp, script_object);
98 return llvm::createStringError(
99 "failed to create script object: %s",
100 llvm::toString(obj_or_err.takeError()).c_str());
104 if (!owned_script_object_sp->IsValid())
105 return llvm::createStringError(
"created script object is invalid");
115 pc = process_sp->FixCodeAddress(
pc);
120 std::optional<SymbolContext> maybe_sym_ctx =
121 scripted_frame_interface->GetSymbolContext();
125 return std::make_shared<ScriptedFrame>(thread_sp, scripted_frame_interface,
126 frame_id,
pc, cfa, sc,
127 owned_script_object_sp);
144 llvm::Expected<lldb::RegisterContextSP> reg_ctx_or_err =
146 if (!reg_ctx_or_err) {
147 std::optional<lldb::user_id_t> debugger_id;
148 if (
ProcessSP process_sp = thread_sp->GetProcess())
149 debugger_id = process_sp->GetTarget().GetDebugger().GetID();
151 llvm::toString(reg_ctx_or_err.takeError()),
163 std::optional<std::string> function_name =
GetInterface()->GetFunctionName();
171 std::optional<std::string> function_name =
195 return llvm::createStringError(
196 "failed to get scripted frame registers info");
199 if (!thread_sp || !thread_sp->IsValid())
200 return llvm::createStringError(
"invalid thread");
202 ProcessSP process_sp = thread_sp->GetProcess();
203 if (!process_sp || !process_sp->IsValid())
204 return llvm::createStringError(
"invalid process");
207 *reg_info, process_sp->GetTarget().GetArchitecture());
208 if (!register_info_sp)
209 return llvm::createStringError(
210 "failed to create scripted frame registers info");
212 return register_info_sp;
217 return llvm::createStringError(
"invalid scripted frame interface");
221 return llvm::createStringError(
"invalid thread");
225 std::optional<std::string> reg_data =
231 std::make_shared<DataBufferHeap>(reg_data->c_str(), reg_data->size()));
233 if (!data_sp->GetByteSize())
234 return llvm::createStringError(
"failed to copy raw registers data");
236 llvm::Expected<DynamicRegisterInfoSP> register_info_or_err =
238 if (!register_info_or_err)
239 return register_info_or_err.takeError();
241 std::shared_ptr<RegisterContextMemory> reg_ctx_memory =
242 std::make_shared<RegisterContextMemory>(*thread_sp,
GetFrameIndex(),
243 std::move(*register_info_or_err),
246 reg_ctx_memory->SetAllRegisterData(data_sp);
248 return reg_ctx_memory;
256 bool include_synthetic_vars,
264 bool include_synthetic_vars,
265 bool must_have_valid_location) {
271 bool include_synthetic_vars) {
280 for (uint32_t i = 0, e = value_list_sp->GetSize(); i < e; ++i) {
299 v->GetName().GetCString(), v->GetName().GetCString(),
nullptr, vt,
315 variable_sp->GetName().AsCString(
nullptr));
320 variable_sp->GetScope());
330 values->FindValueObjectByValueName(name.
AsCString(
nullptr));
339 variable_sp->GetScope());
359 var_expr, options,
error);
362llvm::Expected<lldb::ThreadPlanSP>
364 llvm::Expected<ScriptedMetadata> metadata =
368 return metadata.takeError();
376 if (thread_sp && !metadata->GetClassName().empty()) {
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
static std::unique_ptr< DynamicRegisterInfo > Create(const StructuredData::Dictionary &dict, const ArchSpec &arch)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
virtual lldb::ScriptedFrameInterfaceSP CreateScriptedFrameInterface()
~ScriptedFrame() override
lldb::VariableListSP m_variable_list_sp
llvm::Expected< lldb::DynamicRegisterInfoSP > GetDynamicRegisterInfo()
static llvm::Expected< std::shared_ptr< ScriptedFrame > > Create(lldb::ThreadSP thread_sp, lldb::ScriptedThreadInterfaceSP scripted_thread_interface_sp, StructuredData::DictionarySP args_sp, StructuredData::Generic *script_object=nullptr)
Create a ScriptedFrame from a object instanciated in the script interpreter.
lldb::ValueObjectSP FindVariable(ConstString name) override
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
ScriptedFrame(lldb::ThreadSP thread_sp, lldb::ScriptedFrameInterfaceSP interface_sp, lldb::user_id_t frame_idx, lldb::addr_t pc, lldb::addr_t cfa, SymbolContext &sym_ctx, StructuredData::GenericSP script_object_sp=nullptr)
bool IsArtificial() const override
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error, lldb::DILMode mode=lldb::eDILModeFull) override
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
const char * GetFunctionName() override
Get the frame's demangled name.
lldb::ScriptedFrameInterfaceSP GetInterface() const
void PopulateVariableListFromInterface(bool include_synthetic_vars=true)
void CheckInterpreterAndScriptObject() const
lldb::ScriptedFrameInterfaceSP m_scripted_frame_interface_sp
llvm::Expected< lldb::ThreadPlanSP > GetThreadPlanForStepType(lldb::StepType step_type) override
lldb_private::StructuredData::GenericSP m_script_object_sp
lldb::RegisterContextSP GetRegisterContext() override
Get the RegisterContext for this frame, if possible.
bool IsHidden() override
Query whether this frame should be hidden from backtraces.
lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool include_synthetic_vars, bool must_have_valid_location=false) override
Retrieve the list of variables that are in scope at this StackFrame's pc.
VariableList * GetVariableList(bool get_file_globals, bool include_synthetic_vars, lldb_private::Status *error_ptr) override
Retrieve the list of variables whose scope either:
bool IsInlined() override
Query whether this frame is a concrete frame on the call stack, or if it is an inlined frame derived ...
const char * GetDisplayFunctionName() override
Get the frame's demangled display name.
lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic) override
Create a ValueObject for a given Variable in this StackFrame.
llvm::Expected< lldb::RegisterContextSP > CreateRegisterContext()
lldb::ThreadSP GetThread() const
virtual const char * GetFunctionName()
Get the frame's demangled name.
lldb::ThreadWP m_thread_wp
For StackFrame and derived classes only.
lldb::RegisterContextSP m_reg_context_sp
@ Synthetic
An synthetic stack frame (e.g.
virtual const char * GetDisplayFunctionName()
Get the frame's demangled display name.
virtual uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa, bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind, bool artificial, bool behaves_like_zeroth_frame, const SymbolContext *sc_ptr)
Construct a StackFrame object without supplying a RegisterContextSP.
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Dictionary > DictionarySP
Defines a symbol context baton that can be handed other debug core functions.
static lldb::ValueObjectSP Create(ValueObject &valobj, lldb::ValueType type)
RangeVector< lldb::addr_t, lldb::addr_t > RangeList
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
constexpr bool IsSyntheticValueType(lldb::ValueType vt)
Return true if vt represents a synthetic value, false if not.
constexpr lldb::ValueType GetSyntheticValueType(lldb::ValueType base)
Given a base value type, return a version that carries the synthetic bit.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::DynamicRegisterInfo > DynamicRegisterInfoSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::ScriptedThreadInterface > ScriptedThreadInterfaceSP
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
DILMode
Data Inspection Language (DIL) evaluation modes.
std::shared_ptr< lldb_private::ScriptedFrameInterface > ScriptedFrameInterfaceSP