[Lldb-commits] [lldb] r279353 - 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
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 19 17:48:11 PDT 2016
Author: enrico
Date: Fri Aug 19 19:48:11 2016
New Revision: 279353
URL: http://llvm.org/viewvc/llvm-project?rev=279353&view=rev
Log:
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..
Modified:
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=279353&r1=279352&r2=279353&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Fri Aug 19 19:48:11 2016
@@ -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)
{
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h?rev=279353&r1=279352&r2=279353&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h Fri Aug 19 19:48:11 2016
@@ -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);
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=279353&r1=279352&r2=279353&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Aug 19 19:48:11 2016
@@ -395,7 +395,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(P
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 (ObjCI
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);
+}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=279353&r1=279352&r2=279353&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Fri Aug 19 19:48:11 2016
@@ -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
More information about the lldb-commits
mailing list