21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/Error.h"
96 return m_num_elements;
120 element_type = actual_type;
128 auto node_sp = m_backend.GetChildAtNamePath({
"__table_",
"__first_node_"});
131 auto p1_sp = m_backend.GetChildAtNamePath({
"__table_",
"__p1_"});
145 return node_sp->GetCompilerType().GetTypeTemplateArgument(0).GetPointeeType();
150 if (idx >= CalculateNumChildrenIgnoringErrors())
152 if (m_tree ==
nullptr)
155 while (idx >= m_elements_cache.size()) {
156 if (m_next_element ==
nullptr)
161 if (!node_sp ||
error.Fail())
164 ValueObjectSP value_sp = node_sp->GetChildMemberWithName(
"__value_");
165 ValueObjectSP hash_sp = node_sp->GetChildMemberWithName(
"__hash_");
166 if (!hash_sp || !value_sp) {
167 if (!m_element_type) {
168 m_node_type = GetNodeType();
172 m_element_type = GetElementType(m_node_type);
174 node_sp = m_next_element->Cast(m_node_type.GetPointerType())
175 ->Dereference(
error);
176 if (!node_sp ||
error.Fail())
179 hash_sp = node_sp->GetChildMemberWithName(
"__hash_");
183 value_sp = node_sp->GetChildMemberWithName(
"__value_");
192 auto anon_union_sp = node_sp->GetChildAtIndex(2);
196 value_sp = anon_union_sp->GetChildMemberWithName(
"__value_");
201 m_elements_cache.push_back(
202 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});
203 m_next_element = node_sp->GetChildMemberWithName(
"__next_").get();
204 if (!m_next_element || m_next_element->GetValueAsUnsigned(0) == 0)
205 m_next_element =
nullptr;
208 std::pair<ValueObject *, uint64_t> val_hash = m_elements_cache[idx];
212 stream.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
215 val_hash.first->GetData(data,
error);
218 const bool thread_and_frame_only_if_stopped =
true;
220 thread_and_frame_only_if_stopped);
221 return CreateValueObjectFromData(stream.
GetString(), data, exe_ctx,
225llvm::Expected<size_t>
229 return size_sp->GetValueAsUnsigned(0);
233 return llvm::createStringError(
234 "Unexpected std::unordered_map layout: __p2_ member not found.");
237 return llvm::createStringError(
"Unexpected std::unordered_map layout: old "
238 "__compressed_pair layout not found.");
242 if (!num_elements_sp)
243 return llvm::createStringError(
244 "Unexpected std::unordered_map layout: failed to retrieve first member "
245 "in old __compressed_pair layout.");
247 return num_elements_sp->GetValueAsUnsigned(0);
265 return tree_sp->GetChildMemberWithName(
"__next_");
271 m_next_element =
nullptr;
272 m_elements_cache.clear();
273 ValueObjectSP table_sp = m_backend.GetChildMemberWithName(
"__table_");
281 m_tree = tree_sp.get();
283 if (
auto num_elems_or_err = CalculateNumChildrenImpl(*table_sp))
284 m_num_elements = *num_elems_or_err;
287 num_elems_or_err.takeError(),
"{0}");
291 if (m_num_elements > 0)
292 m_next_element = m_tree;
329 TargetSP target_sp(valobj_sp->GetTargetSP());
340 auto hash_iter_sp = valobj_sp->GetChildMemberWithName(
"__i_");
345 auto hash_iter_type = hash_iter_sp->GetCompilerType();
346 if (!hash_iter_type.IsValid())
350 auto node_pointer_type = hash_iter_type.GetTypeTemplateArgument(0);
351 if (!node_pointer_type.IsValid())
356 auto hash_node_sp = hash_iter_sp->Cast(node_pointer_type);
360 auto key_value_sp = hash_node_sp->GetChildMemberWithName(
"__value_");
369 auto anon_union_sp = hash_node_sp->GetChildAtIndex(2);
373 key_value_sp = anon_union_sp->GetChildMemberWithName(
"__value_");
385 auto potential_child_sp = key_value_sp->Clone(
ConstString(
"pair"));
386 if (potential_child_sp)
387 if (potential_child_sp->GetNumChildrenIgnoringErrors() == 1)
388 if (
auto child0_sp = potential_child_sp->GetChildAtIndex(0);
389 child0_sp->GetName() ==
"__cc_" || child0_sp->GetName() ==
"__cc")
390 potential_child_sp = child0_sp->Clone(
ConstString(
"pair"));
392 m_pair_sp = potential_child_sp;
405 return m_pair_sp->GetChildAtIndex(idx);
418 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