28std::map<ConstString, CXXFunctionSummaryFormat::Callback> &
30 static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
34std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> &
36 static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>
55 bool MightHaveChildren()
override;
57 size_t GetIndexOfChildWithName(
ConstString name)
override;
76 uint8_t m_ptr_size = 8;
93 bool MightHaveChildren()
override;
95 size_t GetIndexOfChildWithName(
ConstString name)
override;
104 uint8_t m_ptr_size = 8;
113template <
typename D32,
typename D64>
126 bool MightHaveChildren()
override;
128 size_t GetIndexOfChildWithName(
ConstString name)
override;
138 uint8_t m_ptr_size = 8;
144namespace Foundation1300 {
163namespace Foundation1428 {
164 struct DataDescriptor_32 {
171 struct DataDescriptor_64 {
182namespace Foundation1437 {
183 struct DataDescriptor_32 {
192 struct DataDescriptor_64 {
204 template <
typename DD>
210 DD descriptor = DD();
211 process.
ReadMemory(start_of_descriptor, &descriptor,
sizeof(descriptor),
216 return descriptor._used;
223 return __NSSetMSize_Impl<DataDescriptor_32>(process, valobj_addr,
error);
225 return __NSSetMSize_Impl<DataDescriptor_64>(process, valobj_addr,
error);
249template <
bool cf_style>
252 static constexpr llvm::StringLiteral g_TypeHint(
"NSSet");
266 if (!descriptor || !descriptor->IsValid())
269 uint32_t ptr_size = process_sp->GetAddressByteSize();
270 bool is_64bit = (ptr_size == 8);
279 ConstString class_name(descriptor->GetClassName());
282 static const ConstString g_OrderedSetI(
"__NSOrderedSetI");
290 if (class_name == g_SetI || class_name == g_OrderedSetI) {
292 value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
296 value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
297 }
else if (class_name == g_SetM) {
299 llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
304 value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
306 value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
310 }
else if (class_name == g_SetCF || class_name == g_SetCFRef) {
313 if (!cfbh.
Update(valobj_addr, exe_ctx))
318 auto iter = map.find(class_name), end = map.end();
320 return iter->second(valobj, stream, options);
325 llvm::StringRef prefix, suffix;
327 std::tie(prefix, suffix) = language->GetFormatterPrefixSuffix(g_TypeHint);
330 stream.
Printf(
"%" PRIu64
" %s%s", value,
"element", value == 1 ?
"" :
"s");
348 if (flags.
IsClear(eTypeIsPointer)) {
350 valobj_sp = valobj_sp->AddressOf(
error);
351 if (
error.Fail() || !valobj_sp)
358 if (!descriptor || !descriptor->IsValid())
361 ConstString class_name = descriptor->GetClassName();
364 static const ConstString g_OrderedSetI(
"__NSOrderedSetI");
372 if (class_name == g_SetI || class_name == g_OrderedSetI) {
374 }
else if (class_name == g_SetM) {
376 llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
387 }
else if (class_name == g_SetCF || class_name == g_SetCFRef) {
391 auto iter = map.find(class_name), end = map.end();
393 return iter->second(synth, valobj_sp);
417 if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
422llvm::Expected<uint32_t>
424 if (!m_data_32 && !m_data_64)
426 return (m_data_32 ? m_data_32->_used : m_data_64->_used);
442 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
446 m_ptr_size = process_sp->GetAddressByteSize();
447 uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
449 if (m_ptr_size == 4) {
460 m_data_ptr = data_location + m_ptr_size;
471 uint32_t num_children = CalculateNumChildrenIgnoringErrors();
473 if (idx >= num_children)
476 ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
480 if (m_children.empty()) {
485 uint32_t test_idx = 0;
487 while (tries < num_children) {
488 obj_at_idx = m_data_ptr + (test_idx * m_ptr_size);
492 obj_at_idx = process_sp->ReadPointerFromMemory(obj_at_idx,
error);
504 m_children.push_back(descriptor);
508 if (idx >= m_children.size())
513 auto ptr_size = process_sp->GetAddressByteSize();
519 *
reinterpret_cast<uint32_t *
>(buffer.
GetBytes()) =
520 static_cast<uint32_t
>(set_item.
item_ptr);
523 *
reinterpret_cast<uint64_t *
>(buffer.
GetBytes()) =
524 static_cast<uint64_t
>(set_item.
item_ptr);
527 lldbassert(
false &&
"pointer size is not 4 nor 8");
530 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
533 process_sp->GetByteOrder(),
534 process_sp->GetAddressByteSize());
536 set_item.
valobj_sp = CreateValueObjectFromData(
537 idx_name.
GetString(), data, m_exe_ctx_ref,
538 m_backend.GetCompilerType().GetBasicTypeFromAST(
554 if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
559llvm::Expected<uint32_t>
561 if (!m_hashtable.IsValid())
563 return m_hashtable.GetCount();
573 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
578 m_ptr_size = process_sp->GetAddressByteSize();
579 m_order = process_sp->GetByteOrder();
580 return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref)
592 lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();
594 const uint32_t num_children = CalculateNumChildrenIgnoringErrors();
596 if (idx >= num_children)
599 if (m_children.empty()) {
600 ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
608 uint32_t test_idx = 0;
614 while (tries < num_children) {
615 val_at_idx = m_values_ptr + (test_idx * m_ptr_size);
617 val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx,
error);
629 m_children.push_back(descriptor);
633 if (idx >= m_children.size())
641 switch (m_ptr_size) {
645 *
reinterpret_cast<uint32_t *
>(buffer_sp->GetBytes()) =
646 static_cast<uint32_t
>(set_item.
item_ptr);
649 *
reinterpret_cast<uint64_t *
>(buffer_sp->GetBytes()) =
650 static_cast<uint64_t
>(set_item.
item_ptr);
653 lldbassert(
false &&
"pointer size is not 4 nor 8");
656 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
660 set_item.
valobj_sp = CreateValueObjectFromData(
661 idx_name.
GetString(), data, m_exe_ctx_ref,
662 m_backend.GetCompilerType().GetBasicTypeFromAST(
669template <
typename D32,
typename D64>
673 m_data_32(nullptr), m_data_64(nullptr) {
678template <
typename D32,
typename D64>
687template <
typename D32,
typename D64>
694 if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
699template <
typename D32,
typename D64>
700llvm::Expected<uint32_t>
703 if (!m_data_32 && !m_data_64)
705 return (m_data_32 ? (uint32_t)m_data_32->_used : (uint32_t)m_data_64->_used);
708template <
typename D32,
typename D64>
722 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
726 m_ptr_size = process_sp->GetAddressByteSize();
727 uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
729 if (m_ptr_size == 4) {
730 m_data_32 =
new D32();
731 process_sp->ReadMemory(data_location, m_data_32,
sizeof(D32),
734 m_data_64 =
new D64();
735 process_sp->ReadMemory(data_location, m_data_64,
sizeof(D64),
742template <
typename D32,
typename D64>
749template <
typename D32,
typename D64>
754 (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);
756 uint32_t num_children = CalculateNumChildrenIgnoringErrors();
758 if (idx >= num_children)
761 ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
765 if (m_children.empty()) {
770 uint32_t test_idx = 0;
772 while (tries < num_children) {
773 obj_at_idx = m_objs_addr + (test_idx * m_ptr_size);
777 obj_at_idx = process_sp->ReadPointerFromMemory(obj_at_idx,
error);
789 m_children.push_back(descriptor);
793 if (idx >= m_children.size())
798 auto ptr_size = process_sp->GetAddressByteSize();
810 assert(
false &&
"pointer size is not 4 nor 8 - get out of here ASAP");
813 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
816 process_sp->GetByteOrder(),
817 process_sp->GetAddressByteSize());
819 set_item.
valobj_sp = CreateValueObjectFromData(
820 idx_name.
GetString(), data, m_exe_ctx_ref,
821 m_backend.GetCompilerType().GetBasicTypeFromAST(
827template bool lldb_private::formatters::NSSetSummaryProvider<true>(
830template bool lldb_private::formatters::NSSetSummaryProvider<false>(
static llvm::raw_ostream & error(Stream &strm)
static std::optional< size_t > CalculateNumChildren(CompilerType container_elem_type, uint64_t num_elements, CompilerType element_type)
Calculates the number of elements stored in a container (with element type 'container_elem_type') as ...
uint32_t GetFoundationVersion()
bool Update(lldb::addr_t addr, ExecutionContextRef exe_ctx_rf)
Generic representation of a type in a programming language.
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
A uniqued constant string class.
bool IsEmpty() const
Test for empty string.
const char * GetCString() const
Get the string value as a C string.
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
Execution context objects refer to objects in the execution of the program that is being debugged.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
static Language * FindPlugin(lldb::LanguageType language)
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
static ObjCLanguageRuntime * Get(Process &process)
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value)
A plug-in interface definition class for debugging a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
uint32_t GetAddressByteSize() const
llvm::StringRef GetString() const
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.
lldb::LanguageType GetLanguage() const
lldb::ProcessSP GetProcessSP() const
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
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::Process > ProcessSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP