1 //===-- StopInfoMachException.h ---------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
11 
12 #include <string>
13 
14 #include "lldb/Target/StopInfo.h"
15 
16 namespace lldb_private {
17 
18 class StopInfoMachException : public StopInfo {
19 public:
20   // Constructors and Destructors
21   StopInfoMachException(Thread &thread, uint32_t exc_type,
22                         uint32_t exc_data_count, uint64_t exc_code,
23                         uint64_t exc_subcode)
24       : StopInfo(thread, exc_type), m_exc_data_count(exc_data_count),
25         m_exc_code(exc_code), m_exc_subcode(exc_subcode) {}
26 
27   ~StopInfoMachException() override = default;
28 
29   lldb::StopReason GetStopReason() const override {
30     return lldb::eStopReasonException;
31   }
32 
33   const char *GetDescription() override;
34 
35   // Since some mach exceptions will be reported as breakpoints, signals,
36   // or trace, we use this static accessor which will translate the mach
37   // exception into the correct StopInfo.
38   static lldb::StopInfoSP CreateStopReasonWithMachException(
39       Thread &thread, uint32_t exc_type, uint32_t exc_data_count,
40       uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code,
41       bool pc_already_adjusted = true, bool adjust_pc_if_needed = false);
42 
43 protected:
44   uint32_t m_exc_data_count;
45   uint64_t m_exc_code;
46   uint64_t m_exc_subcode;
47 };
48 
49 } // namespace lldb_private
50 
51 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
52