[Lldb-commits] [lldb] 8bac9e3 - [lldb] Fixup code addresses in the Objective-C language runtime
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 27 14:48:09 PDT 2021
Author: Jonas Devlieghere
Date: 2021-10-27T14:48:03-07:00
New Revision: 8bac9e3686e05916db88dab29b3c7fee70090d81
URL: https://github.com/llvm/llvm-project/commit/8bac9e3686e05916db88dab29b3c7fee70090d81
DIFF: https://github.com/llvm/llvm-project/commit/8bac9e3686e05916db88dab29b3c7fee70090d81.diff
LOG: [lldb] Fixup code addresses in the Objective-C language runtime
Upstream the calls to ABI::FixCodeAddress in the Objective-C language
runtime.
Differential revision: https://reviews.llvm.org/D112662
Added:
Modified:
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 405b8a6f16b7..162ccad3cdcd 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -9,6 +9,7 @@
#include "AppleObjCClassDescriptorV2.h"
#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Utility/Log.h"
using namespace lldb;
@@ -73,6 +74,10 @@ bool ClassDescriptorV2::objc_class_t::Read(Process *process,
m_flags = (uint8_t)(data_NEVER_USE & (lldb::addr_t)3);
m_data_ptr = data_NEVER_USE & GetClassDataMask(process);
+ if (ABISP abi_sp = process->GetABI()) {
+ m_isa = abi_sp->FixCodeAddress(m_isa);
+ m_superclass = abi_sp->FixCodeAddress(m_superclass);
+ }
return true;
}
@@ -105,6 +110,8 @@ bool ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr) {
m_flags = extractor.GetU32_unchecked(&cursor);
m_version = extractor.GetU32_unchecked(&cursor);
m_ro_ptr = extractor.GetAddress_unchecked(&cursor);
+ if (ABISP abi_sp = process->GetABI())
+ m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
m_method_list_ptr = extractor.GetAddress_unchecked(&cursor);
m_properties_ptr = extractor.GetAddress_unchecked(&cursor);
m_firstSubclass = extractor.GetAddress_unchecked(&cursor);
@@ -120,6 +127,8 @@ bool ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr) {
process->GetByteOrder(),
process->GetAddressByteSize());
m_ro_ptr = extractor.GetAddress_unchecked(&cursor);
+ if (ABISP abi_sp = process->GetABI())
+ m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
}
return true;
@@ -231,6 +240,8 @@ bool ClassDescriptorV2::method_list_t::Read(Process *process,
DataBufferHeap buffer(size, '\0');
Status error;
+ if (ABISP abi_sp = process->GetABI())
+ addr = abi_sp->FixCodeAddress(addr);
process->ReadMemory(addr, buffer.GetBytes(), size, error);
if (error.Fail()) {
return false;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 1dc8034c537a..f935ae7db8c0 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -12,6 +12,7 @@
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@@ -134,6 +135,10 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
target_addr_value);
m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
+
+ if (ABISP abi_sp = GetThread().GetProcess()->GetABI()) {
+ target_addr = abi_sp->FixCodeAddress(target_addr);
+ }
Address target_so_addr;
target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 65bf3e6af626..0cc96e43e195 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -20,6 +20,7 @@
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/ABI.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
@@ -273,10 +274,17 @@ ObjCLanguageRuntime::ClassDescriptorSP
ObjCLanguageRuntime::GetClassDescriptorFromISA(ObjCISA isa) {
if (isa) {
UpdateISAToDescriptorMap();
+
ObjCLanguageRuntime::ISAToDescriptorIterator pos =
m_isa_to_descriptor.find(isa);
if (pos != m_isa_to_descriptor.end())
return pos->second;
+
+ if (ABISP abi_sp = m_process->GetABI()) {
+ pos = m_isa_to_descriptor.find(abi_sp->FixCodeAddress(isa));
+ if (pos != m_isa_to_descriptor.end())
+ return pos->second;
+ }
}
return ClassDescriptorSP();
}
More information about the lldb-commits
mailing list