10b57cec5SDimitry Andric //===-- StopInfoMachException.h ---------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 95ffd83dbSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H 105ffd83dbSDimitry Andric #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H 110b57cec5SDimitry Andric 12bdd1243dSDimitry Andric #include <optional> 130b57cec5SDimitry Andric #include <string> 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #include "lldb/Target/StopInfo.h" 160b57cec5SDimitry Andric 17bdd1243dSDimitry Andric #if defined(__APPLE__) 18bdd1243dSDimitry Andric // Needed for the EXC_* defines 19bdd1243dSDimitry Andric #include <mach/exception.h> 20bdd1243dSDimitry Andric #endif 21bdd1243dSDimitry Andric 220b57cec5SDimitry Andric namespace lldb_private { 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric class StopInfoMachException : public StopInfo { 25349cc55cSDimitry Andric /// Determine the pointer-authentication related failure that caused this 26349cc55cSDimitry Andric /// exception. Returns true and fills out the failure description if there 27349cc55cSDimitry Andric /// is auth-related failure, and returns false otherwise. 28349cc55cSDimitry Andric bool DeterminePtrauthFailure(ExecutionContext &exe_ctx); 29349cc55cSDimitry Andric 300b57cec5SDimitry Andric public: 310b57cec5SDimitry Andric // Constructors and Destructors 320b57cec5SDimitry Andric StopInfoMachException(Thread &thread, uint32_t exc_type, 330b57cec5SDimitry Andric uint32_t exc_data_count, uint64_t exc_code, 34*0fca6ea1SDimitry Andric uint64_t exc_subcode, 35*0fca6ea1SDimitry Andric bool not_stepping_but_got_singlestep_exception) 360b57cec5SDimitry Andric : StopInfo(thread, exc_type), m_exc_data_count(exc_data_count), 37*0fca6ea1SDimitry Andric m_exc_code(exc_code), m_exc_subcode(exc_subcode), 38*0fca6ea1SDimitry Andric m_not_stepping_but_got_singlestep_exception( 39*0fca6ea1SDimitry Andric not_stepping_but_got_singlestep_exception) {} 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric ~StopInfoMachException() override = default; 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric lldb::StopReason GetStopReason() const override { 440b57cec5SDimitry Andric return lldb::eStopReasonException; 450b57cec5SDimitry Andric } 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric const char *GetDescription() override; 480b57cec5SDimitry Andric 49bdd1243dSDimitry Andric #if defined(__APPLE__) 50bdd1243dSDimitry Andric struct MachException { 51bdd1243dSDimitry Andric static const char *Name(exception_type_t exc_type); 52bdd1243dSDimitry Andric static std::optional<exception_type_t> ExceptionCode(const char *name); 53bdd1243dSDimitry Andric }; 54bdd1243dSDimitry Andric #endif 55bdd1243dSDimitry Andric 560b57cec5SDimitry Andric // Since some mach exceptions will be reported as breakpoints, signals, 570b57cec5SDimitry Andric // or trace, we use this static accessor which will translate the mach 580b57cec5SDimitry Andric // exception into the correct StopInfo. 590b57cec5SDimitry Andric static lldb::StopInfoSP CreateStopReasonWithMachException( 600b57cec5SDimitry Andric Thread &thread, uint32_t exc_type, uint32_t exc_data_count, 610b57cec5SDimitry Andric uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code, 620b57cec5SDimitry Andric bool pc_already_adjusted = true, bool adjust_pc_if_needed = false); 630b57cec5SDimitry Andric 64*0fca6ea1SDimitry Andric bool WasContinueInterrupted(Thread &thread) override; 65*0fca6ea1SDimitry Andric 660b57cec5SDimitry Andric protected: 670b57cec5SDimitry Andric uint32_t m_exc_data_count; 680b57cec5SDimitry Andric uint64_t m_exc_code; 690b57cec5SDimitry Andric uint64_t m_exc_subcode; 70*0fca6ea1SDimitry Andric 71*0fca6ea1SDimitry Andric bool m_not_stepping_but_got_singlestep_exception; 720b57cec5SDimitry Andric }; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric } // namespace lldb_private 750b57cec5SDimitry Andric 765ffd83dbSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H 77