Skip to content

Commit f4a8300

Browse files
committed
Add Fix*Address methods to Process, call into ABI
We need to clear non-addressable bits from addresses across the lldb sources. Currently these need to use an ABI method to clear those bits from addresses, which you do by taking a Process, getting the current ABI, then calling the method. Simplify this by providing methods in Process which call into the ABI methods themselves. Differential Revision: https://reviews.llvm.org/D152863 (cherry picked from commit 90d9f88)
1 parent 512217c commit f4a8300

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,22 @@ class Process : public std::enable_shared_from_this<Process>,
14091409
m_highmem_data_address_mask = data_address_mask;
14101410
}
14111411

1412+
/// Some targets might use bits in a code address to indicate a mode switch,
1413+
/// ARM uses bit zero to signify a code address is thumb, so any ARM ABI
1414+
/// plug-ins would strip those bits.
1415+
/// Or use the high bits to authenticate a pointer value.
1416+
lldb::addr_t FixCodeAddress(lldb::addr_t pc);
1417+
lldb::addr_t FixDataAddress(lldb::addr_t pc);
1418+
1419+
/// Use this method when you do not know, or do not care what kind of address
1420+
/// you are fixing. On platforms where there would be a difference between the
1421+
/// two types, it will pick the safest option.
1422+
///
1423+
/// Its purpose is to signal that no specific choice was made and provide an
1424+
/// alternative to randomly picking FixCode/FixData address. Which could break
1425+
/// platforms where there is a difference (only Arm Thumb at this time).
1426+
lldb::addr_t FixAnyAddress(lldb::addr_t pc);
1427+
14121428
/// Get the Modification ID of the process.
14131429
///
14141430
/// \return

lldb/source/Target/Process.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5854,6 +5854,24 @@ lldb::addr_t Process::GetHighmemDataAddressMask() {
58545854
return GetDataAddressMask();
58555855
}
58565856

5857+
addr_t Process::FixCodeAddress(addr_t addr) {
5858+
if (ABISP abi_sp = GetABI())
5859+
addr = abi_sp->FixCodeAddress(addr);
5860+
return addr;
5861+
}
5862+
5863+
addr_t Process::FixDataAddress(addr_t addr) {
5864+
if (ABISP abi_sp = GetABI())
5865+
addr = abi_sp->FixDataAddress(addr);
5866+
return addr;
5867+
}
5868+
5869+
addr_t Process::FixAnyAddress(addr_t addr) {
5870+
if (ABISP abi_sp = GetABI())
5871+
addr = abi_sp->FixAnyAddress(addr);
5872+
return addr;
5873+
}
5874+
58575875
void Process::DidExec() {
58585876
Log *log = GetLog(LLDBLog::Process);
58595877
LLDB_LOGF(log, "Process::%s()", __FUNCTION__);

0 commit comments

Comments
 (0)