OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef DEBUGGER_CORE_DEBUG_CONTINUE_POLICY_H_ | |
6 #define DEBUGGER_CORE_DEBUG_CONTINUE_POLICY_H_ | |
7 | |
8 #include <windows.h> | |
9 #include "debugger/core/debug_event.h" | |
10 | |
11 namespace debug { | |
12 class DebuggeeThread; | |
13 | |
14 /// \brief This class represents information about decision of debugger | |
15 /// to continue execution of the child or halt it. | |
16 | |
17 /// Once debugger gets debug event, it has an option to | |
18 /// continue a debuggee thread or not. | |
19 /// |DecisionToContinue| allows several entities to take part in | |
20 /// decision making. | |
21 class DecisionToContinue { | |
22 public: | |
23 /// kNoDecision - no decision yet | |
24 /// kWeakDecision - weak decision, can be overwritten | |
25 /// kStrongDecision - really strong decision | |
26 enum DecisionStrength {kNoDecision, kWeakDecision, kStrongDecision}; | |
27 | |
28 /// kDontHaltDebuggee - continue debuggee thread | |
29 /// kHaltDebuggee - halt debugee thread | |
30 enum HaltDebuggee {kDontHaltDebuggee, kHaltDebuggee}; | |
31 | |
32 /// Debugger can either pass exception to debugee or not. | |
33 /// kPassExceptionToDebuggee - debugger will pass exception | |
34 /// kDontPassExceptionToDebuggee - debugger will not pass exception | |
35 enum PassExceptionToDebuggee {kPassExceptionToDebuggee, | |
36 kDontPassExceptionToDebuggee}; | |
37 DecisionToContinue(); | |
38 DecisionToContinue(DecisionStrength strength, | |
39 HaltDebuggee halt_debuggee, | |
40 PassExceptionToDebuggee pass_exception_to_debuggee); | |
41 bool operator==(const DecisionToContinue& other) const; | |
42 | |
43 /// If the decision strength of |other| is stronger than |this| object, | |
44 /// then |this| is overwritten with |other| . | |
45 /// @return false if decisions are incompatible. | |
46 bool Combine(const DecisionToContinue& other); | |
47 | |
48 bool IsHaltDecision() const; | |
49 DecisionStrength decision_strength() const { | |
50 return decision_strength_; | |
51 } | |
52 bool halt_debuggee() const; | |
53 bool pass_exception_to_debuggee() const; | |
54 | |
55 public: | |
56 DecisionStrength decision_strength_; | |
57 bool halt_debuggee_; | |
58 bool pass_exception_to_debuggee_; | |
59 }; | |
60 | |
61 /// \brief This class represents entity that can make a decision | |
62 /// to continue execution of the child or halt it. | |
63 | |
64 /// It's a base for whatever complicated policy we might | |
65 /// want to have in the future. | |
66 class ContinuePolicy { | |
67 public: | |
68 ContinuePolicy() {} | |
69 virtual ~ContinuePolicy() {} | |
70 | |
71 /// Makes a continue decision. | |
72 /// @param[in] debug_event debug event | |
73 /// @param[in] thread debuggee thread that needs decision | |
74 /// @param[in,out] dtc decision to continue | |
75 virtual void MakeContinueDecision(const DebugEvent& debug_event, | |
76 DebuggeeThread* thread, | |
77 DecisionToContinue* dtc) = 0; | |
78 }; | |
79 | |
80 /// This class represents default 'continue or halt' policy. | |
81 | |
82 /// For native-native (trusted) threads it decides not to halt, | |
83 /// and pass exceptions to the debuggee, except breakpoint event. | |
84 /// For NaCl (untrusted) threads, it weakly decides to halt on | |
85 /// all exceptions. | |
86 class StandardContinuePolicy : public ContinuePolicy { | |
87 public: | |
88 /// Makes a continue decision. | |
89 /// @param[in] debug_event debug event | |
90 /// @param[in] thread debuggee thread that needs decision | |
91 /// @param[in,out] dtc decision to continue | |
92 virtual void MakeContinueDecision(const DebugEvent& debug_event, | |
93 DebuggeeThread* thread, | |
94 DecisionToContinue* dtc); | |
95 }; | |
96 } // namespace debug | |
97 #endif // DEBUGGER_CORE_DEBUG_CONTINUE_POLICY_H_ | |
98 | |
OLD | NEW |