-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress #159612
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
[lldb][NFC] Simplify logic in ABIMacOSX_arm64::FixDataAddress #159612
Conversation
@llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) ChangesI've intentionally split this into two commits to make it easier that this is an NFC patch; don't think we need to preserve them separately though upon merging. Full diff: https://github.com/llvm/llvm-project/pull/159612.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 094e0523a4edf..16aafe640b1a4 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -757,42 +757,37 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return return_valobj_sp;
}
-addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080000000000000ULL;
- addr_t tbi_mask = 0xff80000000000000ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
- mask = process_sp->GetCodeAddressMask();
- if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
- mask = highmem_mask;
- }
- }
+constexpr addr_t tbi_mask = 0xff80000000000000ULL;
+constexpr addr_t pac_sign_extension = 0x0080000000000000ULL;
+
+static addr_t DoFixAddr(addr_t addr, bool is_code, ProcessSP process_sp) {
+ if (!process_sp)
+ return addr;
+
+ addr_t mask = is_code ? process_sp->GetCodeAddressMask()
+ : process_sp->GetDataAddressMask();
if (mask == LLDB_INVALID_ADDRESS_MASK)
mask = tbi_mask;
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+ if (addr & pac_sign_extension) {
+ addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask()
+ : process_sp->GetHighmemCodeAddressMask();
+ if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
+ return addr | highmem_mask;
+ return addr | mask;
+ }
+
+ return addr & (~mask);
}
-addr_t ABIMacOSX_arm64::FixDataAddress(addr_t pc) {
- addr_t pac_sign_extension = 0x0080000000000000ULL;
- addr_t tbi_mask = 0xff80000000000000ULL;
- addr_t mask = 0;
-
- if (ProcessSP process_sp = GetProcessSP()) {
- mask = process_sp->GetDataAddressMask();
- if (pc & pac_sign_extension) {
- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask();
- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
- mask = highmem_mask;
- }
- }
- if (mask == LLDB_INVALID_ADDRESS_MASK)
- mask = tbi_mask;
+addr_t ABIMacOSX_arm64::FixCodeAddress(addr_t pc) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(pc, true /*is_code*/, GetProcessSP());
+}
- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
+addr_t ABIMacOSX_arm64::FixDataAddress(addr_t addr) {
+ ProcessSP process_sp = GetProcessSP();
+ return DoFixAddr(addr, false /*is_code*/, GetProcessSP());
}
void ABIMacOSX_arm64::Initialize() {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine, although we're not using tbi_mask
anywhere now? We should probably remove it if it's not being used.
It is!
|
I've intentionally split this into two commits to make it easier that this is an NFC patch; don't think we need to preserve them separately though upon merging.