44llvm::Expected<std::shared_ptr<ScriptedFrame>>
49 if (!thread_sp || !thread_sp->IsValid())
50 return llvm::createStringError(
"invalid thread");
52 ProcessSP process_sp = thread_sp->GetProcess();
53 if (!process_sp || !process_sp->IsValid())
54 return llvm::createStringError(
"invalid process");
57 process_sp->GetTarget().GetDebugger().GetScriptInterpreter();
59 return llvm::createStringError(
"no script interpreter");
62 if (!scripted_frame_interface)
63 return llvm::createStringError(
"failed to create scripted frame interface");
65 llvm::StringRef frame_class_name;
69 if (scripted_thread_interface_sp) {
70 std::optional<std::string> class_name =
71 scripted_thread_interface_sp->GetScriptedFramePluginName();
72 if (!class_name || class_name->empty())
73 return llvm::createStringError(
74 "failed to get scripted frame class name");
75 frame_class_name = *class_name;
77 return llvm::createStringError(
78 "no script object provided and no scripted thread interface");
83 auto obj_or_err = scripted_frame_interface->CreatePluginObject(
84 frame_class_name, exe_ctx, args_sp, script_object);
87 return llvm::createStringError(
88 "failed to create script object: %s",
89 llvm::toString(obj_or_err.takeError()).c_str());
93 if (!owned_script_object_sp->IsValid())
94 return llvm::createStringError(
"created script object is invalid");
106 std::optional<SymbolContext> maybe_sym_ctx =
107 scripted_frame_interface->GetSymbolContext();
117 reg_ctx_sp = *regs_or_err;
119 return std::make_shared<ScriptedFrame>(thread_sp, scripted_frame_interface,
120 frame_id,
pc, sc, reg_ctx_sp,
121 owned_script_object_sp);
144 std::optional<std::string> function_name =
GetInterface()->GetFunctionName();
152 std::optional<std::string> function_name =
179 std::shared_ptr<DynamicRegisterInfo>>(
180 LLVM_PRETTY_FUNCTION,
"failed to get scripted frame registers info",
184 if (!thread_sp || !thread_sp->IsValid())
186 std::shared_ptr<DynamicRegisterInfo>>(
187 LLVM_PRETTY_FUNCTION,
188 "failed to get scripted frame registers info: invalid thread",
error,
191 ProcessSP process_sp = thread_sp->GetProcess();
192 if (!process_sp || !process_sp->IsValid())
194 std::shared_ptr<DynamicRegisterInfo>>(
195 LLVM_PRETTY_FUNCTION,
196 "failed to get scripted frame registers info: invalid process",
error,
200 process_sp->GetTarget().GetArchitecture());
203llvm::Expected<lldb::RegisterContextSP>
209 return llvm::createStringError(
210 "failed to get scripted frame registers info");
212 std::shared_ptr<DynamicRegisterInfo> register_info_sp =
214 *reg_info, thread.GetProcess()->GetTarget().GetArchitecture());
220 return llvm::createStringError(
221 "failed to get scripted frame registers data");
224 std::make_shared<DataBufferHeap>(reg_data->c_str(), reg_data->size()));
226 if (!data_sp->GetByteSize())
227 return llvm::createStringError(
"failed to copy raw registers data");
229 std::shared_ptr<RegisterContextMemory> reg_ctx_memory =
230 std::make_shared<RegisterContextMemory>(
233 reg_ctx_memory->SetAllRegisterData(data_sp);
234 reg_ctx_sp = reg_ctx_memory;
244 LLVM_PRETTY_FUNCTION,
245 "failed to get scripted frame registers context: invalid interface",
251 LLVM_PRETTY_FUNCTION,
252 "failed to get scripted frame registers context: invalid thread",
260 LLVM_PRETTY_FUNCTION,
261 "failed to get scripted frame registers context",
error,
279 bool must_have_valid_location) {
292 for (uint32_t i = 0, e = value_list_sp->GetSize(); i < e; ++i) {
314 return values->FindValueObjectByValueName(variable_sp->GetName().AsCString());
330 var_expr, options,
error);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
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=nullptr) const
Get the string value as a C string.
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()
virtual StructuredData::DictionarySP GetRegisterInfo()
virtual std::optional< std::string > GetRegisterContext()
~ScriptedFrame() override
lldb::VariableListSP m_variable_list_sp
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.
bool IsArtificial() const override
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
const char * GetFunctionName() override
Get the frame's demangled name.
VariableList * GetVariableList(bool get_file_globals, lldb_private::Status *error_ptr) override
Retrieve the list of variables whose scope either:
lldb::ScriptedFrameInterfaceSP GetInterface() const
lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location=false) override
Retrieve the list of variables that are in scope at this StackFrame's pc.
void PopulateVariableListFromInterface()
void CheckInterpreterAndScriptObject() const
lldb::ScriptedFrameInterfaceSP m_scripted_frame_interface_sp
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error) override
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
static llvm::Expected< lldb::RegisterContextSP > CreateRegisterContext(ScriptedFrameInterface &interface, Thread &thread, lldb::user_id_t frame_id)
ScriptedFrame(lldb::ThreadSP thread_sp, lldb::ScriptedFrameInterfaceSP interface_sp, lldb::user_id_t frame_idx, lldb::addr_t pc, SymbolContext &sym_ctx, lldb::RegisterContextSP reg_ctx_sp, StructuredData::GenericSP script_object_sp=nullptr)
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.
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.
std::shared_ptr< DynamicRegisterInfo > GetDynamicRegisterInfo()
static Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef error_msg, Status &error, LLDBLog log_category=LLDBLog::Process)
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.
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Dictionary > DictionarySP
Defines a symbol context baton that can be handed other debug core functions.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
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
std::shared_ptr< lldb_private::ScriptedFrameInterface > ScriptedFrameInterfaceSP