Skip to content

Commit 90d9f88

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
1 parent 5d54213 commit 90d9f88

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
@@ -1392,6 +1392,22 @@ class Process : public std::enable_shared_from_this<Process>,
13921392
m_highmem_data_address_mask = data_address_mask;
13931393
}
13941394

1395+
/// Some targets might use bits in a code address to indicate a mode switch,
1396+
/// ARM uses bit zero to signify a code address is thumb, so any ARM ABI
1397+
/// plug-ins would strip those bits.
1398+
/// Or use the high bits to authenticate a pointer value.
1399+
lldb::addr_t FixCodeAddress(lldb::addr_t pc);
1400+
lldb::addr_t FixDataAddress(lldb::addr_t pc);
1401+
1402+
/// Use this method when you do not know, or do not care what kind of address
1403+
/// you are fixing. On platforms where there would be a difference between the
1404+
/// two types, it will pick the safest option.
1405+
///
1406+
/// Its purpose is to signal that no specific choice was made and provide an
1407+
/// alternative to randomly picking FixCode/FixData address. Which could break
1408+
/// platforms where there is a difference (only Arm Thumb at this time).
1409+
lldb::addr_t FixAnyAddress(lldb::addr_t pc);
1410+
13951411
/// Get the Modification ID of the process.
13961412
///
13971413
/// \return

lldb/source/Target/Process.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5688,6 +5688,24 @@ lldb::addr_t Process::GetHighmemDataAddressMask() {
56885688
return GetDataAddressMask();
56895689
}
56905690

5691+
addr_t Process::FixCodeAddress(addr_t addr) {
5692+
if (ABISP abi_sp = GetABI())
5693+
addr = abi_sp->FixCodeAddress(addr);
5694+
return addr;
5695+
}
5696+
5697+
addr_t Process::FixDataAddress(addr_t addr) {
5698+
if (ABISP abi_sp = GetABI())
5699+
addr = abi_sp->FixDataAddress(addr);
5700+
return addr;
5701+
}
5702+
5703+
addr_t Process::FixAnyAddress(addr_t addr) {
5704+
if (ABISP abi_sp = GetABI())
5705+
addr = abi_sp->FixAnyAddress(addr);
5706+
return addr;
5707+
}
5708+
56915709
void Process::DidExec() {
56925710
Log *log = GetLog(LLDBLog::Process);
56935711
LLDB_LOGF(log, "Process::%s()", __FUNCTION__);

0 commit comments

Comments
 (0)