21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/Error.h"
96 return m_num_elements;
115 m_backend.GetCompilerType().GetCanonicalType().GetTypeName())) {
121 element_type = actual_type;
129 auto node_sp = m_backend.GetChildAtNamePath({
"__table_",
"__first_node_"});
132 auto p1_sp = m_backend.GetChildAtNamePath({
"__table_",
"__p1_"});
146 return node_sp->GetCompilerType().GetTypeTemplateArgument(0).GetPointeeType();
151 if (idx >= CalculateNumChildrenIgnoringErrors())
153 if (m_tree ==
nullptr)
156 while (idx >= m_elements_cache.size()) {
157 if (m_next_element ==
nullptr)
162 if (!node_sp ||
error.Fail())
165 ValueObjectSP value_sp = node_sp->GetChildMemberWithName(
"__value_");
166 ValueObjectSP hash_sp = node_sp->GetChildMemberWithName(
"__hash_");
167 if (!hash_sp || !value_sp) {
168 if (!m_element_type) {
169 m_node_type = GetNodeType();
173 m_element_type = GetElementType(m_node_type);
175 node_sp = m_next_element->Cast(m_node_type.GetPointerType())
176 ->Dereference(
error);
177 if (!node_sp ||
error.Fail())
180 hash_sp = node_sp->GetChildMemberWithName(
"__hash_");
184 value_sp = node_sp->GetChildMemberWithName(
"__value_");
193 auto anon_union_sp = node_sp->GetChildAtIndex(2);
197 value_sp = anon_union_sp->GetChildMemberWithName(
"__value_");
202 m_elements_cache.push_back(
203 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});
204 m_next_element = node_sp->GetChildMemberWithName(
"__next_").get();
205 if (!m_next_element || m_next_element->GetValueAsUnsigned(0) == 0)
206 m_next_element =
nullptr;
209 std::pair<ValueObject *, uint64_t> val_hash = m_elements_cache[idx];
213 stream.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
216 val_hash.first->GetData(data,
error);
219 const bool thread_and_frame_only_if_stopped =
true;
221 thread_and_frame_only_if_stopped);
222 return CreateValueObjectFromData(stream.
GetString(), data, exe_ctx,
226llvm::Expected<size_t>
230 return size_sp->GetValueAsUnsigned(0);
234 return llvm::createStringError(
235 "Unexpected std::unordered_map layout: __p2_ member not found.");
238 return llvm::createStringError(
"Unexpected std::unordered_map layout: old "
239 "__compressed_pair layout not found.");
243 if (!num_elements_sp)
244 return llvm::createStringError(
245 "Unexpected std::unordered_map layout: failed to retrieve first member "
246 "in old __compressed_pair layout.");
248 return num_elements_sp->GetValueAsUnsigned(0);
266 return tree_sp->GetChildMemberWithName(
"__next_");
272 m_next_element =
nullptr;
273 m_elements_cache.clear();
274 ValueObjectSP table_sp = m_backend.GetChildMemberWithName(
"__table_");
282 m_tree = tree_sp.get();
284 if (
auto num_elems_or_err = CalculateNumChildrenImpl(*table_sp))
285 m_num_elements = *num_elems_or_err;
288 num_elems_or_err.takeError(),
"{0}");
292 if (m_num_elements > 0)
293 m_next_element = m_tree;
330 TargetSP target_sp(valobj_sp->GetTargetSP());
341 auto hash_iter_sp = valobj_sp->GetChildMemberWithName(
"__i_");
346 auto hash_iter_type = hash_iter_sp->GetCompilerType();
347 if (!hash_iter_type.IsValid())
351 auto node_pointer_type = hash_iter_type.GetTypeTemplateArgument(0);
352 if (!node_pointer_type.IsValid())
357 auto hash_node_sp = hash_iter_sp->Cast(node_pointer_type);
361 auto key_value_sp = hash_node_sp->GetChildMemberWithName(
"__value_");
370 auto anon_union_sp = hash_node_sp->GetChildAtIndex(2);
374 key_value_sp = anon_union_sp->GetChildMemberWithName(
"__value_");
386 auto potential_child_sp = key_value_sp->Clone(
ConstString(
"pair"));
387 if (potential_child_sp)
388 if (potential_child_sp->GetNumChildrenIgnoringErrors() == 1)
389 if (
auto child0_sp = potential_child_sp->GetChildAtIndex(0);
390 child0_sp->GetName() ==
"__cc_" || child0_sp->GetName() ==
"__cc")
391 potential_child_sp = child0_sp->Clone(
ConstString(
"pair"));
393 m_pair_sp = potential_child_sp;
406 return m_pair_sp->GetChildAtIndex(idx);
419 if (name ==
"second")
static llvm::raw_ostream & error(Stream &strm)
static ValueObjectSP GetTreePointer(ValueObject &table)
static bool isUnorderedMap(ConstString type_name)
#define LLDB_LOG_ERRORV(log, error,...)
Generic representation of a type in a programming language.
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
ConstString GetTypeName(bool BaseOnly=false) const
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true)
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.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Target > TargetSP