Chromium Code Reviews| 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 | 569 |
| 570 if (event == v8::AsyncTaskEvent) { | 570 if (event == v8::AsyncTaskEvent) { |
| 571 v8::HandleScope scope(m_isolate); | 571 v8::HandleScope scope(m_isolate); |
| 572 handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), | 572 handleV8AsyncTaskEvent(eventContext, eventDetails.GetExecutionState(), |
| 573 eventDetails.GetEventData()); | 573 eventDetails.GetEventData()); |
| 574 return; | 574 return; |
| 575 } | 575 } |
| 576 | 576 |
| 577 V8DebuggerAgentImpl* agent = | 577 V8DebuggerAgentImpl* agent = |
| 578 m_inspector->enabledDebuggerAgentForGroup(getGroupId(eventContext)); | 578 m_inspector->enabledDebuggerAgentForGroup(getGroupId(eventContext)); |
| 579 if (agent) { | 579 if (!agent) return; |
| 580 v8::HandleScope scope(m_isolate); | 580 |
| 581 if (m_ignoreScriptParsedEventsCounter == 0 && | 581 v8::HandleScope scope(m_isolate); |
| 582 (event == v8::AfterCompile || event == v8::CompileError)) { | 582 if (event == v8::AfterCompile || event == v8::CompileError) { |
| 583 v8::Local<v8::Context> context = debuggerContext(); | 583 v8::Context::Scope contextScope(debuggerContext()); |
| 584 v8::Context::Scope contextScope(context); | 584 // Determine if it is a wasm script by checking whether the source url |
|
dgozman
2016/11/11 21:50:34
Why not expose isWasmScript or similar?
Clemens Hammacher
2016/11/16 11:36:28
Added "isWasm" method to script wrapper.
| |
| 585 // starts with "wasm://". | |
| 586 v8::Local<v8::Value> scriptMirror = | |
| 587 callInternalGetterFunction(eventDetails.GetEventData(), "script"); | |
| 588 DCHECK(scriptMirror->IsObject()); | |
| 589 v8::Local<v8::Value> scriptWrapper = | |
| 590 callInternalGetterFunction(scriptMirror.As<v8::Object>(), "value"); | |
| 591 DCHECK(scriptWrapper->IsObject()); | |
| 592 v8::Local<v8::Value> sourceUrl = callInternalGetterFunction( | |
| 593 scriptWrapper.As<v8::Object>(), "nameOrSourceURL"); | |
| 594 char sourceUrlStart[7]; | |
|
titzer
2016/11/11 10:59:02
Can you factor this code out into a "startsWith" h
Clemens Hammacher
2016/11/16 11:36:28
Obsolete with the isWasm method.
| |
| 595 int written = sourceUrl->IsString() | |
| 596 ? sourceUrl.As<v8::String>()->WriteUtf8( | |
| 597 sourceUrlStart, sizeof(sourceUrlStart)) | |
| 598 : 0; | |
| 599 bool isWasmScript = | |
| 600 written == sizeof(sourceUrlStart) && | |
| 601 !memcmp(sourceUrlStart, "wasm://", sizeof(sourceUrlStart)); | |
| 602 if (isWasmScript) { | |
| 603 agent->newWasmScript(scriptWrapper.As<v8::Object>()); | |
| 604 } else if (m_ignoreScriptParsedEventsCounter == 0) { | |
| 585 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()}; | 605 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()}; |
| 586 v8::Local<v8::Value> value = | 606 v8::Local<v8::Value> value = |
| 587 callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked(); | 607 callDebuggerMethod("getAfterCompileScript", 1, argv).ToLocalChecked(); |
| 588 if (value->IsNull()) return; | 608 if (value->IsNull()) return; |
| 589 DCHECK(value->IsObject()); | 609 DCHECK(value->IsObject()); |
| 590 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value); | 610 v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value); |
| 591 v8::Local<v8::DebugInterface::Script> script; | 611 v8::Local<v8::DebugInterface::Script> script; |
| 592 if (!v8::DebugInterface::Script::Wrap(m_isolate, scriptObject) | 612 if (!v8::DebugInterface::Script::Wrap(m_isolate, scriptObject) |
| 593 .ToLocal(&script)) | 613 .ToLocal(&script)) |
| 594 return; | 614 return; |
| 595 agent->didParseSource( | 615 agent->didParseSource( |
| 596 wrapUnique(new V8DebuggerScript(m_isolate, script, inLiveEditScope)), | 616 wrapUnique(new V8DebuggerScript(m_isolate, script, inLiveEditScope)), |
| 597 event == v8::AfterCompile); | 617 event == v8::AfterCompile); |
| 598 } else if (event == v8::Exception) { | |
| 599 v8::Local<v8::Context> context = debuggerContext(); | |
| 600 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); | |
| 601 v8::Local<v8::Value> exception = | |
| 602 callInternalGetterFunction(eventData, "exception"); | |
| 603 v8::Local<v8::Value> promise = | |
| 604 callInternalGetterFunction(eventData, "promise"); | |
| 605 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject(); | |
| 606 v8::Local<v8::Value> uncaught = | |
| 607 callInternalGetterFunction(eventData, "uncaught"); | |
| 608 bool isUncaught = uncaught->BooleanValue(context).FromJust(); | |
| 609 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), | |
| 610 exception, v8::Local<v8::Array>(), isPromiseRejection, | |
| 611 isUncaught); | |
| 612 } else if (event == v8::Break) { | |
| 613 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()}; | |
| 614 v8::Local<v8::Value> hitBreakpoints = | |
| 615 callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked(); | |
| 616 DCHECK(hitBreakpoints->IsArray()); | |
| 617 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), | |
| 618 v8::Local<v8::Value>(), | |
| 619 hitBreakpoints.As<v8::Array>()); | |
| 620 } | 618 } |
| 619 } else if (event == v8::Exception) { | |
| 620 v8::Local<v8::Context> context = debuggerContext(); | |
| 621 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); | |
| 622 v8::Local<v8::Value> exception = | |
| 623 callInternalGetterFunction(eventData, "exception"); | |
| 624 v8::Local<v8::Value> promise = | |
| 625 callInternalGetterFunction(eventData, "promise"); | |
| 626 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject(); | |
| 627 v8::Local<v8::Value> uncaught = | |
| 628 callInternalGetterFunction(eventData, "uncaught"); | |
| 629 bool isUncaught = uncaught->BooleanValue(context).FromJust(); | |
| 630 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), | |
| 631 exception, v8::Local<v8::Array>(), isPromiseRejection, | |
| 632 isUncaught); | |
| 633 } else if (event == v8::Break) { | |
| 634 v8::Local<v8::Value> argv[] = {eventDetails.GetEventData()}; | |
| 635 v8::Local<v8::Value> hitBreakpoints = | |
| 636 callDebuggerMethod("getBreakpointNumbers", 1, argv).ToLocalChecked(); | |
| 637 DCHECK(hitBreakpoints->IsArray()); | |
| 638 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), | |
| 639 v8::Local<v8::Value>(), hitBreakpoints.As<v8::Array>()); | |
| 621 } | 640 } |
| 622 } | 641 } |
| 623 | 642 |
| 624 void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, | 643 void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, |
| 625 v8::Local<v8::Object> executionState, | 644 v8::Local<v8::Object> executionState, |
| 626 v8::Local<v8::Object> eventData) { | 645 v8::Local<v8::Object> eventData) { |
| 627 if (!m_maxAsyncCallStackDepth) return; | 646 if (!m_maxAsyncCallStackDepth) return; |
| 628 | 647 |
| 629 String16 type = toProtocolStringWithTypeCheck( | 648 String16 type = toProtocolStringWithTypeCheck( |
| 630 callInternalGetterFunction(eventData, "type")); | 649 callInternalGetterFunction(eventData, "type")); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 979 | 998 |
| 980 size_t stackSize = | 999 size_t stackSize = |
| 981 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 1000 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 982 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 1001 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 983 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 1002 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 984 | 1003 |
| 985 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1004 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 986 } | 1005 } |
| 987 | 1006 |
| 988 } // namespace v8_inspector | 1007 } // namespace v8_inspector |
| OLD | NEW |