[Lldb-commits] [lldb] [lldb] Recognize MTE fault Mach exceptions (PR #159117)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 16 09:53:06 PDT 2025
================
@@ -77,6 +77,35 @@ static void DescribeAddressBriefly(Stream &strm, const Address &addr,
strm.Printf(".\n");
}
+static constexpr uint8_t g_mte_tag_shift = 64 - 8;
+static constexpr uintptr_t g_mte_tag_mask = (uintptr_t)0x0f << g_mte_tag_shift;
+
+bool StopInfoMachException::DetermineTagMismatch(ExecutionContext &exe_ctx) {
+ const bool IsBadAccess = m_value == 1; // EXC_BAD_ACCESS
+ const bool IsMTETagFault = (m_exc_code == 0x106); // EXC_ARM_MTE_TAG_FAULT
+ if (!IsBadAccess || !IsMTETagFault)
+ return false;
+
+ if (m_exc_data_count < 2)
+ return false;
+
+ const uint64_t bad_address = m_exc_subcode;
+
+ StreamString strm;
+ strm.Printf("EXC_ARM_MTE_TAG_FAULT (code=%" PRIu64 ", address=0x%" PRIx64
+ ")\n",
+ m_exc_code, bad_address);
+
+ const uint8_t tag = (bad_address & g_mte_tag_mask) >> g_mte_tag_shift;
+ const uint64_t canonical_addr = bad_address & ~g_mte_tag_mask;
+ strm.Printf(
+ "Note: MTE tag mismatch detected: pointer tag=%d, address=0x%" PRIx64,
----------------
DavidSpickett wrote:
The Linux version will go and fetch the allocation tag, but I am not sure whether you have access to process here to do that.
https://github.com/llvm/llvm-project/pull/159117
More information about the lldb-commits
mailing list