@@ -811,42 +811,39 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
811811 return return_valobj_sp;
812812}
813813
814- addr_t ABIMacOSX_arm64::FixCodeAddress (addr_t pc) {
815- addr_t pac_sign_extension = 0x0080000000000000ULL ;
816- addr_t tbi_mask = 0xff80000000000000ULL ;
817- addr_t mask = 0 ;
818-
819- if (ProcessSP process_sp = GetProcessSP ()) {
820- mask = process_sp->GetCodeAddressMask ();
821- if (pc & pac_sign_extension) {
822- addr_t highmem_mask = process_sp->GetHighmemCodeAddressMask ();
823- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
824- mask = highmem_mask;
825- }
826- }
814+ constexpr addr_t tbi_mask = 0xff80000000000000ULL ;
815+ constexpr addr_t pac_sign_extension = 0x0080000000000000ULL ;
816+
817+ // / Consults the process for its {code, data} address masks and applies it to
818+ // / `addr`.
819+ static addr_t DoFixAddr (addr_t addr, bool is_code, ProcessSP process_sp) {
820+ if (!process_sp)
821+ return addr;
822+
823+ addr_t mask = is_code ? process_sp->GetCodeAddressMask ()
824+ : process_sp->GetDataAddressMask ();
827825 if (mask == LLDB_INVALID_ADDRESS_MASK)
828826 mask = tbi_mask;
829827
830- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
828+ if (addr & pac_sign_extension) {
829+ addr_t highmem_mask = is_code ? process_sp->GetHighmemCodeAddressMask ()
830+ : process_sp->GetHighmemCodeAddressMask ();
831+ if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
832+ return addr | highmem_mask;
833+ return addr | mask;
834+ }
835+
836+ return addr & (~mask);
831837}
832838
833- addr_t ABIMacOSX_arm64::FixDataAddress (addr_t pc) {
834- addr_t pac_sign_extension = 0x0080000000000000ULL ;
835- addr_t tbi_mask = 0xff80000000000000ULL ;
836- addr_t mask = 0 ;
837-
838- if (ProcessSP process_sp = GetProcessSP ()) {
839- mask = process_sp->GetDataAddressMask ();
840- if (pc & pac_sign_extension) {
841- addr_t highmem_mask = process_sp->GetHighmemDataAddressMask ();
842- if (highmem_mask != LLDB_INVALID_ADDRESS_MASK)
843- mask = highmem_mask;
844- }
845- }
846- if (mask == LLDB_INVALID_ADDRESS_MASK)
847- mask = tbi_mask;
839+ addr_t ABIMacOSX_arm64::FixCodeAddress (addr_t pc) {
840+ ProcessSP process_sp = GetProcessSP ();
841+ return DoFixAddr (pc, true /* is_code*/ , GetProcessSP ());
842+ }
848843
849- return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
844+ addr_t ABIMacOSX_arm64::FixDataAddress (addr_t addr) {
845+ ProcessSP process_sp = GetProcessSP ();
846+ return DoFixAddr (addr, false /* is_code*/ , GetProcessSP ());
850847}
851848
852849void ABIMacOSX_arm64::Initialize () {
0 commit comments