23#include "llvm/Support/Error.h"
29std::map<ConstString, CXXFunctionSummaryFormat::Callback> &
31 static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
35std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> &
37 static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>
106template <
typename D32,
typename D64>
153 struct DataDescriptor_32 {
160 struct DataDescriptor_64 {
172 struct DataDescriptor_32 {
181 struct DataDescriptor_64 {
193 template <
typename DD>
199 DD descriptor = DD();
200 process.
ReadMemory(start_of_descriptor, &descriptor,
sizeof(descriptor),
205 return descriptor._used;
221template <
bool cf_style>
224 static constexpr llvm::StringLiteral g_TypeHint(
"NSSet");
238 if (!descriptor || !descriptor->IsValid())
241 uint32_t ptr_size = process_sp->GetAddressByteSize();
242 bool is_64bit = (ptr_size == 8);
251 ConstString class_name(descriptor->GetClassName());
252 llvm::StringRef class_name_ref(class_name.
GetStringRef());
254 static constexpr llvm::StringLiteral g_SetI(
"__NSSetI");
255 static constexpr llvm::StringLiteral g_OrderedSetI(
"__NSOrderedSetI");
256 static constexpr llvm::StringLiteral g_SetM(
"__NSSetM");
257 static constexpr llvm::StringLiteral g_SetCF(
"__NSCFSet");
258 static constexpr llvm::StringLiteral g_SetCFRef(
"CFSetRef");
260 if (class_name_ref.empty())
263 if (class_name_ref == g_SetI || class_name_ref == g_OrderedSetI) {
265 value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
269 value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
270 }
else if (class_name_ref == g_SetM) {
272 llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
277 value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
279 value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
283 }
else if (class_name_ref == g_SetCF || class_name_ref == g_SetCFRef) {
286 if (!cfbh.
Update(valobj_addr, exe_ctx))
291 auto iter = map.find(class_name), end = map.end();
293 return iter->second(valobj, stream, options);
298 llvm::StringRef prefix, suffix;
300 std::tie(prefix, suffix) = language->GetFormatterPrefixSuffix(g_TypeHint);
303 stream.
Printf(
"%" PRIu64
" %s%s", value,
"element", value == 1 ?
"" :
"s");
319 Flags flags(valobj_type.GetTypeInfo());
321 if (flags.IsClear(eTypeIsPointer)) {
323 valobj_sp = valobj_sp->AddressOf(
error);
324 if (
error.Fail() || !valobj_sp)
331 if (!descriptor || !descriptor->IsValid())
334 ConstString class_name = descriptor->GetClassName();
335 llvm::StringRef class_name_ref(class_name.
GetStringRef());
337 static constexpr llvm::StringLiteral g_SetI(
"__NSSetI");
338 static constexpr llvm::StringLiteral g_OrderedSetI(
"__NSOrderedSetI");
339 static constexpr llvm::StringLiteral g_SetM(
"__NSSetM");
340 static constexpr llvm::StringLiteral g_SetCF(
"__NSCFSet");
341 static constexpr llvm::StringLiteral g_SetCFRef(
"CFSetRef");
343 if (class_name_ref.empty())
346 if (class_name_ref == g_SetI || class_name_ref == g_OrderedSetI) {
348 }
else if (class_name_ref == g_SetM) {
349 AppleObjCRuntime *apple_runtime =
350 llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
361 }
else if (class_name_ref == g_SetCF || class_name_ref == g_SetCFRef) {
362 return (
new NSCFSetSyntheticFrontEnd(valobj_sp));
365 auto iter = map.find(class_name), end = map.end();
367 return iter->second(synth, valobj_sp);
386llvm::Expected<uint32_t>
408 m_ptr_size = process_sp->GetAddressByteSize();
409 uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) +
m_ptr_size;
431 if (idx >= num_children)
443 uint32_t test_idx = 0;
445 while (tries < num_children) {
449 llvm::Expected<lldb::addr_t> obj_at_idx_or_err =
450 process_sp->ReadPointerFromMemory(obj_at_idx);
451 if (!obj_at_idx_or_err) {
452 llvm::consumeError(obj_at_idx_or_err.takeError());
455 obj_at_idx = *obj_at_idx_or_err;
474 auto ptr_size = process_sp->GetAddressByteSize();
480 *
reinterpret_cast<uint32_t *
>(buffer.
GetBytes()) =
481 static_cast<uint32_t
>(set_item.
item_ptr);
484 *
reinterpret_cast<uint64_t *
>(buffer.
GetBytes()) =
485 static_cast<uint64_t
>(set_item.
item_ptr);
488 lldbassert(
false &&
"pointer size is not 4 nor 8");
491 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
494 process_sp->GetByteOrder(),
495 process_sp->GetAddressByteSize());
499 m_backend.GetCompilerType().GetBasicTypeFromAST(
510llvm::Expected<uint32_t>
529 m_ptr_size = process_sp->GetAddressByteSize();
530 m_order = process_sp->GetByteOrder();
543 if (idx >= num_children)
554 uint32_t test_idx = 0;
560 while (tries < num_children) {
561 val_at_idx = m_values_ptr + (test_idx *
m_ptr_size);
563 llvm::Expected<lldb::addr_t> val_at_idx_or_err =
564 process_sp->ReadPointerFromMemory(val_at_idx);
565 if (!val_at_idx_or_err) {
566 llvm::consumeError(val_at_idx_or_err.takeError());
569 val_at_idx = *val_at_idx_or_err;
595 *
reinterpret_cast<uint32_t *
>(buffer_sp->GetBytes()) =
596 static_cast<uint32_t
>(set_item.
item_ptr);
599 *
reinterpret_cast<uint64_t *
>(buffer_sp->GetBytes()) =
600 static_cast<uint64_t
>(set_item.
item_ptr);
603 lldbassert(
false &&
"pointer size is not 4 nor 8");
606 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
612 m_backend.GetCompilerType().GetBasicTypeFromAST(
619template <
typename D32,
typename D64>
628template <
typename D32,
typename D64>
637template <
typename D32,
typename D64>
638llvm::Expected<uint32_t>
646template <
typename D32,
typename D64>
664 m_ptr_size = process_sp->GetAddressByteSize();
665 uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) +
m_ptr_size;
669 process_sp->ReadMemory(data_location,
m_data_32,
sizeof(D32),
673 process_sp->ReadMemory(data_location,
m_data_64,
sizeof(D64),
680template <
typename D32,
typename D64>
689 if (idx >= num_children)
701 uint32_t test_idx = 0;
703 while (tries < num_children) {
704 obj_at_idx = m_objs_addr + (test_idx *
m_ptr_size);
707 llvm::Expected<lldb::addr_t> obj_at_idx_or_err =
708 process_sp->ReadPointerFromMemory(obj_at_idx);
709 if (!obj_at_idx_or_err) {
710 llvm::consumeError(obj_at_idx_or_err.takeError());
713 obj_at_idx = *obj_at_idx_or_err;
732 auto ptr_size = process_sp->GetAddressByteSize();
744 assert(
false &&
"pointer size is not 4 nor 8 - get out of here ASAP");
747 idx_name.
Printf(
"[%" PRIu64
"]", (uint64_t)idx);
750 process_sp->GetByteOrder(),
751 process_sp->GetAddressByteSize());
755 m_backend.GetCompilerType().GetBasicTypeFromAST(
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.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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.
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(const ProcessAddress &process_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.
uint32_t CalculateNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
SyntheticChildrenFrontEnd(ValueObject &backend)
lldb::ValueObjectSP CreateChildValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
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