| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/inspector/v8-debugger.h" | 5 #include "src/inspector/v8-debugger.h" |
| 6 | 6 |
| 7 #include "src/inspector/debugger-script.h" | 7 #include "src/inspector/debugger-script.h" |
| 8 #include "src/inspector/protocol/Protocol.h" | 8 #include "src/inspector/protocol/Protocol.h" |
| 9 #include "src/inspector/script-breakpoint.h" | 9 #include "src/inspector/script-breakpoint.h" |
| 10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) | 50 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) |
| 51 : m_isolate(isolate), | 51 : m_isolate(isolate), |
| 52 m_inspector(inspector), | 52 m_inspector(inspector), |
| 53 m_lastContextId(0), | 53 m_lastContextId(0), |
| 54 m_enableCount(0), | 54 m_enableCount(0), |
| 55 m_breakpointsActivated(true), | 55 m_breakpointsActivated(true), |
| 56 m_runningNestedMessageLoop(false), | 56 m_runningNestedMessageLoop(false), |
| 57 m_ignoreScriptParsedEventsCounter(0), | 57 m_ignoreScriptParsedEventsCounter(0), |
| 58 m_maxAsyncCallStackDepth(0) {} | 58 m_maxAsyncCallStackDepth(0), |
| 59 m_pauseOnExceptionsState(v8::DebugInterface::NoBreakOnException) {} |
| 59 | 60 |
| 60 V8Debugger::~V8Debugger() {} | 61 V8Debugger::~V8Debugger() {} |
| 61 | 62 |
| 62 void V8Debugger::enable() { | 63 void V8Debugger::enable() { |
| 63 if (m_enableCount++) return; | 64 if (m_enableCount++) return; |
| 64 DCHECK(!enabled()); | 65 DCHECK(!enabled()); |
| 65 v8::HandleScope scope(m_isolate); | 66 v8::HandleScope scope(m_isolate); |
| 66 v8::DebugInterface::SetDebugEventListener(m_isolate, | 67 v8::DebugInterface::SetDebugEventListener(m_isolate, |
| 67 &V8Debugger::v8DebugEventCallback, | 68 &V8Debugger::v8DebugEventCallback, |
| 68 v8::External::New(m_isolate, this)); | 69 v8::External::New(m_isolate, this)); |
| 69 m_debuggerContext.Reset(m_isolate, | 70 m_debuggerContext.Reset(m_isolate, |
| 70 v8::DebugInterface::GetDebugContext(m_isolate)); | 71 v8::DebugInterface::GetDebugContext(m_isolate)); |
| 72 v8::DebugInterface::ChangeBreakOnException( |
| 73 m_isolate, v8::DebugInterface::NoBreakOnException); |
| 74 m_pauseOnExceptionsState = v8::DebugInterface::NoBreakOnException; |
| 71 compileDebuggerScript(); | 75 compileDebuggerScript(); |
| 72 } | 76 } |
| 73 | 77 |
| 74 void V8Debugger::disable() { | 78 void V8Debugger::disable() { |
| 75 if (--m_enableCount) return; | 79 if (--m_enableCount) return; |
| 76 DCHECK(enabled()); | 80 DCHECK(enabled()); |
| 77 clearBreakpoints(); | 81 clearBreakpoints(); |
| 78 m_debuggerScript.Reset(); | 82 m_debuggerScript.Reset(); |
| 79 m_debuggerContext.Reset(); | 83 m_debuggerContext.Reset(); |
| 80 allAsyncTasksCanceled(); | 84 allAsyncTasksCanceled(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 m_debuggerScript.Get(m_isolate) | 249 m_debuggerScript.Get(m_isolate) |
| 246 ->Get(context, toV8StringInternalized(m_isolate, | 250 ->Get(context, toV8StringInternalized(m_isolate, |
| 247 "setBreakpointsActivated")) | 251 "setBreakpointsActivated")) |
| 248 .ToLocalChecked()); | 252 .ToLocalChecked()); |
| 249 v8::DebugInterface::Call(debuggerContext(), setBreakpointsActivated, info) | 253 v8::DebugInterface::Call(debuggerContext(), setBreakpointsActivated, info) |
| 250 .ToLocalChecked(); | 254 .ToLocalChecked(); |
| 251 | 255 |
| 252 m_breakpointsActivated = activated; | 256 m_breakpointsActivated = activated; |
| 253 } | 257 } |
| 254 | 258 |
| 255 V8Debugger::PauseOnExceptionsState V8Debugger::getPauseOnExceptionsState() { | 259 v8::DebugInterface::ExceptionBreakState |
| 260 V8Debugger::getPauseOnExceptionsState() { |
| 256 DCHECK(enabled()); | 261 DCHECK(enabled()); |
| 257 v8::HandleScope scope(m_isolate); | 262 return m_pauseOnExceptionsState; |
| 258 v8::Local<v8::Context> context = debuggerContext(); | |
| 259 v8::Context::Scope contextScope(context); | |
| 260 | |
| 261 v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)}; | |
| 262 v8::Local<v8::Value> result = | |
| 263 callDebuggerMethod("pauseOnExceptionsState", 0, argv).ToLocalChecked(); | |
| 264 return static_cast<V8Debugger::PauseOnExceptionsState>( | |
| 265 result->Int32Value(context).FromJust()); | |
| 266 } | 263 } |
| 267 | 264 |
| 268 void V8Debugger::setPauseOnExceptionsState( | 265 void V8Debugger::setPauseOnExceptionsState( |
| 269 PauseOnExceptionsState pauseOnExceptionsState) { | 266 v8::DebugInterface::ExceptionBreakState pauseOnExceptionsState) { |
| 270 DCHECK(enabled()); | 267 DCHECK(enabled()); |
| 271 v8::HandleScope scope(m_isolate); | 268 if (m_pauseOnExceptionsState == pauseOnExceptionsState) return; |
| 272 v8::Context::Scope contextScope(debuggerContext()); | 269 v8::DebugInterface::ChangeBreakOnException(m_isolate, pauseOnExceptionsState); |
| 273 | 270 m_pauseOnExceptionsState = pauseOnExceptionsState; |
| 274 v8::Local<v8::Value> argv[] = { | |
| 275 v8::Int32::New(m_isolate, pauseOnExceptionsState)}; | |
| 276 callDebuggerMethod("setPauseOnExceptionsState", 1, argv); | |
| 277 } | 271 } |
| 278 | 272 |
| 279 void V8Debugger::setPauseOnNextStatement(bool pause) { | 273 void V8Debugger::setPauseOnNextStatement(bool pause) { |
| 280 if (m_runningNestedMessageLoop) return; | 274 if (m_runningNestedMessageLoop) return; |
| 281 if (pause) | 275 if (pause) |
| 282 v8::DebugInterface::DebugBreak(m_isolate); | 276 v8::DebugInterface::DebugBreak(m_isolate); |
| 283 else | 277 else |
| 284 v8::DebugInterface::CancelDebugBreak(m_isolate); | 278 v8::DebugInterface::CancelDebugBreak(m_isolate); |
| 285 } | 279 } |
| 286 | 280 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 | 991 |
| 998 size_t stackSize = | 992 size_t stackSize = |
| 999 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 993 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 1000 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 994 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 1001 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 995 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 1002 | 996 |
| 1003 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 997 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 1004 } | 998 } |
| 1005 | 999 |
| 1006 } // namespace v8_inspector | 1000 } // namespace v8_inspector |
| OLD | NEW |