23#include "llvm/Support/Error.h"
24#include "llvm/Support/ErrorExtras.h"
31 bool need_add_dot =
true;
32 if (path[0] ==
'.' || (path[0] ==
'-' && path[1] ==
'>') || path[0] ==
'[')
42 const std::string &path) {
45 bool need_add_dot =
true;
46 if (path[0] ==
'.' || (path[0] ==
'-' && path[1] ==
'>') || path[0] ==
'[')
60 for (
size_t i = 0; i <
filter->GetCount(); i++) {
61 const char *expr_cstr =
filter->GetExpressionPathAtIndex(i);
63 if (*expr_cstr ==
'.')
65 else if (*expr_cstr ==
'-' && *(expr_cstr + 1) ==
'>')
69 if (!::strcmp(name_cstr, expr_cstr))
74 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
83 for (
size_t i = 0; i <
GetCount(); i++) {
126 return *value_or_err;
133 llvm::StringRef name, llvm::StringRef expression,
138 valobj_sp->SetSyntheticChildrenGenerated(
true);
146 name, address, exe_ctx, type, do_deref));
148 valobj_sp->SetSyntheticChildrenGenerated(
true);
158 valobj_sp->SetSyntheticChildrenGenerated(
true);
174 m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
195llvm::Expected<uint32_t>
202llvm::Expected<uint32_t>
225llvm::Expected<size_t>
228 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
249 sstr.
Printf(
"%s%s%s Python class %s",
Cascades() ?
"" :
" (not cascading)",
262 m_init_results = std::move(data);
271 "@init failed: {0}");
288 control, data, FormatterBytecode::sig_update);
291 "@update failed: {0}");
295 std::optional<ChildCacheState> can_reuse = std::nullopt;
297 if (
auto *u = std::get_if<uint64_t>(&top))
298 if (*u == 0 || *u == 1)
300 if (
auto *i = std::get_if<int64_t>(&top))
301 if (*i == 0 || *i == 1)
308 "Bytecode formatter can reuse @update: {0} (type: `{1}`, name: `{2}`)",
309 can_reuse ?
"true" :
"false",
m_backend.GetDisplayTypeName(),
313 "Bytecode formatter did not return a valid reuse response from "
314 "@update (type: `{1}`, name: `{2}`)",
324llvm::Expected<uint32_t>
332 control, data, FormatterBytecode::sig_get_num_children);
336 if (data.size() == 0) {
337 char message[] =
"@get_num_children returned empty data stack";
339 return llvm::createStringError(message);
343 if (
auto *u = std::get_if<uint64_t>(&top))
346 if (
auto *i = std::get_if<int64_t>(&top)) {
352 return llvm::createStringError(
"@get_num_children returned invalid value");
357 if (!
m_impl.get_child_at_index)
361 m_impl.get_child_at_index->getBuffer()};
363 data.emplace_back((uint64_t)idx);
365 control, data, FormatterBytecode::sig_get_child_at_index);
368 "@get_child_at_index failed: {0}");
372 if (data.size() == 0) {
374 "@get_child_at_index returned empty data stack");
379 if (
auto *child = std::get_if<ValueObjectSP>(&top))
385llvm::Expected<size_t>
387 if (
m_impl.get_child_index)
391 m_impl.get_child_index->getBuffer()};
395 control, data, FormatterBytecode::sig_get_child_index);
399 if (data.size() == 0) {
400 char message[] =
"@get_child_index returned empty data stack";
402 return llvm::createStringError(message);
406 if (
auto *u = std::get_if<uint64_t>(&top))
409 if (
auto *i = std::get_if<int64_t>(&top)) {
410 if (*i > 0 &&
static_cast<uint64_t
>(*i) <= SIZE_MAX)
415 return llvm::createStringError(
"@get_child_index returned invalid value");
420 sstr.
Printf(
"%s%s%s Bytecode synthetic",
Cascades() ?
"" :
" (not cascading)",
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERRORV(log, error,...)
#define LLDB_LOG_ERROR(log, error,...)
FrontEnd(ValueObject &backend, SyntheticBytecodeImplementation &impl)
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override
llvm::Expected< size_t > GetIndexOfChildWithName(ConstString name) override
Determine the index of a named child.
llvm::Expected< uint32_t > CalculateNumChildren() override
const SyntheticBytecodeImplementation & m_impl
FormatterBytecode::DataStack m_init_results
lldb::ChildCacheState Update() override
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
FormatterBytecode::DataStack m_self
std::string GetDescription() override
CreateFrontEndCallback m_create_callback
virtual ~CXXSyntheticChildren()
std::string m_description
std::string GetDescription() override
CXXSyntheticChildren(const SyntheticChildren::Flags &flags, const char *description, CreateFrontEndCallback callback)
std::function< SyntheticChildrenFrontEnd *(CXXSyntheticChildren *, lldb::ValueObjectSP)> CreateFrontEndCallback
Generic representation of a type in a programming language.
A uniqued constant string class.
std::string GetString() const
Get the string value as a std::string.
const char * GetCString() const
Get the string value as a C string.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
lldb::ChildCacheState Update() override
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
std::string m_python_class
llvm::Expected< size_t > GetIndexOfChildWithName(ConstString name) override
Determine the index of a named child.
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override
ScriptInterpreter * m_interpreter
FrontEnd(std::string pclass, ValueObject &backend)
lldb::ValueObjectSP GetSyntheticValue() override
llvm::Expected< uint32_t > CalculateNumChildren() override
ConstString GetSyntheticTypeName() override
StructuredData::ObjectSP m_wrapper_sp
bool MightHaveChildren() override
std::string GetDescription() override
std::string m_python_class
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
uint32_t CalculateNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
std::unique_ptr< SyntheticChildrenFrontEnd > UniquePointer
lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
virtual llvm::Expected< uint32_t > CalculateNumChildren()=0
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
virtual std::string GetDescription()=0
virtual SyntheticChildrenFrontEnd::UniquePointer GetFrontEnd(ValueObject &backend)=0
bool SkipsPointers() const
SyntheticChildren(const Flags &flags)
bool SkipsReferences() const
virtual ~SyntheticChildren()
virtual bool IsScripted()=0
llvm::Expected< size_t > GetIndexOfChildWithName(ConstString name) override
Determine the index of a named child.
bool SetExpressionPathAtIndex(size_t i, const char *path)
const char * GetExpressionPathAtIndex(size_t i) const
void AddExpressionPath(const char *path)
std::string GetDescription() override
std::vector< std::string > m_expression_paths
static lldb::ValueObjectSP CreateValueObjectFromExpression(llvm::StringRef name, llvm::StringRef expression, const ExecutionContext &exe_ctx)
lldb::ValueObjectSP GetSP()
lldb::user_id_t GetID() const
Returns a unique id for this ValueObject.
static lldb::ValueObjectSP CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address, const ExecutionContext &exe_ctx, CompilerType type, bool do_deref=true)
Given an address either create a value object containing the value at that address,...
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
lldb::TargetSP GetTargetSP() const
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.
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
@ eReuse
Children did not change and don't need to be recomputed; re-use what we computed the last time we cal...
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Target > TargetSP