LLDB mainline
ScriptedFrame.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_SCRIPTED_SCRIPTEDFRAME_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_SCRIPTED_SCRIPTEDFRAME_H
11
12#include "ScriptedThread.h"
15#include "lldb/lldb-forward.h"
16#include "llvm/Support/Error.h"
17#include <memory>
18#include <string>
19
20namespace lldb_private {
21
23
24public:
28 SymbolContext &sym_ctx, lldb::RegisterContextSP reg_ctx_sp,
29 StructuredData::GenericSP script_object_sp = nullptr);
30
31 ~ScriptedFrame() override;
32
33 /// Create a ScriptedFrame from a object instanciated in the script
34 /// interpreter.
35 ///
36 /// \param[in] thread_sp
37 /// The thread this frame belongs to.
38 ///
39 /// \param[in] scripted_thread_interface_sp
40 /// The scripted thread interface (needed for ScriptedThread
41 /// compatibility). Can be nullptr for frames on real threads.
42 ///
43 /// \param[in] args_sp
44 /// Arguments to pass to the frame creation.
45 ///
46 /// \param[in] script_object
47 /// The optional script object representing this frame.
48 ///
49 /// \return
50 /// An Expected containing the ScriptedFrame shared pointer if successful,
51 /// otherwise an error.
52 static llvm::Expected<std::shared_ptr<ScriptedFrame>>
53 Create(lldb::ThreadSP thread_sp,
54 lldb::ScriptedThreadInterfaceSP scripted_thread_interface_sp,
56 StructuredData::Generic *script_object = nullptr);
57
58 bool IsInlined() override;
59 bool IsArtificial() const override;
60 bool IsHidden() override;
61 const char *GetFunctionName() override;
62 const char *GetDisplayFunctionName() override;
63
65
66 VariableList *GetVariableList(bool get_file_globals,
67 bool include_synthetic_vars,
68 lldb_private::Status *error_ptr) override;
69
71 GetInScopeVariableList(bool get_file_globals, bool include_synthetic_vars,
72 bool must_have_valid_location = false) override;
73
76 lldb::DynamicValueType use_dynamic) override;
77
79
81 llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic,
82 uint32_t options, lldb::VariableSP &var_sp, Status &error,
83 lldb::DILMode mode = lldb::eDILModeFull) override;
84
85 bool isA(const void *ClassID) const override {
86 return ClassID == &ID || StackFrame::isA(ClassID);
87 }
88 static bool classof(const StackFrame *obj) { return obj->isA(&ID); }
89
90private:
93 static llvm::Expected<lldb::RegisterContextSP>
95 lldb::user_id_t frame_id);
96
97 // Populate m_variable_list_sp from the scripted frame interface. The boolean
98 // controls if we should try to fabricate Variable objects for each of the
99 // ValueObjects that we have. This defaults to 'true' because this is a
100 // scripted frame, so kind of the whole point is to provide synthetic
101 // variables to the user.
102 void PopulateVariableListFromInterface(bool include_synthetic_vars = true);
103
104 ScriptedFrame(const ScriptedFrame &) = delete;
105 const ScriptedFrame &operator=(const ScriptedFrame &) = delete;
106
107 std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo();
108
112
113 static char ID;
114};
115
116} // namespace lldb_private
117
118#endif // LLDB_SOURCE_PLUGINS_PROCESS_SCRIPTED_SCRIPTEDFRAME_H
static llvm::raw_ostream & error(Stream &strm)
A uniqued constant string class.
Definition ConstString.h:40
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.
lldb::ValueObjectSP FindVariable(ConstString name) override
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
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.
bool isA(const void *ClassID) const override
lldb::ScriptedFrameInterfaceSP GetInterface() const
void PopulateVariableListFromInterface(bool include_synthetic_vars=true)
void CheckInterpreterAndScriptObject() const
lldb::ScriptedFrameInterfaceSP m_scripted_frame_interface_sp
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)
ScriptedFrame(const ScriptedFrame &)=delete
const ScriptedFrame & operator=(const ScriptedFrame &)=delete
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 ...
static bool classof(const StackFrame *obj)
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()
This base class provides an interface to stack frames.
Definition StackFrame.h:44
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.
virtual bool isA(const void *ClassID) const
Definition StackFrame.h:49
An error handling class.
Definition Status.h:118
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Dictionary > DictionarySP
Defines a symbol context baton that can be handed other debug core functions.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ScriptedThreadInterface > ScriptedThreadInterfaceSP
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
DILMode
Data Inspection Language (DIL) evaluation modes.
@ eDILModeFull
Allowed: everything supported by DIL.
std::shared_ptr< lldb_private::ScriptedFrameInterface > ScriptedFrameInterfaceSP