diff options
| author | Enrico Granata <egranata@apple.com> | 2016-08-20 00:48:11 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2016-08-20 00:48:11 +0000 |
| commit | 3630a287a66951f13764e17e597b9149bc59fa99 (patch) | |
| tree | f62c6973d5b8768c036928e30b820d364ae54c1b /lldb/source/Plugins/LanguageRuntime | |
| parent | c49b00a2491d935d6e225d6061819566f8e02191 (diff) | |
| download | bcm5719-llvm-3630a287a66951f13764e17e597b9149bc59fa99.tar.gz bcm5719-llvm-3630a287a66951f13764e17e597b9149bc59fa99.zip | |
Add logic to the ObjC runtime in LLDB to extract the pointer values of the two singleton (pairtons?) instances of __NSCFBoolean that represent true and false
This is useful because that knowledge will in turn allow no-code-running formatting of boolean NSNumbers; but that's a commit that will have to wait Monday..
llvm-svn: 279353
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime')
4 files changed, 63 insertions, 1 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 6d83f7a7c5e..84d5f81ed04 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -350,6 +350,13 @@ AppleObjCRuntime::GetFoundationVersion () return m_Foundation_major.getValue(); } +void +AppleObjCRuntime::GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true, + lldb::addr_t& cf_false) +{ + cf_true = cf_false = LLDB_INVALID_ADDRESS; +} + bool AppleObjCRuntime::IsModuleObjCLibrary (const ModuleSP &module_sp) { diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h index 342824e79b1..b66700fc516 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h @@ -114,6 +114,10 @@ public: uint32_t GetFoundationVersion(); + virtual void + GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true, + lldb::addr_t& cf_false); + protected: // Call CreateInstance instead. AppleObjCRuntime(Process *process); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 98efe523173..f8bce2b7b99 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -395,7 +395,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, const ModuleSP &objc_mo m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this, objc_module_sp)), m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)), m_encoding_to_type_sp(), - m_noclasses_warning_emitted(false) + m_noclasses_warning_emitted(false), + m_CFBoolean_values() { static const ConstString g_gdb_object_getClass("gdb_object_getClass"); m_has_object_getClass = @@ -2577,3 +2578,44 @@ AppleObjCRuntimeV2::GetPointerISA (ObjCISA isa) return ret; } + +bool +AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded () +{ + if (m_CFBoolean_values) + return true; + + static ConstString g_kCFBooleanFalse("kCFBooleanFalse"); + static ConstString g_kCFBooleanTrue("kCFBooleanTrue"); + + std::function<lldb::addr_t(ConstString)> get_symbol = [this] (ConstString sym) -> lldb::addr_t { + SymbolContextList sc_list; + if (GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(g_kCFBooleanFalse, lldb::eSymbolTypeData, sc_list) == 1) + { + SymbolContext sc; + sc_list.GetContextAtIndex(0, sc); + if (sc.symbol) + return sc.symbol->GetLoadAddress(&GetProcess()->GetTarget()); + } + + return LLDB_INVALID_ADDRESS; + }; + + lldb::addr_t false_addr = get_symbol(g_kCFBooleanFalse); + lldb::addr_t true_addr = get_symbol(g_kCFBooleanTrue); + + return (m_CFBoolean_values = {false_addr,true_addr}).operator bool(); +} + +void +AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true, + lldb::addr_t& cf_false) +{ + if (GetCFBooleanValuesIfNeeded()) + { + cf_true = m_CFBoolean_values->second; + cf_false = m_CFBoolean_values->first; + } + else + this->AppleObjCRuntime::GetValuesForGlobalCFBooleans(cf_true, cf_false); +} diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index fe128bb4d76..09bb13dd7cd 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -114,6 +114,10 @@ public: return m_tagged_pointer_vendor_ap.get(); } + void + GetValuesForGlobalCFBooleans(lldb::addr_t& cf_true, + lldb::addr_t& cf_false) override; + // none of these are valid ISAs - we use them to infer the type // of tagged pointers - if we have something meaningful to say // we report an actual type - otherwise, we just say tagged @@ -356,6 +360,9 @@ private: lldb::addr_t GetSharedCacheReadOnlyAddress(); + bool + GetCFBooleanValuesIfNeeded (); + friend class ClassDescriptorV2; std::unique_ptr<UtilityFunction> m_get_class_info_code; @@ -375,6 +382,8 @@ private: std::unique_ptr<TaggedPointerVendor> m_tagged_pointer_vendor_ap; EncodingToTypeSP m_encoding_to_type_sp; bool m_noclasses_warning_emitted; + llvm::Optional<std::pair<lldb::addr_t, + lldb::addr_t>> m_CFBoolean_values; }; } // namespace lldb_private |

