OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "Frame.h" | 7 #include "Frame.h" |
8 #include "PageGroupLoadDeferrer.h" | 8 #include "PageGroupLoadDeferrer.h" |
9 #include "V8Proxy.h" | 9 #include "V8Proxy.h" |
10 #include <wtf/HashSet.h> | 10 #include <wtf/HashSet.h> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 // static | 115 // static |
116 void DebuggerAgentManager::DebugDetach(DebuggerAgentImpl* debugger_agent) { | 116 void DebuggerAgentManager::DebugDetach(DebuggerAgentImpl* debugger_agent) { |
117 if (!attached_agents_map_) { | 117 if (!attached_agents_map_) { |
118 NOTREACHED(); | 118 NOTREACHED(); |
119 return; | 119 return; |
120 } | 120 } |
121 int host_id = debugger_agent->webdevtools_agent()->host_id(); | 121 int host_id = debugger_agent->webdevtools_agent()->host_id(); |
122 DCHECK(attached_agents_map_->get(host_id) == debugger_agent); | 122 DCHECK(attached_agents_map_->get(host_id) == debugger_agent); |
| 123 bool is_on_breakpoint = (FindAgentForCurrentV8Context() == debugger_agent); |
123 attached_agents_map_->remove(host_id); | 124 attached_agents_map_->remove(host_id); |
124 | 125 |
125 if (attached_agents_map_->isEmpty()) { | 126 if (attached_agents_map_->isEmpty()) { |
126 delete attached_agents_map_; | 127 delete attached_agents_map_; |
127 attached_agents_map_ = NULL; | 128 attached_agents_map_ = NULL; |
128 // Note that we do not empty handlers while in dispatch - we schedule | 129 // Note that we do not empty handlers while in dispatch - we schedule |
129 // continue and do removal once we are out of the dispatch. | 130 // continue and do removal once we are out of the dispatch. Also there is |
| 131 // no need to send continue command in this case since removing message |
| 132 // handler will cause debugger unload and all breakpoints will be cleared. |
130 if (!in_host_dispatch_handler_) { | 133 if (!in_host_dispatch_handler_) { |
131 v8::Debug::SetMessageHandler2(NULL); | 134 v8::Debug::SetMessageHandler2(NULL); |
132 v8::Debug::SetHostDispatchHandler(NULL); | 135 v8::Debug::SetHostDispatchHandler(NULL); |
133 } else if (FindAgentForCurrentV8Context() == debugger_agent) { | 136 } |
134 // Force continue just in case to handle close while on a breakpoint. | 137 } else { |
| 138 // Remove all breakpoints set by the agent. |
| 139 std::wstring clear_breakpoint_group_cmd(StringPrintf( |
| 140 L"{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\"," |
| 141 L"\"arguments\":{\"groupId\":%d}}", |
| 142 host_id)); |
| 143 SendCommandToV8(WideToUTF16(clear_breakpoint_group_cmd), |
| 144 new CallerIdWrapper()); |
| 145 |
| 146 if (is_on_breakpoint) { |
| 147 // Force continue if detach happened in nessted message loop while |
| 148 // debugger was paused on a breakpoint(as long as there are other |
| 149 // attached agents v8 will wait for explicit'continue' message). |
135 SendContinueCommandToV8(); | 150 SendContinueCommandToV8(); |
136 } | 151 } |
137 } | 152 } |
138 } | 153 } |
139 | 154 |
140 // static | 155 // static |
141 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) { | 156 void DebuggerAgentManager::DebugBreak(DebuggerAgentImpl* debugger_agent) { |
142 #if USE(V8) | 157 #if USE(V8) |
143 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id()) | 158 DCHECK(DebuggerAgentForHostId(debugger_agent->webdevtools_agent()->host_id()) |
144 == debugger_agent); | 159 == debugger_agent); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return NULL; | 286 return NULL; |
272 } | 287 } |
273 | 288 |
274 // static | 289 // static |
275 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) { | 290 DebuggerAgentImpl* DebuggerAgentManager::DebuggerAgentForHostId(int host_id) { |
276 if (!attached_agents_map_) { | 291 if (!attached_agents_map_) { |
277 return NULL; | 292 return NULL; |
278 } | 293 } |
279 return attached_agents_map_->get(host_id); | 294 return attached_agents_map_->get(host_id); |
280 } | 295 } |
OLD | NEW |