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 #include "debug_continue_policy.h" | |
5 #include "debugger/core/debuggee_process.h" | |
6 #include "debugger/core/debuggee_thread.h" | |
7 | |
8 namespace { | |
9 // MS Visual C++ runtime exception. | |
10 const int kVS2008_THREAD_INFO = 0x406D1388; | |
11 } // namespace | |
12 | |
13 namespace debug { | |
14 DecisionToContinue::DecisionToContinue() | |
15 : decision_strength_(kNoDecision), | |
16 halt_debuggee_(false), | |
17 pass_exception_to_debuggee_(true) { | |
18 } | |
19 | |
20 DecisionToContinue::DecisionToContinue( | |
21 DecisionStrength strength, | |
22 HaltDebuggee halt_debuggee, | |
23 PassExceptionToDebuggee pass_exception_to_debuggee) | |
24 : decision_strength_(strength), | |
25 halt_debuggee_(kHaltDebuggee == halt_debuggee), | |
26 pass_exception_to_debuggee_( | |
27 kPassExceptionToDebuggee == pass_exception_to_debuggee) { | |
28 } | |
29 | |
30 bool DecisionToContinue::operator==(const DecisionToContinue& other) const { | |
31 return (other.decision_strength_ == decision_strength_) && | |
32 (other.halt_debuggee_ == halt_debuggee_) && | |
33 (other.pass_exception_to_debuggee_ == pass_exception_to_debuggee_); | |
34 } | |
35 | |
36 bool DecisionToContinue::Combine(const DecisionToContinue& other) { | |
37 if (other == *this) | |
38 return true; | |
39 | |
40 if (other.decision_strength_ == decision_strength_) | |
41 return false; | |
42 | |
43 if ((kStrongDecision == other.decision_strength_) || | |
44 (kNoDecision == decision_strength_)) | |
45 *this = other; | |
46 | |
47 return true; | |
48 } | |
49 | |
50 bool DecisionToContinue::halt_debuggee() const { | |
51 return halt_debuggee_; | |
52 } | |
53 | |
54 bool DecisionToContinue::pass_exception_to_debuggee() const { | |
55 return pass_exception_to_debuggee_; | |
56 } | |
57 | |
58 bool DecisionToContinue::IsHaltDecision() const { | |
59 return (kNoDecision != decision_strength_) && halt_debuggee_; | |
60 } | |
61 | |
62 void StandardContinuePolicy::MakeContinueDecision( | |
63 const DebugEvent& debug_event, | |
64 DebuggeeThread* thread, | |
65 DecisionToContinue* dtc) { | |
66 if (DebugEvent::kNotNaClDebugEvent != debug_event.nacl_debug_event_code()) { | |
67 *dtc = DecisionToContinue( | |
68 DecisionToContinue::kStrongDecision, | |
69 DecisionToContinue::kHaltDebuggee, | |
70 DecisionToContinue::kDontPassExceptionToDebuggee); | |
71 return; | |
72 } | |
73 | |
74 int exception_code = debug_event.windows_debug_event().u.Exception.ExceptionRe
cord.ExceptionCode; | |
75 if (EXCEPTION_DEBUG_EVENT == debug_event.windows_debug_event().dwDebugEventCod
e) { | |
76 if (kVS2008_THREAD_INFO == exception_code) { | |
77 dtc->Combine( | |
78 DecisionToContinue( | |
79 DecisionToContinue::kWeakDecision, | |
80 DecisionToContinue::kDontHaltDebuggee, | |
81 // DecisionToContinue::kDontPassExceptionToDebuggee)); | |
82 DecisionToContinue::kPassExceptionToDebuggee)); | |
83 } else { | |
84 bool is_nexe = false; | |
85 if (NULL != thread) | |
86 is_nexe = thread->IsNaClAppThread(); | |
87 | |
88 DecisionToContinue::PassExceptionToDebuggee pass_to_debuggee = | |
89 DecisionToContinue::kPassExceptionToDebuggee; | |
90 | |
91 if (EXCEPTION_BREAKPOINT == exception_code) | |
92 pass_to_debuggee = DecisionToContinue::kDontPassExceptionToDebuggee; | |
93 | |
94 if (is_nexe) { | |
95 dtc->Combine(DecisionToContinue( | |
96 DecisionToContinue::kWeakDecision, | |
97 DecisionToContinue::kHaltDebuggee, | |
98 pass_to_debuggee)); | |
99 } else { | |
100 dtc->Combine( | |
101 DecisionToContinue( | |
102 DecisionToContinue::kWeakDecision, | |
103 DecisionToContinue::kDontHaltDebuggee, | |
104 pass_to_debuggee)); | |
105 } | |
106 } | |
107 } | |
108 } | |
109 } // namespace debug | |
110 | |
OLD | NEW |