[lldb] Fixup more code addresses
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 13 May 2021 16:41:09 +0000 (09:41 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 13 May 2021 17:27:22 +0000 (10:27 -0700)
The Swift async task pointers are signed on arm64e and we need to fixup
the addresses in the CFA and DWARF expressions.

lldb/source/Expression/DWARFExpression.cpp
lldb/source/Target/RegisterContextUnwind.cpp

index 12fe76e..776d7f2 100644 (file)
@@ -1130,6 +1130,8 @@ bool DWARFExpression::Evaluate(
             lldb::addr_t pointer_value =
                 process->ReadPointerFromMemory(pointer_addr, error);
             if (pointer_value != LLDB_INVALID_ADDRESS) {
+              if (ABISP abi_sp = process->GetABI())
+                pointer_value = abi_sp->FixCodeAddress(pointer_value);
               stack.back().GetScalar() = pointer_value;
               stack.back().ClearContext();
             } else {
index b8d9926..1ce21e6 100644 (file)
@@ -1946,6 +1946,8 @@ bool RegisterContextUnwind::ReadFrameAddress(
             reg_info, cfa_reg_contents, reg_info->byte_size, reg_value);
         if (error.Success()) {
           address = reg_value.GetAsUInt64();
+          if (ABISP abi_sp = m_thread.GetProcess()->GetABI())
+            address = abi_sp->FixCodeAddress(address);
           UnwindLogMsg(
               "CFA value via dereferencing reg %s (%d): reg has val 0x%" PRIx64
               ", CFA value is 0x%" PRIx64,
@@ -2000,6 +2002,8 @@ bool RegisterContextUnwind::ReadFrameAddress(
     if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
                            &error)) {
       address = result.GetScalar().ULongLong();
+      if (ABISP abi_sp = m_thread.GetProcess()->GetABI())
+        address = abi_sp->FixCodeAddress(address);
 
       UnwindLogMsg("CFA value set by DWARF expression is 0x%" PRIx64,
                    address);