23#include "llvm/Support/Error.h"
30 bool need_add_dot =
true;
31 if (path[0] ==
'.' || (path[0] ==
'-' && path[1] ==
'>') || path[0] ==
'[')
41 const std::string &path) {
44 bool need_add_dot =
true;
45 if (path[0] ==
'.' || (path[0] ==
'-' && path[1] ==
'>') || path[0] ==
'[')
59 for (
size_t i = 0; i <
filter->GetCount(); i++) {
60 const char *expr_cstr =
filter->GetExpressionPathAtIndex(i);
62 if (*expr_cstr ==
'.')
64 else if (*expr_cstr ==
'-' && *(expr_cstr + 1) ==
'>')
68 if (!::strcmp(name_cstr, expr_cstr))
73 return llvm::createStringError(
"Type has no child named '%s'",
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::createStringError(
"Type has no child named '%s'",
250 sstr.
Printf(
"%s%s%s Python class %s",
Cascades() ?
"" :
" (not cascading)",
272 "@init failed: {0}");
287 control, data, FormatterBytecode::sig_update);
290 "@update failed: {0}");
300llvm::Expected<uint32_t>
308 control, data, FormatterBytecode::sig_get_num_children);
312 if (data.size() == 0) {
313 char message[] =
"@get_num_children returned empty data stack";
315 return llvm::createStringError(message);
319 if (
auto *u = std::get_if<uint64_t>(&top))
322 if (
auto *i = std::get_if<int64_t>(&top)) {
328 return llvm::createStringError(
"@get_num_children returned invalid value");
333 if (!
m_impl.get_child_at_index)
337 m_impl.get_child_at_index->getBuffer()};
339 data.emplace_back((uint64_t)idx);
341 control, data, FormatterBytecode::sig_get_child_at_index);
344 "@get_child_at_index failed: {0}");
348 if (data.size() == 0) {
350 "@get_child_at_index returned empty data stack");
355 if (
auto *child = std::get_if<ValueObjectSP>(&top))
361llvm::Expected<size_t>
363 if (
m_impl.get_child_index)
367 m_impl.get_child_index->getBuffer()};
371 control, data, FormatterBytecode::sig_get_child_index);
375 if (data.size() == 0) {
376 char message[] =
"@get_child_index returned empty data stack";
378 return llvm::createStringError(message);
382 if (
auto *u = std::get_if<uint64_t>(&top))
385 if (
auto *i = std::get_if<int64_t>(&top)) {
386 if (*i > 0 &&
static_cast<uint64_t
>(*i) <= SIZE_MAX)
391 return llvm::createStringError(
"@get_child_index returned invalid value");
396 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
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 * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C 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