/src/CMake/Source/cmDebuggerExceptionManager.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <cstddef> |
8 | | #include <functional> |
9 | | #include <mutex> |
10 | | #include <string> |
11 | | #include <unordered_map> |
12 | | |
13 | | #include <cm/optional> |
14 | | |
15 | | #include <cm3p/cppdap/protocol.h> |
16 | | |
17 | | #include "cmMessageType.h" // IWYU pragma: keep |
18 | | |
19 | | namespace dap { |
20 | | class Session; |
21 | | struct CMakeInitializeResponse; |
22 | | } |
23 | | |
24 | | namespace cmDebugger { |
25 | | |
26 | | struct cmDebuggerException |
27 | | { |
28 | | std::string Id; |
29 | | std::string Description; |
30 | | }; |
31 | | |
32 | | struct cmDebuggerExceptionFilter |
33 | | { |
34 | | std::string Filter; |
35 | | std::string Label; |
36 | | }; |
37 | | |
38 | | /** The exception manager. */ |
39 | | class cmDebuggerExceptionManager |
40 | | { |
41 | | // Some older C++ standard libraries cannot hash an enum class by default. |
42 | | struct MessageTypeHash |
43 | | { |
44 | | std::size_t operator()(MessageType t) const |
45 | 0 | { |
46 | 0 | return std::hash<int>{}(static_cast<int>(t)); |
47 | 0 | } |
48 | | }; |
49 | | |
50 | | dap::Session* DapSession; |
51 | | std::mutex Mutex; |
52 | | std::unordered_map<std::string, bool> RaiseExceptions; |
53 | | std::unordered_map<MessageType, cmDebuggerExceptionFilter, MessageTypeHash> |
54 | | ExceptionMap; |
55 | | cm::optional<cmDebuggerException> TheException; |
56 | | |
57 | | dap::SetExceptionBreakpointsResponse HandleSetExceptionBreakpointsRequest( |
58 | | dap::SetExceptionBreakpointsRequest const& request); |
59 | | |
60 | | dap::ExceptionInfoResponse HandleExceptionInfoRequest(); |
61 | | |
62 | | public: |
63 | | cmDebuggerExceptionManager(dap::Session* dapSession); |
64 | | void HandleInitializeRequest(dap::CMakeInitializeResponse& response); |
65 | | cm::optional<dap::StoppedEvent> RaiseExceptionIfAny(MessageType t, |
66 | | std::string const& text); |
67 | | void ClearAll(); |
68 | | }; |
69 | | |
70 | | } // namespace cmDebugger |