[Lldb-commits] [lldb] 9ed7416 - [lldb] Try harder to find the __NSCFBoolean addresses
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 6 13:04:40 PDT 2021
Author: Fred Riss
Date: 2021-08-06T13:04:29-07:00
New Revision: 9ed7416aaf257b13079b48f856df9b45d783fab2
URL: https://github.com/llvm/llvm-project/commit/9ed7416aaf257b13079b48f856df9b45d783fab2
DIFF: https://github.com/llvm/llvm-project/commit/9ed7416aaf257b13079b48f856df9b45d783fab2.diff
LOG: [lldb] Try harder to find the __NSCFBoolean addresses
It looks like recent CoreFoundation builds strip the non-public symbol
that we were looking for to find the 2 boolean "classes". The public
symbol is of course there, and it contains the address of the private
one. If we don't find the private symbol directly, go through a memory
read at the public symbol's location instead.
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 10512a97ad69c..b4b6c8bf74861 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -2967,11 +2967,13 @@ bool AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded() {
if (m_CFBoolean_values)
return true;
- static ConstString g_kCFBooleanFalse("__kCFBooleanFalse");
- static ConstString g_kCFBooleanTrue("__kCFBooleanTrue");
+ static ConstString g___kCFBooleanFalse("__kCFBooleanFalse");
+ static ConstString g___kCFBooleanTrue("__kCFBooleanTrue");
+ static ConstString g_kCFBooleanFalse("kCFBooleanFalse");
+ static ConstString g_kCFBooleanTrue("kCFBooleanTrue");
- std::function<lldb::addr_t(ConstString)> get_symbol =
- [this](ConstString sym) -> lldb::addr_t {
+ std::function<lldb::addr_t(ConstString, ConstString)> get_symbol =
+ [this](ConstString sym, ConstString real_sym) -> lldb::addr_t {
SymbolContextList sc_list;
GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
sym, lldb::eSymbolTypeData, sc_list);
@@ -2981,12 +2983,26 @@ bool AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded() {
if (sc.symbol)
return sc.symbol->GetLoadAddress(&GetProcess()->GetTarget());
}
+ GetProcess()->GetTarget().GetImages().FindSymbolsWithNameAndType(
+ real_sym, lldb::eSymbolTypeData, sc_list);
+ if (sc_list.GetSize() != 1)
+ return LLDB_INVALID_ADDRESS;
- return LLDB_INVALID_ADDRESS;
+ SymbolContext sc;
+ sc_list.GetContextAtIndex(0, sc);
+ if (!sc.symbol)
+ return LLDB_INVALID_ADDRESS;
+
+ lldb::addr_t addr = sc.symbol->GetLoadAddress(&GetProcess()->GetTarget());
+ Status error;
+ addr = GetProcess()->ReadPointerFromMemory(addr, error);
+ if (error.Fail())
+ return LLDB_INVALID_ADDRESS;
+ return addr;
};
- lldb::addr_t false_addr = get_symbol(g_kCFBooleanFalse);
- lldb::addr_t true_addr = get_symbol(g_kCFBooleanTrue);
+ lldb::addr_t false_addr = get_symbol(g___kCFBooleanFalse, g_kCFBooleanFalse);
+ lldb::addr_t true_addr = get_symbol(g___kCFBooleanTrue, g_kCFBooleanTrue);
return (m_CFBoolean_values = {false_addr, true_addr}).operator bool();
}
More information about the lldb-commits
mailing list