Skip to content

Commit c8c963c

Browse files
committed
[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 (cherry picked from commit 8bac9e3)
1 parent 818339f commit c8c963c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "AppleObjCClassDescriptorV2.h"
1010

1111
#include "lldb/Expression/FunctionCaller.h"
12+
#include "lldb/Target/ABI.h"
1213
#include "lldb/Utility/Log.h"
1314

1415
using namespace lldb;
@@ -73,6 +74,10 @@ bool ClassDescriptorV2::objc_class_t::Read(Process *process,
7374
m_flags = (uint8_t)(data_NEVER_USE & (lldb::addr_t)3);
7475
m_data_ptr = data_NEVER_USE & GetClassDataMask(process);
7576

77+
if (ABISP abi_sp = process->GetABI()) {
78+
m_isa = abi_sp->FixCodeAddress(m_isa);
79+
m_superclass = abi_sp->FixCodeAddress(m_superclass);
80+
}
7681
return true;
7782
}
7883

@@ -105,6 +110,8 @@ bool ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr) {
105110
m_flags = extractor.GetU32_unchecked(&cursor);
106111
m_version = extractor.GetU32_unchecked(&cursor);
107112
m_ro_ptr = extractor.GetAddress_unchecked(&cursor);
113+
if (ABISP abi_sp = process->GetABI())
114+
m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
108115
m_method_list_ptr = extractor.GetAddress_unchecked(&cursor);
109116
m_properties_ptr = extractor.GetAddress_unchecked(&cursor);
110117
m_firstSubclass = extractor.GetAddress_unchecked(&cursor);
@@ -120,6 +127,8 @@ bool ClassDescriptorV2::class_rw_t::Read(Process *process, lldb::addr_t addr) {
120127
process->GetByteOrder(),
121128
process->GetAddressByteSize());
122129
m_ro_ptr = extractor.GetAddress_unchecked(&cursor);
130+
if (ABISP abi_sp = process->GetABI())
131+
m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
123132
}
124133

125134
return true;
@@ -231,6 +240,8 @@ bool ClassDescriptorV2::method_list_t::Read(Process *process,
231240
DataBufferHeap buffer(size, '\0');
232241
Status error;
233242

243+
if (ABISP abi_sp = process->GetABI())
244+
addr = abi_sp->FixCodeAddress(addr);
234245
process->ReadMemory(addr, buffer.GetBytes(), size, error);
235246
if (error.Fail()) {
236247
return false;

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "lldb/Expression/DiagnosticManager.h"
1313
#include "lldb/Expression/FunctionCaller.h"
1414
#include "lldb/Expression/UtilityFunction.h"
15+
#include "lldb/Target/ABI.h"
1516
#include "lldb/Target/ExecutionContext.h"
1617
#include "lldb/Target/Process.h"
1718
#include "lldb/Target/Thread.h"
@@ -134,6 +135,10 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
134135
target_addr_value);
135136
m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
136137
lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
138+
139+
if (ABISP abi_sp = GetThread().GetProcess()->GetABI()) {
140+
target_addr = abi_sp->FixCodeAddress(target_addr);
141+
}
137142
Address target_so_addr;
138143
target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
139144
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));

lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "lldb/Symbol/TypeList.h"
2121
#include "lldb/Symbol/Variable.h"
2222
#include "lldb/Target/Target.h"
23+
#include "lldb/Target/ABI.h"
2324
#include "lldb/Utility/Log.h"
2425
#include "lldb/Utility/Timer.h"
2526

@@ -273,10 +274,17 @@ ObjCLanguageRuntime::ClassDescriptorSP
273274
ObjCLanguageRuntime::GetClassDescriptorFromISA(ObjCISA isa) {
274275
if (isa) {
275276
UpdateISAToDescriptorMap();
277+
276278
ObjCLanguageRuntime::ISAToDescriptorIterator pos =
277279
m_isa_to_descriptor.find(isa);
278280
if (pos != m_isa_to_descriptor.end())
279281
return pos->second;
282+
283+
if (ABISP abi_sp = m_process->GetABI()) {
284+
pos = m_isa_to_descriptor.find(abi_sp->FixCodeAddress(isa));
285+
if (pos != m_isa_to_descriptor.end())
286+
return pos->second;
287+
}
280288
}
281289
return ClassDescriptorSP();
282290
}

0 commit comments

Comments
 (0)