14#include "llvm/Support/ErrorExtras.h"
26 if (valobj_sp->GetNumChildrenIgnoringErrors() != 1)
31 if (!ptr_sp->GetCompilerType().IsPointerType())
34 auto [frame_ptr_addr, addr_type] = ptr_sp->GetPointerValue();
41 return frame_ptr_addr;
47 auto ptr_size = process_sp->GetAddressByteSize();
50 auto destroy_func_ptr_addr = frame_ptr_addr + ptr_size;
52 process_sp->ReadPointerFromMemory(destroy_func_ptr_addr,
error);
57 if (!target_sp->ResolveLoadAddress(destroy_func_addr, destroy_func_address))
73 auto var = variable_list->FindVariable(var_name);
76 if (!var->IsArtificial())
79 Type *promise_type = var->GetType();
92 if (frame_ptr_addr == 0) {
95 stream.
Printf(
"coro frame = 0x%" PRIx64, frame_ptr_addr);
134 auto &exe_ctx =
m_backend.GetExecutionContextRef();
136 auto ptr_size = process_sp->GetAddressByteSize();
137 auto ast_ctx = valobj_sp->GetCompilerType().GetTypeSystem<
TypeSystemClang>();
148 valobj_sp->GetCompilerType().GetTypeTemplateArgument(0))
149 promise_type = std::move(template_arg);
155 promise_type = inferred_type;
161 if (!coro_frame_type)
162 coro_frame_type = void_type;
165 std::array<CompilerType, 1> args{coro_frame_type};
166 CompilerType coro_func_type = ast_ctx->CreateFunctionType(
171 "resume", frame_ptr_addr + 0 * ptr_size, exe_ctx, coro_func_ptr_type);
172 assert(resume_ptr_sp);
173 m_children.push_back(std::move(resume_ptr_sp));
175 "destroy", frame_ptr_addr + 1 * ptr_size, exe_ctx, coro_func_ptr_type);
176 assert(destroy_ptr_sp);
177 m_children.push_back(std::move(destroy_ptr_sp));
186 "promise", frame_ptr_addr + 2 * ptr_size, exe_ctx,
188 m_children.push_back(std::move(promise_ptr_sp));
190 "coro_frame", frame_ptr_addr, exe_ctx, coro_frame_type.
GetPointerType(),
192 m_children.push_back(std::move(coroframe_ptr_sp));
197llvm::Expected<size_t>
200 for (
const auto &[idx, child_sp] : llvm::enumerate(
m_children)) {
201 if (child_sp->GetName() == name)
205 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
static llvm::raw_ostream & error(Stream &strm)
static CompilerType InferArtificialCoroType(Function *destroy_func, ConstString var_name)
static Function * ExtractDestroyFunction(lldb::TargetSP target_sp, lldb::addr_t frame_ptr_addr)
static lldb::addr_t GetCoroFramePtrFromHandle(ValueObjectSP valobj_sp)
A section + offset based address class.
Function * CalculateSymbolContextFunction() const
A class that describes a single lexical block.
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
A class that describes a function.
Block & GetBlock(bool can_create)
Get accessor for the block list.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
A TypeSystem implementation based on Clang.
CompilerType GetForwardCompilerType()
virtual lldb::ValueObjectSP GetNonSyntheticValue()
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Target > TargetSP