summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Language/ObjC
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC')
-rw-r--r--lldb/source/Plugins/Language/ObjC/CF.cpp7
-rw-r--r--lldb/source/Plugins/Language/ObjC/CF.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp114
-rw-r--r--lldb/source/Plugins/Language/ObjC/CFBasicHash.h76
-rw-r--r--lldb/source/Plugins/Language/ObjC/Cocoa.cpp22
-rw-r--r--lldb/source/Plugins/Language/ObjC/Cocoa.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/CoreMedia.cpp3
-rw-r--r--lldb/source/Plugins/Language/ObjC/CoreMedia.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSArray.cpp79
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSDictionary.cpp330
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSDictionary.h9
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSError.cpp8
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSException.cpp6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSSet.cpp213
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSSet.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSString.cpp21
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSString.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp33
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.h6
20 files changed, 771 insertions, 192 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp
index 5bca260616ea8..2610468b17fd9 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CF.cpp
@@ -1,5 +1,4 @@
-//===-- CF.cpp ----------------------------------------------------*- C++
-//-*-===//
+//===-- CF.cpp ------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +8,10 @@
#include "CF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -30,7 +29,7 @@ using namespace lldb_private::formatters;
bool lldb_private::formatters::CFAbsoluteTimeSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)valobj.GetValueAsUnsigned(0);
+ epoch = epoch + (time_t)valobj.GetValueAsSigned(0);
tm *tm_date = localtime(&epoch);
if (!tm_date)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/CF.h b/lldb/source/Plugins/Language/ObjC/CF.h
index 2abb56d407eb8..6165e1c235bc8 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.h
+++ b/lldb/source/Plugins/Language/ObjC/CF.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CF_h_
-#define liblldb_CF_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -29,4 +29,4 @@ bool CFAbsoluteTimeSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp
new file mode 100644
index 0000000000000..42cda0146f2e0
--- /dev/null
+++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp
@@ -0,0 +1,114 @@
+#include "CFBasicHash.h"
+
+#include "lldb/Utility/Endian.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool CFBasicHash::IsValid() const {
+ if (m_address != LLDB_INVALID_ADDRESS) {
+ if (m_ptr_size == 4 && m_ht_32)
+ return true;
+ else if (m_ptr_size == 8 && m_ht_64)
+ return true;
+ else
+ return false;
+ }
+ return false;
+}
+
+bool CFBasicHash::Update(addr_t addr, ExecutionContextRef exe_ctx_rf) {
+ if (addr == LLDB_INVALID_ADDRESS || !addr)
+ return false;
+
+ m_address = addr;
+ m_exe_ctx_ref = exe_ctx_rf;
+ m_ptr_size =
+ m_exe_ctx_ref.GetTargetSP()->GetArchitecture().GetAddressByteSize();
+ m_byte_order = m_exe_ctx_ref.GetTargetSP()->GetArchitecture().GetByteOrder();
+
+ if (m_ptr_size == 4)
+ return UpdateFor(m_ht_32);
+ else if (m_ptr_size == 8)
+ return UpdateFor(m_ht_64);
+ return false;
+
+ llvm_unreachable(
+ "Unsupported architecture. Only 32bits and 64bits supported.");
+}
+
+template <typename T>
+bool CFBasicHash::UpdateFor(std::unique_ptr<__CFBasicHash<T>> &m_ht) {
+ if (m_byte_order != endian::InlHostByteOrder())
+ return false;
+
+ Status error;
+ Target *target = m_exe_ctx_ref.GetTargetSP().get();
+ addr_t addr = m_address.GetLoadAddress(target);
+ size_t size = sizeof(typename __CFBasicHash<T>::RuntimeBase) +
+ sizeof(typename __CFBasicHash<T>::Bits);
+
+ m_ht = std::make_unique<__CFBasicHash<T>>();
+ m_exe_ctx_ref.GetProcessSP()->ReadMemory(addr, m_ht.get(),
+ size, error);
+ if (error.Fail())
+ return false;
+
+ m_mutable = !(m_ht->base.cfinfoa & (1 << 6));
+ m_multi = m_ht->bits.counts_offset;
+ m_type = static_cast<HashType>(m_ht->bits.keys_offset);
+ addr_t ptr_offset = addr + size;
+ size_t ptr_count = GetPointerCount();
+ size = ptr_count * sizeof(T);
+
+ m_exe_ctx_ref.GetProcessSP()->ReadMemory(ptr_offset, m_ht->pointers, size,
+ error);
+
+ if (error.Fail()) {
+ m_ht = nullptr;
+ return false;
+ }
+
+ return true;
+}
+
+size_t CFBasicHash::GetCount() const {
+ if (!IsValid())
+ return 0;
+
+ if (!m_multi)
+ return (m_ptr_size == 4) ? m_ht_32->bits.used_buckets
+ : m_ht_64->bits.used_buckets;
+
+ // FIXME: Add support for multi
+ return 0;
+}
+
+size_t CFBasicHash::GetPointerCount() const {
+ if (!IsValid())
+ return 0;
+
+ if (m_multi)
+ return 3; // Bits::counts_offset;
+ return (m_type == HashType::dict) + 1;
+}
+
+addr_t CFBasicHash::GetKeyPointer() const {
+ if (!IsValid())
+ return LLDB_INVALID_ADDRESS;
+
+ if (m_ptr_size == 4)
+ return m_ht_32->pointers[m_ht_32->bits.keys_offset];
+
+ return m_ht_64->pointers[m_ht_64->bits.keys_offset];
+}
+
+addr_t CFBasicHash::GetValuePointer() const {
+ if (!IsValid())
+ return LLDB_INVALID_ADDRESS;
+
+ if (m_ptr_size == 4)
+ return m_ht_32->pointers[0];
+
+ return m_ht_64->pointers[0];
+}
diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
new file mode 100644
index 0000000000000..fd30f5f7845ff
--- /dev/null
+++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
@@ -0,0 +1,76 @@
+//===-- CFBasicHash.h -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
+
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+namespace lldb_private {
+
+class CFBasicHash {
+public:
+ enum class HashType { set = 0, dict };
+
+ CFBasicHash() = default;
+ ~CFBasicHash() = default;
+
+ bool Update(lldb::addr_t addr, ExecutionContextRef exe_ctx_rf);
+
+ bool IsValid() const;
+
+ bool IsMutable() const { return m_mutable; };
+ bool IsMultiVariant() const { return m_multi; }
+ HashType GetType() const { return m_type; }
+
+ size_t GetCount() const;
+ lldb::addr_t GetKeyPointer() const;
+ lldb::addr_t GetValuePointer() const;
+
+private:
+ template <typename T> struct __CFBasicHash {
+ struct RuntimeBase {
+ T cfisa;
+ T cfinfoa;
+ } base;
+
+ struct Bits {
+ uint16_t __reserved0;
+ uint16_t __reserved1 : 2;
+ uint16_t keys_offset : 1;
+ uint16_t counts_offset : 2;
+ uint16_t counts_width : 2;
+ uint16_t __reserved2 : 9;
+ uint32_t used_buckets; // number of used buckets
+ uint64_t deleted : 16; // number of elements deleted
+ uint64_t num_buckets_idx : 8; // index to number of buckets
+ uint64_t __reserved3 : 40;
+ uint64_t __reserved4;
+ } bits;
+
+ T pointers[3];
+ };
+ template <typename T> bool UpdateFor(std::unique_ptr<__CFBasicHash<T>> &m_ht);
+
+ size_t GetPointerCount() const;
+
+ uint32_t m_ptr_size = UINT32_MAX;
+ lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
+ Address m_address = LLDB_INVALID_ADDRESS;
+ std::unique_ptr<__CFBasicHash<uint32_t>> m_ht_32 = nullptr;
+ std::unique_ptr<__CFBasicHash<uint64_t>> m_ht_64 = nullptr;
+ ExecutionContextRef m_exe_ctx_ref;
+ bool m_mutable = true;
+ bool m_multi = false;
+ HashType m_type;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 8a81abbaedbef..648fc4adf24fd 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1,4 +1,4 @@
-//===-- Cocoa.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Cocoa.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +8,7 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
@@ -15,7 +16,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Time.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessStructReader.h"
@@ -818,13 +818,14 @@ bool lldb_private::formatters::NSDateSummaryProvider(
static const ConstString g___NSDate("__NSDate");
static const ConstString g___NSTaggedDate("__NSTaggedDate");
static const ConstString g_NSCalendarDate("NSCalendarDate");
+ static const ConstString g_NSConstantDate("NSConstantDate");
if (class_name.IsEmpty())
return false;
uint64_t info_bits = 0, value_bits = 0;
if ((class_name == g_NSDate) || (class_name == g___NSDate) ||
- (class_name == g___NSTaggedDate)) {
+ (class_name == g___NSTaggedDate) || (class_name == g_NSConstantDate)) {
if (descriptor->GetTaggedPointerInfo(&info_bits, &value_bits)) {
date_value_bits = ((value_bits << 8) | (info_bits << 4));
memcpy(&date_value, &date_value_bits, sizeof(date_value_bits));
@@ -850,8 +851,14 @@ bool lldb_private::formatters::NSDateSummaryProvider(
} else
return false;
- if (date_value == -63114076800) {
- stream.Printf("0001-12-30 00:00:00 +0000");
+ // FIXME: It seems old dates are not formatted according to NSDate's calendar
+ // so we hardcode distantPast's value so that it looks like LLDB is doing
+ // the right thing.
+
+ // The relative time in seconds from Cocoa Epoch to [NSDate distantPast].
+ const double RelSecondsFromCocoaEpochToNSDateDistantPast = -63114076800;
+ if (date_value == RelSecondsFromCocoaEpochToNSDateDistantPast) {
+ stream.Printf("0001-01-01 00:00:00 UTC");
return true;
}
@@ -867,7 +874,7 @@ bool lldb_private::formatters::NSDateSummaryProvider(
// is generally true and POSIXly happy, but might break if a library vendor
// decides to get creative
time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)date_value;
+ epoch = epoch + static_cast<time_t>(std::floor(date_value));
tm *tm_date = gmtime(&epoch);
if (!tm_date)
return false;
@@ -902,8 +909,7 @@ bool lldb_private::formatters::ObjCClassSummaryProvider(
if (class_name.IsEmpty())
return false;
- if (ConstString cs =
- Mangled(class_name).GetDemangledName(lldb::eLanguageTypeUnknown))
+ if (ConstString cs = Mangled(class_name).GetDemangledName())
class_name = cs;
stream.Printf("%s", class_name.AsCString("<unknown class>"));
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.h b/lldb/source/Plugins/Language/ObjC/Cocoa.h
index 388e6f03aa0f9..a195d622ce581 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.h
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Cocoa_h_
-#define liblldb_Cocoa_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -113,4 +113,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_Cocoa_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
index 247429da1b069..ac2f45b8354fa 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -1,5 +1,4 @@
-//===-- CoreMedia.cpp --------------------------------------------*- C++
-//-*-===//
+//===-- CoreMedia.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.h b/lldb/source/Plugins/Language/ObjC/CoreMedia.h
index 79abb67b9d7e3..7fd8560d20e18 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.h
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CoreMedia_h_
-#define liblldb_CoreMedia_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -22,4 +22,4 @@ bool CMTimeSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 73335aff2fd7c..8d648d8a08614 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -1,4 +1,4 @@
-//===-- NSArray.cpp ---------------------------------------------*- C++ -*-===//
+//===-- NSArray.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,16 +7,17 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
+#include "clang/Basic/TargetInfo.h"
#include "Cocoa.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -97,42 +98,46 @@ private:
};
namespace Foundation1010 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size : 28;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size : 60;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size : 28;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size : 60;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
@@ -436,7 +441,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontE
: SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
m_id_type() {
if (valobj_sp) {
- auto *clang_ast_context = ClangASTContext::GetScratch(
+ auto *clang_ast_context = TypeSystemClang::GetScratch(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = CompilerType(
@@ -528,7 +533,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
template <typename D32, typename D64>
lldb_private::formatters::
GenericNSArrayMSyntheticFrontEnd<D32, D64>::
- ~GenericNSArrayMSyntheticFrontEnd() {
+ ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -584,7 +589,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
if (valobj_sp) {
CompilerType type = valobj_sp->GetCompilerType();
if (type) {
- auto *clang_ast_context = ClangASTContext::GetScratch(
+ auto *clang_ast_context = TypeSystemClang::GetScratch(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = clang_ast_context->GetType(
@@ -595,7 +600,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
template <typename D32, typename D64, bool Inline>
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
- ~GenericNSArrayISyntheticFrontEnd() {
+ ~GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -753,7 +758,7 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::GetChildAtIndex(
if (idx == 0) {
auto *clang_ast_context =
- ClangASTContext::GetScratch(*m_backend.GetTargetSP());
+ TypeSystemClang::GetScratch(*m_backend.GetTargetSP());
if (clang_ast_context) {
CompilerType id_type(
clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index ae00674c49f33..3dc07678f92f5 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1,4 +1,4 @@
-//===-- NSDictionary.cpp ----------------------------------------*- C++ -*-===//
+//===-- NSDictionary.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,14 +10,15 @@
#include "clang/AST/DeclCXX.h"
+#include "CFBasicHash.h"
#include "NSDictionary.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -65,7 +66,7 @@ NSDictionary_Additionals::GetAdditionalSynthetics() {
static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
CompilerType compiler_type;
- ClangASTContext *target_ast_context = ClangASTContext::GetScratch(*target_sp);
+ TypeSystemClang *target_ast_context = TypeSystemClang::GetScratch(*target_sp);
if (target_ast_context) {
ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair");
@@ -76,18 +77,19 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
if (!compiler_type) {
compiler_type = target_ast_context->CreateRecordType(
- nullptr, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(),
- clang::TTK_Struct, lldb::eLanguageTypeC);
+ nullptr, OptionalClangModuleID(), lldb::eAccessPublic,
+ g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct,
+ lldb::eLanguageTypeC);
if (compiler_type) {
- ClangASTContext::StartTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::StartTagDeclarationDefinition(compiler_type);
CompilerType id_compiler_type =
target_ast_context->GetBasicType(eBasicTypeObjCID);
- ClangASTContext::AddFieldToRecordType(
+ TypeSystemClang::AddFieldToRecordType(
compiler_type, "key", id_compiler_type, lldb::eAccessPublic, 0);
- ClangASTContext::AddFieldToRecordType(
+ TypeSystemClang::AddFieldToRecordType(
compiler_type, "value", id_compiler_type, lldb::eAccessPublic, 0);
- ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
}
}
}
@@ -139,6 +141,37 @@ private:
std::vector<DictionaryItemDescriptor> m_children;
};
+class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+private:
+ struct DictionaryItemDescriptor {
+ lldb::addr_t key_ptr;
+ lldb::addr_t val_ptr;
+ lldb::ValueObjectSP valobj_sp;
+ };
+
+ ExecutionContextRef m_exe_ctx_ref;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_order;
+
+ CFBasicHash m_hashtable;
+
+ CompilerType m_pair_type;
+ std::vector<DictionaryItemDescriptor> m_children;
+};
+
class NSDictionary1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
NSDictionary1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
@@ -245,64 +278,67 @@ namespace Foundation1100 {
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used : 26;
- uint32_t _kvo : 1;
- uint32_t _size;
- uint32_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
- struct DataDescriptor_64 {
- uint64_t _used : 58;
- uint32_t _kvo : 1;
- uint64_t _size;
- uint64_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
-
-
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used : 26;
+ uint32_t _kvo : 1;
+ uint32_t _size;
+ uint32_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used : 58;
+ uint32_t _kvo : 1;
+ uint64_t _size;
+ uint64_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+ }
+
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1437 {
- static const uint64_t NSDictionaryCapacities[] = {
- 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723,
- 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607,
- 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
- 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
- 111638519, 180634607, 292272623, 472907251
- };
-
- static const size_t NSDictionaryNumSizeBuckets = sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
-
- struct DataDescriptor_32 {
- uint32_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ namespace {
+ static const uint64_t NSDictionaryCapacities[] = {
+ 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723,
+ 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607,
+ 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
+ 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
+ 111638519, 180634607, 292272623, 472907251
+ };
+
+ static const size_t NSDictionaryNumSizeBuckets =
+ sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
+
+ struct DataDescriptor_32 {
+ uint32_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
-
- struct DataDescriptor_64 {
- uint64_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+ }
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
@@ -375,7 +411,9 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_Dictionary0("__NSDictionary0");
- static const ConstString g_DictionaryCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCF("__CFDictionary");
+ static const ConstString g_DictionaryNSCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCFRef("CFDictionaryRef");
if (class_name.IsEmpty())
return false;
@@ -386,9 +424,9 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
ptr_size, 0, error);
if (error.Fail())
return false;
+
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy ||
- class_name == g_DictionaryCF) {
+ } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error;
@@ -406,8 +444,15 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
value = 1;
} else if (class_name == g_Dictionary0) {
value = 0;
- }
- else {
+ } else if (class_name == g_DictionaryCF ||
+ class_name == g_DictionaryNSCF ||
+ class_name == g_DictionaryCFRef) {
+ ExecutionContext exe_ctx(process_sp);
+ CFBasicHash cfbh;
+ if (!cfbh.Update(valobj_addr, exe_ctx))
+ return false;
+ value = cfbh.GetCount();
+ } else {
auto &map(NSDictionary_Additionals::GetAdditionalSummaries());
for (auto &candidate : map) {
if (candidate.first && candidate.first->Match(class_name))
@@ -465,6 +510,9 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
static const ConstString g_DictionaryImmutable("__NSDictionaryM_Immutable");
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
static const ConstString g_Dictionary0("__NSDictionary0");
+ static const ConstString g_DictionaryCF("__CFDictionary");
+ static const ConstString g_DictionaryNSCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCFRef("CFDictionaryRef");
if (class_name.IsEmpty())
return nullptr;
@@ -483,6 +531,10 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
return (new Foundation1100::NSDictionaryMSyntheticFrontEnd(valobj_sp));
} else if (class_name == g_Dictionary1) {
return (new NSDictionary1SyntheticFrontEnd(valobj_sp));
+ } else if (class_name == g_DictionaryCF ||
+ class_name == g_DictionaryNSCF ||
+ class_name == g_DictionaryCFRef) {
+ return (new NSCFDictionarySyntheticFrontEnd(valobj_sp));
} else {
auto &map(NSDictionary_Additionals::GetAdditionalSynthetics());
for (auto &candidate : map) {
@@ -640,6 +692,140 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex(
return dict_item.valobj_sp;
}
+lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
+ m_order(lldb::eByteOrderInvalid), m_hashtable(), m_pair_type() {}
+
+size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ GetIndexOfChildWithName(ConstString name) {
+ const char *item_name = name.GetCString();
+ const uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+}
+
+size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ CalculateNumChildren() {
+ if (!m_hashtable.IsValid())
+ return 0;
+ return m_hashtable.GetCount();
+}
+
+bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ m_ptr_size = 0;
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return false;
+ m_ptr_size = process_sp->GetAddressByteSize();
+ m_order = process_sp->GetByteOrder();
+ return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref);
+}
+
+bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ lldb::addr_t m_keys_ptr = m_hashtable.GetKeyPointer();
+ lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();
+
+ const uint32_t num_children = CalculateNumChildren();
+
+ if (idx >= num_children)
+ return lldb::ValueObjectSP();
+
+ if (m_children.empty()) {
+ ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
+ if (!process_sp)
+ return lldb::ValueObjectSP();
+
+ Status error;
+ lldb::addr_t key_at_idx = 0, val_at_idx = 0;
+
+ uint32_t tries = 0;
+ uint32_t test_idx = 0;
+
+ // Iterate over inferior memory, reading key/value pointers by shifting each
+ // cursor by test_index * m_ptr_size. Returns an empty ValueObject if a read
+ // fails, otherwise, continue until the number of tries matches the number
+ // of childen.
+ while (tries < num_children) {
+ key_at_idx = m_keys_ptr + (test_idx * m_ptr_size);
+ val_at_idx = m_values_ptr + (test_idx * m_ptr_size);
+
+ key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+ val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
+ test_idx++;
+
+ if (!key_at_idx || !val_at_idx)
+ continue;
+ tries++;
+
+ DictionaryItemDescriptor descriptor = {key_at_idx, val_at_idx,
+ lldb::ValueObjectSP()};
+
+ m_children.push_back(descriptor);
+ }
+ }
+
+ if (idx >= m_children.size()) // should never happen
+ return lldb::ValueObjectSP();
+
+ DictionaryItemDescriptor &dict_item = m_children[idx];
+ if (!dict_item.valobj_sp) {
+ if (!m_pair_type.IsValid()) {
+ TargetSP target_sp(m_backend.GetTargetSP());
+ if (!target_sp)
+ return ValueObjectSP();
+ m_pair_type = GetLLDBNSPairType(target_sp);
+ }
+ if (!m_pair_type.IsValid())
+ return ValueObjectSP();
+
+ DataBufferSP buffer_sp(new DataBufferHeap(2 * m_ptr_size, 0));
+
+ switch (m_ptr_size) {
+ case 0: // architecture has no clue - fail
+ return lldb::ValueObjectSP();
+ case 4: {
+ uint32_t *data_ptr = reinterpret_cast<uint32_t *>(buffer_sp->GetBytes());
+ *data_ptr = dict_item.key_ptr;
+ *(data_ptr + 1) = dict_item.val_ptr;
+ } break;
+ case 8: {
+ uint64_t *data_ptr = reinterpret_cast<uint64_t *>(buffer_sp->GetBytes());
+ *data_ptr = dict_item.key_ptr;
+ *(data_ptr + 1) = dict_item.val_ptr;
+ } break;
+ default:
+ lldbassert(false && "pointer size is not 4 nor 8");
+ }
+
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ DataExtractor data(buffer_sp, m_order, m_ptr_size);
+ dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetString(), data,
+ m_exe_ctx_ref, m_pair_type);
+ }
+ return dict_item.valobj_sp;
+}
+
lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
NSDictionary1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
: SyntheticChildrenFrontEnd(*valobj_sp.get()), m_pair(nullptr) {}
@@ -724,7 +910,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
- ~GenericNSDictionaryMSyntheticFrontEnd() {
+ ~GenericNSDictionaryMSyntheticFrontEnd<D32,D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -732,8 +918,8 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
}
template <typename D32, typename D64>
-size_t
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: GetIndexOfChildWithName(ConstString name) {
+size_t lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+ D32, D64>::GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -782,7 +968,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
}
if (error.Fail())
return false;
- return false;
+ return true;
}
template <typename D32, typename D64>
@@ -794,9 +980,8 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
lldb::ValueObjectSP
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
- GetChildAtIndex(
- size_t idx) {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+ D32, D64>::GetChildAtIndex(size_t idx) {
lldb::addr_t m_keys_ptr;
lldb::addr_t m_values_ptr;
if (m_data_32) {
@@ -884,7 +1069,6 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
return dict_item.valobj_sp;
}
-
lldb_private::formatters::Foundation1100::
NSDictionaryMSyntheticFrontEnd::
NSDictionaryMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.h b/lldb/source/Plugins/Language/ObjC/NSDictionary.h
index 44d56f9c2c686..57dacd6759d29 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.h
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.h
@@ -1,5 +1,4 @@
-//===-- NSDictionary.h ---------------------------------------------------*- C++
-//-*-===//
+//===-- NSDictionary.h ------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSDictionary_h_
-#define liblldb_NSDictionary_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -91,4 +90,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_NSDictionary_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 94a97c8ad039d..aa1103cb342cb 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -1,4 +1,4 @@
-//===-- NSError.cpp ---------------------------------------------*- C++ -*-===//
+//===-- NSError.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +10,10 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -87,7 +87,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData(
"domain_str", isw.GetAsData(process_sp->GetByteOrder()),
valobj.GetExecutionContextRef(),
- ClangASTContext::GetScratch(process_sp->GetTarget())
+ TypeSystemClang::GetScratch(process_sp->GetTarget())
->GetBasicType(lldb::eBasicTypeVoid)
.GetPointerType());
@@ -156,7 +156,7 @@ public:
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
- ClangASTContext::GetScratch(process_sp->GetTarget())
+ TypeSystemClang::GetScratch(process_sp->GetTarget())
->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 9150787361c54..c6bae5e1c0087 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -1,4 +1,4 @@
-//===-- NSException.cpp -----------------------------------------*- C++ -*-===//
+//===-- NSException.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -23,6 +22,7 @@
#include "Plugins/Language/ObjC/NSString.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
@@ -69,7 +69,7 @@ static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp,
InferiorSizedWord userinfo_isw(userinfo, *process_sp);
InferiorSizedWord reserved_isw(reserved, *process_sp);
- auto *clang_ast_context = ClangASTContext::GetScratch(process_sp->GetTarget());
+ auto *clang_ast_context = TypeSystemClang::GetScratch(process_sp->GetTarget());
if (!clang_ast_context)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 587dd13870a0f..d962f39611b60 100644
--- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -1,4 +1,4 @@
-//===-- NSIndexPath.cpp -----------------------------------------*- C++ -*-===//
+//===-- NSIndexPath.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,11 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -53,7 +53,7 @@ public:
if (!type_system)
return false;
- ClangASTContext *ast = ClangASTContext::GetScratch(
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(
*m_backend.GetExecutionContextRef().GetTargetSP());
if (!ast)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index ebaa990fb74b2..4dbbe6fbddfff 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -1,4 +1,4 @@
-//===-- NSSet.cpp -----------------------------------------------*- C++ -*-===//
+//===-- NSSet.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,13 @@
//===----------------------------------------------------------------------===//
#include "NSSet.h"
+#include "CFBasicHash.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -79,6 +80,36 @@ private:
std::vector<SetItemDescriptor> m_children;
};
+class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ NSCFSetSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+private:
+ struct SetItemDescriptor {
+ lldb::addr_t item_ptr;
+ lldb::ValueObjectSP valobj_sp;
+ };
+
+ ExecutionContextRef m_exe_ctx_ref;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_order;
+
+ CFBasicHash m_hashtable;
+
+ CompilerType m_pair_type;
+ std::vector<SetItemDescriptor> m_children;
+};
+
template <typename D32, typename D64>
class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
@@ -245,21 +276,25 @@ bool lldb_private::formatters::NSSetSummaryProvider(
uint64_t value = 0;
- ConstString class_name_cs = descriptor->GetClassName();
- const char *class_name = class_name_cs.GetCString();
+ ConstString class_name(descriptor->GetClassName());
- if (!class_name || !*class_name)
+ static const ConstString g_SetI("__NSSetI");
+ static const ConstString g_OrderedSetI("__NSOrderedSetI");
+ static const ConstString g_SetM("__NSSetM");
+ static const ConstString g_SetCF("__NSCFSet");
+ static const ConstString g_SetCFRef("CFSetRef");
+
+ if (class_name.IsEmpty())
return false;
- if (!strcmp(class_name, "__NSSetI") ||
- !strcmp(class_name, "__NSOrderedSetI")) {
+ if (class_name == g_SetI || class_name == g_OrderedSetI) {
Status error;
value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
ptr_size, 0, error);
if (error.Fail())
return false;
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- } else if (!strcmp(class_name, "__NSSetM")) {
+ } else if (class_name == g_SetM) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error;
@@ -272,9 +307,15 @@ bool lldb_private::formatters::NSSetSummaryProvider(
}
if (error.Fail())
return false;
+ } else if (class_name == g_SetCF || class_name == g_SetCFRef) {
+ ExecutionContext exe_ctx(process_sp);
+ CFBasicHash cfbh;
+ if (!cfbh.Update(valobj_addr, exe_ctx))
+ return false;
+ value = cfbh.GetCount();
} else {
auto &map(NSSet_Additionals::GetAdditionalSummaries());
- auto iter = map.find(class_name_cs), end = map.end();
+ auto iter = map.find(class_name), end = map.end();
if (iter != end)
return iter->second(valobj, stream, options);
else
@@ -321,16 +362,20 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator(
if (!descriptor || !descriptor->IsValid())
return nullptr;
- ConstString class_name_cs = descriptor->GetClassName();
- const char *class_name = class_name_cs.GetCString();
+ ConstString class_name = descriptor->GetClassName();
- if (!class_name || !*class_name)
+ static const ConstString g_SetI("__NSSetI");
+ static const ConstString g_OrderedSetI("__NSOrderedSetI");
+ static const ConstString g_SetM("__NSSetM");
+ static const ConstString g_SetCF("__NSCFSet");
+ static const ConstString g_SetCFRef("CFSetRef");
+
+ if (class_name.IsEmpty())
return nullptr;
- if (!strcmp(class_name, "__NSSetI") ||
- !strcmp(class_name, "__NSOrderedSetI")) {
+ if (class_name == g_SetI || class_name == g_OrderedSetI) {
return (new NSSetISyntheticFrontEnd(valobj_sp));
- } else if (!strcmp(class_name, "__NSSetM")) {
+ } else if (class_name == g_SetM) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
if (apple_runtime) {
@@ -343,9 +388,11 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator(
} else {
return (new Foundation1300::NSSetMSyntheticFrontEnd(valobj_sp));
}
+ } else if (class_name == g_SetCF || class_name == g_SetCFRef) {
+ return (new NSCFSetSyntheticFrontEnd(valobj_sp));
} else {
auto &map(NSSet_Additionals::GetAdditionalSynthetics());
- auto iter = map.find(class_name_cs), end = map.end();
+ auto iter = map.find(class_name), end = map.end();
if (iter != end)
return iter->second(synth, valobj_sp);
return nullptr;
@@ -475,16 +522,18 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) {
auto ptr_size = process_sp->GetAddressByteSize();
DataBufferHeap buffer(ptr_size, 0);
switch (ptr_size) {
- case 0: // architecture has no clue?? - fail
+ case 0: // architecture has no clue - fail
return lldb::ValueObjectSP();
case 4:
- *((uint32_t *)buffer.GetBytes()) = (uint32_t)set_item.item_ptr;
+ *reinterpret_cast<uint32_t *>(buffer.GetBytes()) =
+ static_cast<uint32_t>(set_item.item_ptr);
break;
case 8:
- *((uint64_t *)buffer.GetBytes()) = (uint64_t)set_item.item_ptr;
+ *reinterpret_cast<uint64_t *>(buffer.GetBytes()) =
+ static_cast<uint64_t>(set_item.item_ptr);
break;
default:
- assert(false && "pointer size is not 4 nor 8 - get out of here ASAP");
+ lldbassert(false && "pointer size is not 4 nor 8");
}
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
@@ -501,6 +550,128 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) {
return set_item.valobj_sp;
}
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::NSCFSetSyntheticFrontEnd(
+ lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
+ m_order(lldb::eByteOrderInvalid), m_hashtable(), m_pair_type() {}
+
+size_t
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetIndexOfChildWithName(
+ ConstString name) {
+ const char *item_name = name.GetCString();
+ const uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+}
+
+size_t
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren() {
+ if (!m_hashtable.IsValid())
+ return 0;
+ return m_hashtable.GetCount();
+}
+
+bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ m_ptr_size = 0;
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return false;
+ m_ptr_size = process_sp->GetAddressByteSize();
+ m_order = process_sp->GetByteOrder();
+ return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref);
+}
+
+bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::MightHaveChildren() {
+ return true;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();
+
+ const uint32_t num_children = CalculateNumChildren();
+
+ if (idx >= num_children)
+ return lldb::ValueObjectSP();
+
+ if (m_children.empty()) {
+ ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
+ if (!process_sp)
+ return lldb::ValueObjectSP();
+
+ Status error;
+ lldb::addr_t val_at_idx = 0;
+
+ uint32_t tries = 0;
+ uint32_t test_idx = 0;
+
+ // Iterate over inferior memory, reading value pointers by shifting the
+ // cursor by test_index * m_ptr_size. Returns an empty ValueObject if a read
+ // fails, otherwise, continue until the number of tries matches the number
+ // of childen.
+ while (tries < num_children) {
+ val_at_idx = m_values_ptr + (test_idx * m_ptr_size);
+
+ val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
+ test_idx++;
+
+ if (!val_at_idx)
+ continue;
+ tries++;
+
+ SetItemDescriptor descriptor = {val_at_idx, lldb::ValueObjectSP()};
+
+ m_children.push_back(descriptor);
+ }
+ }
+
+ if (idx >= m_children.size()) // should never happen
+ return lldb::ValueObjectSP();
+
+ SetItemDescriptor &set_item = m_children[idx];
+ if (!set_item.valobj_sp) {
+
+ DataBufferSP buffer_sp(new DataBufferHeap(m_ptr_size, 0));
+
+ switch (m_ptr_size) {
+ case 0: // architecture has no clue - fail
+ return lldb::ValueObjectSP();
+ case 4:
+ *reinterpret_cast<uint32_t *>(buffer_sp->GetBytes()) =
+ static_cast<uint32_t>(set_item.item_ptr);
+ break;
+ case 8:
+ *reinterpret_cast<uint64_t *>(buffer_sp->GetBytes()) =
+ static_cast<uint64_t>(set_item.item_ptr);
+ break;
+ default:
+ lldbassert(false && "pointer size is not 4 nor 8");
+ }
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+
+ DataExtractor data(buffer_sp, m_order, m_ptr_size);
+
+ set_item.valobj_sp = CreateValueObjectFromData(
+ idx_name.GetString(), data, m_exe_ctx_ref,
+ m_backend.GetCompilerType().GetBasicTypeFromAST(
+ lldb::eBasicTypeObjCID));
+ }
+
+ return set_item.valobj_sp;
+}
+
template <typename D32, typename D64>
lldb_private::formatters::
GenericNSSetMSyntheticFrontEnd<D32, D64>::GenericNSSetMSyntheticFrontEnd(
@@ -513,7 +684,7 @@ lldb_private::formatters::
template <typename D32, typename D64>
lldb_private::formatters::
- GenericNSSetMSyntheticFrontEnd<D32, D64>::~GenericNSSetMSyntheticFrontEnd() {
+ GenericNSSetMSyntheticFrontEnd<D32, D64>::~GenericNSSetMSyntheticFrontEnd<D32, D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.h b/lldb/source/Plugins/Language/ObjC/NSSet.h
index f11b6d406dec3..3ad1f694befe7 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.h
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSSet_h_
-#define liblldb_NSSet_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -36,4 +36,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_NSSet_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp
index ce54d657374b1..b9d0d73cbc2eb 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -1,5 +1,4 @@
-//===-- NSString.cpp ----------------------------------------------*- C++
-//-*-===//
+//===-- NSString.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,11 +8,11 @@
#include "NSString.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
@@ -35,7 +34,7 @@ NSString_Additionals::GetAdditionalSummaries() {
static CompilerType GetNSPathStore2Type(Target &target) {
static ConstString g_type_name("__lldb_autogen_nspathstore2");
- ClangASTContext *ast_ctx = ClangASTContext::GetScratch(target);
+ TypeSystemClang *ast_ctx = TypeSystemClang::GetScratch(target);
if (!ast_ctx)
return CompilerType();
@@ -171,11 +170,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(false);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(false);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF16>(options);
} else {
@@ -183,11 +182,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(false);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(false);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::ASCII>(options);
}
@@ -200,9 +199,9 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::ASCII>(options);
} else if (is_unicode) {
@@ -222,11 +221,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(!has_explicit_length);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF16>(options);
} else if (is_path_store) {
@@ -242,11 +241,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(!has_explicit_length);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF16>(options);
} else if (is_inline) {
@@ -264,11 +263,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(!has_explicit_length);
- options.SetLanguage(summary_options.GetLanguage());
if (has_explicit_length)
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF8>(options);
@@ -287,9 +286,9 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::ASCII>(options);
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h
index 699d8eb36f882..a68cc6c056b0d 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.h
+++ b/lldb/source/Plugins/Language/ObjC/NSString.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSString_h_
-#define liblldb_NSString_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -39,4 +39,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 3be548ad41441..29391daaab93a 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- ObjCLanguage.cpp ----------------------------------------*- C++ -*-===//
+//===-- ObjCLanguage.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,12 +10,12 @@
#include "ObjCLanguage.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
@@ -37,6 +37,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+LLDB_PLUGIN_DEFINE(ObjCLanguage)
+
void ObjCLanguage::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(), "Objective-C Language",
CreateInstance);
@@ -446,6 +448,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
appkit_flags);
AddCXXSummary(objc_category_sp,
lldb_private::formatters::NSDictionarySummaryProvider<true>,
+ "NSDictionary summary provider", ConstString("__CFDictionary"),
+ appkit_flags);
+ AddCXXSummary(objc_category_sp,
+ lldb_private::formatters::NSDictionarySummaryProvider<true>,
"NSDictionary summary provider",
ConstString("CFMutableDictionaryRef"), appkit_flags);
@@ -466,6 +472,9 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
"__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
AddCXXSummary(objc_category_sp,
lldb_private::formatters::NSSetSummaryProvider<false>,
+ "__CFSet summary", ConstString("__CFSet"), appkit_flags);
+ AddCXXSummary(objc_category_sp,
+ lldb_private::formatters::NSSetSummaryProvider<false>,
"__NSSetI summary", ConstString("__NSSetI"), appkit_flags);
AddCXXSummary(objc_category_sp,
lldb_private::formatters::NSSetSummaryProvider<false>,
@@ -582,6 +591,11 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
"NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(
+ objc_category_sp,
+ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
+ "NSDictionary synthetic children", ConstString("__CFDictionary"),
+ ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp,
lldb_private::formatters::NSErrorSyntheticFrontEndCreator,
@@ -604,6 +618,15 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"__NSSetM synthetic children", ConstString("__NSSetM"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "__NSCFSet synthetic children", ConstString("__NSCFSet"),
+ ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "CFSetRef synthetic children", ConstString("CFSetRef"),
+ ScriptedSyntheticChildren::Flags());
+
AddCXXSynthetic(
objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"NSMutableSet synthetic children", ConstString("NSMutableSet"),
@@ -620,6 +643,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"__NSOrderedSetM synthetic children", ConstString("__NSOrderedSetM"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "__CFSet synthetic children", ConstString("__CFSet"),
+ ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp,
lldb_private::formatters::NSIndexPathSyntheticFrontEndCreator,
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index 3e2cc09729934..bed62a5c447ae 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjCLanguage_h_
-#define liblldb_ObjCLanguage_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H
#include <cstring>
#include <vector>
@@ -160,4 +160,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ObjCLanguage_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H