Skip to content

Add Fix*Address methods to Process, call into ABI #6995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lldb/include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,22 @@ class Process : public std::enable_shared_from_this<Process>,
m_highmem_data_address_mask = data_address_mask;
}

/// Some targets might use bits in a code address to indicate a mode switch,
/// ARM uses bit zero to signify a code address is thumb, so any ARM ABI
/// plug-ins would strip those bits.
/// Or use the high bits to authenticate a pointer value.
lldb::addr_t FixCodeAddress(lldb::addr_t pc);
lldb::addr_t FixDataAddress(lldb::addr_t pc);

/// Use this method when you do not know, or do not care what kind of address
/// you are fixing. On platforms where there would be a difference between the
/// two types, it will pick the safest option.
///
/// Its purpose is to signal that no specific choice was made and provide an
/// alternative to randomly picking FixCode/FixData address. Which could break
/// platforms where there is a difference (only Arm Thumb at this time).
lldb::addr_t FixAnyAddress(lldb::addr_t pc);

/// Get the Modification ID of the process.
///
/// \return
Expand Down
18 changes: 18 additions & 0 deletions lldb/source/Target/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5854,6 +5854,24 @@ lldb::addr_t Process::GetHighmemDataAddressMask() {
return GetDataAddressMask();
}

addr_t Process::FixCodeAddress(addr_t addr) {
if (ABISP abi_sp = GetABI())
addr = abi_sp->FixCodeAddress(addr);
return addr;
}

addr_t Process::FixDataAddress(addr_t addr) {
if (ABISP abi_sp = GetABI())
addr = abi_sp->FixDataAddress(addr);
return addr;
}

addr_t Process::FixAnyAddress(addr_t addr) {
if (ABISP abi_sp = GetABI())
addr = abi_sp->FixAnyAddress(addr);
return addr;
}

void Process::DidExec() {
Log *log = GetLog(LLDBLog::Process);
LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
Expand Down