| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/v8_inspector/V8Debugger.h" | 5 #include "platform/v8_inspector/V8Debugger.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/DebuggerScript.h" | 7 #include "platform/v8_inspector/DebuggerScript.h" |
| 8 #include "platform/v8_inspector/ScriptBreakpoint.h" | 8 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 9 #include "platform/v8_inspector/V8Compat.h" | 9 #include "platform/v8_inspector/V8Compat.h" |
| 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
argv); | 41 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
argv); |
| 42 } | 42 } |
| 43 | 43 |
| 44 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) | 44 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) |
| 45 : m_isolate(isolate) | 45 : m_isolate(isolate) |
| 46 , m_inspector(inspector) | 46 , m_inspector(inspector) |
| 47 , m_lastContextId(0) | 47 , m_lastContextId(0) |
| 48 , m_enableCount(0) | 48 , m_enableCount(0) |
| 49 , m_breakpointsActivated(true) | 49 , m_breakpointsActivated(true) |
| 50 , m_runningNestedMessageLoop(false) | 50 , m_runningNestedMessageLoop(false) |
| 51 , m_ignoreScriptParsedEvents(false) |
| 51 , m_maxAsyncCallStackDepth(0) | 52 , m_maxAsyncCallStackDepth(0) |
| 52 { | 53 { |
| 53 } | 54 } |
| 54 | 55 |
| 55 V8Debugger::~V8Debugger() | 56 V8Debugger::~V8Debugger() |
| 56 { | 57 { |
| 57 } | 58 } |
| 58 | 59 |
| 59 void V8Debugger::enable() | 60 void V8Debugger::enable() |
| 60 { | 61 { |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 498 |
| 498 if (event == v8::AsyncTaskEvent) { | 499 if (event == v8::AsyncTaskEvent) { |
| 499 v8::HandleScope scope(m_isolate); | 500 v8::HandleScope scope(m_isolate); |
| 500 handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), e
ventDetails.GetEventData()); | 501 handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), e
ventDetails.GetEventData()); |
| 501 return; | 502 return; |
| 502 } | 503 } |
| 503 | 504 |
| 504 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGr
oupId(eventContext)); | 505 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGr
oupId(eventContext)); |
| 505 if (agent) { | 506 if (agent) { |
| 506 v8::HandleScope scope(m_isolate); | 507 v8::HandleScope scope(m_isolate); |
| 507 if (event == v8::AfterCompile || event == v8::CompileError) { | 508 if (!m_ignoreScriptParsedEvents && (event == v8::AfterCompile || event =
= v8::CompileError)) { |
| 508 v8::Context::Scope contextScope(debuggerContext()); | 509 v8::Context::Scope contextScope(debuggerContext()); |
| 509 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; | 510 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; |
| 510 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri
pt", 1, argv).ToLocalChecked(); | 511 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri
pt", 1, argv).ToLocalChecked(); |
| 511 DCHECK(value->IsObject()); | 512 DCHECK(value->IsObject()); |
| 512 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(val
ue); | 513 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(val
ue); |
| 513 agent->didParseSource(wrapUnique(new V8DebuggerScript(m_isolate, scr
iptObject, inLiveEditScope)), event == v8::AfterCompile); | 514 agent->didParseSource(wrapUnique(new V8DebuggerScript(m_isolate, scr
iptObject, inLiveEditScope)), event == v8::AfterCompile); |
| 514 } else if (event == v8::Exception) { | 515 } else if (event == v8::Exception) { |
| 515 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); | 516 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); |
| 516 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat
a, "exception"); | 517 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat
a, "exception"); |
| 517 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData,
"promise"); | 518 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData,
"promise"); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 } | 800 } |
| 800 | 801 |
| 801 void V8Debugger::allAsyncTasksCanceled() | 802 void V8Debugger::allAsyncTasksCanceled() |
| 802 { | 803 { |
| 803 m_asyncTaskStacks.clear(); | 804 m_asyncTaskStacks.clear(); |
| 804 m_recurringTasks.clear(); | 805 m_recurringTasks.clear(); |
| 805 m_currentStacks.clear(); | 806 m_currentStacks.clear(); |
| 806 m_currentTasks.clear(); | 807 m_currentTasks.clear(); |
| 807 } | 808 } |
| 808 | 809 |
| 810 void V8Debugger::setIgnoreScriptParsedEvents(bool ignore) |
| 811 { |
| 812 m_ignoreScriptParsedEvents = ignore; |
| 813 } |
| 814 |
| 809 std::unique_ptr<V8StackTraceImpl> V8Debugger::captureStackTrace(bool fullStack) | 815 std::unique_ptr<V8StackTraceImpl> V8Debugger::captureStackTrace(bool fullStack) |
| 810 { | 816 { |
| 811 if (!m_isolate->InContext()) | 817 if (!m_isolate->InContext()) |
| 812 return nullptr; | 818 return nullptr; |
| 813 | 819 |
| 814 v8::HandleScope handles(m_isolate); | 820 v8::HandleScope handles(m_isolate); |
| 815 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); | 821 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); |
| 816 if (!contextGroupId) | 822 if (!contextGroupId) |
| 817 return nullptr; | 823 return nullptr; |
| 818 | 824 |
| 819 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 825 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
| 820 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 826 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 821 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 827 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 822 | 828 |
| 823 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 829 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 824 } | 830 } |
| 825 | 831 |
| 826 } // namespace blink | 832 } // namespace blink |
| OLD | NEW |