Author: Jason Molenda Date: 2023-06-15T15:41:37-07:00 New Revision: 6a8e2538afc10e6b7a321fd38bf5faf550518f2a
URL: https://github.com/llvm/llvm-project/commit/6a8e2538afc10e6b7a321fd38bf5faf550518f2a DIFF: https://github.com/llvm/llvm-project/commit/6a8e2538afc10e6b7a321fd38bf5faf550518f2a.diff LOG: Add a fatal error for debug builds when disagreement about stepping On one CI bot we're seeing a failure where the kernel reports that we have completed an instruction step (via a mach exception) and lldb doesn't think the thread was doing an instruction step. It takes the conservative approach of stopping at this point, breaking tests. This patch adds an llvm fatal error for debug builds where it will log the state of the thread and the AArch64 ESR, to confirm what the hardware reported as the exception so we can double check the kernel's interpretation. I'll change this to an lldbassert without the runtime details in the string once we have an idea what is happening. the hope is that this will get hit on the CI bot soon. Differential Revision: https://reviews.llvm.org/D153079 Added: Modified: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index aae15b2ef4624..b4301f21ac103 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -708,12 +708,49 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( case llvm::Triple::aarch64_32: case llvm::Triple::aarch64: { + // xnu describes three things with type EXC_BREAKPOINT: + // + // exc_code 0x102 [EXC_ARM_DA_DEBUG], exc_sub_code addr-of-insn + // Watchpoint access. exc_sub_code is the address of the + // instruction which trigged the watchpoint trap. + // debugserver may add the watchpoint number that was triggered + // in exc_sub_sub_code. + // + // exc_code 1 [EXC_ARM_BREAKPOINT], exc_sub_code 0 + // Instruction step has completed. + // + // exc_code 1 [EXC_ARM_BREAKPOINT], exc_sub_code address-of-instruction + // Software breakpoint instruction executed. + if (exc_code == 1 && exc_sub_code == 0) // EXC_ARM_BREAKPOINT { // This is hit when we single instruction step aka MDSCR_EL1 SS bit 0 // is set - is_actual_breakpoint = false; + is_actual_breakpoint = true; is_trace_if_actual_breakpoint_missing = true; +#ifndef NDEBUG + if (thread.GetTemporaryResumeState() != eStateStepping) { + StreamString s; + s.Printf("CreateStopReasonWithMachException got EXC_BREAKPOINT [1,0] " + "indicating trace event, but thread is not tracing, it has " + "ResumeState %d", + thread.GetTemporaryResumeState()); + if (RegisterContextSP regctx = thread.GetRegisterContext()) { + if (const RegisterInfo *ri = regctx->GetRegisterInfoByName("esr")) { + uint32_t esr = + (uint32_t)regctx->ReadRegisterAsUnsigned(ri, UINT32_MAX); + if (esr != UINT32_MAX) { + s.Printf(" esr value: 0x%" PRIx32, esr); + } + } + } + llvm::report_fatal_error(s.GetData()); + lldbassert( + false && + "CreateStopReasonWithMachException got EXC_BREAKPOINT [1,0] " + "indicating trace event, but thread was not doing a step."); + } +#endif } if (exc_code == 0x102) // EXC_ARM_DA_DEBUG { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits