OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "wtf/StdLibExtras.h" | 41 #include "wtf/StdLibExtras.h" |
42 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
43 #include "wtf/dtoa/utils.h" | 43 #include "wtf/dtoa/utils.h" |
44 #include "wtf/text/CString.h" | 44 #include "wtf/text/CString.h" |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 namespace { | 48 namespace { |
49 const char stepIntoV8MethodName[] = "stepIntoStatement"; | 49 const char stepIntoV8MethodName[] = "stepIntoStatement"; |
50 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 50 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
| 51 static const unsigned kBlackboxUnknown = 0; |
| 52 } |
| 53 |
| 54 V8Debugger::Script::Script() |
| 55 : m_startLine(0) |
| 56 , m_startColumn(0) |
| 57 , m_endLine(0) |
| 58 , m_endColumn(0) |
| 59 , m_isContentScript(false) |
| 60 , m_isBlackboxedURL(false) |
| 61 , m_blackboxGeneration(kBlackboxUnknown) |
| 62 { |
| 63 } |
| 64 |
| 65 String V8Debugger::Script::sourceURL() const |
| 66 { |
| 67 return m_sourceURL.isEmpty() ? m_url : m_sourceURL; |
| 68 } |
| 69 |
| 70 bool V8Debugger::Script::getBlackboxedState(unsigned blackboxGeneration, bool* i
sBlackboxed) const |
| 71 { |
| 72 if (m_blackboxGeneration == kBlackboxUnknown || m_blackboxGeneration != blac
kboxGeneration) |
| 73 return false; |
| 74 *isBlackboxed = m_isBlackboxedURL; |
| 75 return true; |
| 76 } |
| 77 |
| 78 void V8Debugger::Script::setBlackboxedState(unsigned blackboxGeneration, bool is
Blackboxed) |
| 79 { |
| 80 ASSERT(blackboxGeneration); |
| 81 m_isBlackboxedURL = isBlackboxed; |
| 82 m_blackboxGeneration = blackboxGeneration; |
| 83 } |
| 84 |
| 85 V8Debugger::Script& V8Debugger::Script::setURL(const String& url) |
| 86 { |
| 87 m_url = url; |
| 88 m_blackboxGeneration = kBlackboxUnknown; |
| 89 return *this; |
| 90 } |
| 91 |
| 92 V8Debugger::Script& V8Debugger::Script::setSourceURL(const String& sourceURL) |
| 93 { |
| 94 m_sourceURL = sourceURL; |
| 95 m_blackboxGeneration = kBlackboxUnknown; |
| 96 return *this; |
| 97 } |
| 98 |
| 99 V8Debugger::Script& V8Debugger::Script::setSourceMappingURL(const String& source
MappingURL) |
| 100 { |
| 101 m_sourceMappingURL = sourceMappingURL; |
| 102 return *this; |
| 103 } |
| 104 |
| 105 V8Debugger::Script& V8Debugger::Script::setSource(const String& source) |
| 106 { |
| 107 m_source = source; |
| 108 return *this; |
| 109 } |
| 110 |
| 111 V8Debugger::Script& V8Debugger::Script::setStartLine(int startLine) |
| 112 { |
| 113 m_startLine = startLine; |
| 114 return *this; |
| 115 } |
| 116 |
| 117 V8Debugger::Script& V8Debugger::Script::setStartColumn(int startColumn) |
| 118 { |
| 119 m_startColumn = startColumn; |
| 120 return *this; |
| 121 } |
| 122 |
| 123 V8Debugger::Script& V8Debugger::Script::setEndLine(int endLine) |
| 124 { |
| 125 m_endLine = endLine; |
| 126 return *this; |
| 127 } |
| 128 |
| 129 V8Debugger::Script& V8Debugger::Script::setEndColumn(int endColumn) |
| 130 { |
| 131 m_endColumn = endColumn; |
| 132 return *this; |
| 133 } |
| 134 |
| 135 V8Debugger::Script& V8Debugger::Script::setIsContentScript(bool isContentScript) |
| 136 { |
| 137 m_isContentScript = isContentScript; |
| 138 return *this; |
| 139 } |
| 140 |
| 141 V8Debugger::Script& V8Debugger::Script::setIsInternalScript(bool isInternalScrip
t) |
| 142 { |
| 143 m_isInternalScript = isInternalScript; |
| 144 return *this; |
51 } | 145 } |
52 | 146 |
53 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionNam
e, int argc, v8::Local<v8::Value> argv[]) | 147 v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionNam
e, int argc, v8::Local<v8::Value> argv[]) |
54 { | 148 { |
55 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); | 149 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); |
56 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); | 150 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); |
57 ASSERT(m_isolate->InContext()); | 151 ASSERT(m_isolate->InContext()); |
58 return V8ScriptRunner::callInternalFunction(function, debuggerScript, argc,
argv, m_isolate); | 152 return V8ScriptRunner::callInternalFunction(function, debuggerScript, argc,
argv, m_isolate); |
59 } | 153 } |
60 | 154 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return !m_debuggerScript.IsEmpty(); | 193 return !m_debuggerScript.IsEmpty(); |
100 } | 194 } |
101 | 195 |
102 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin
g& contextDebugData) | 196 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin
g& contextDebugData) |
103 { | 197 { |
104 v8::HandleScope scope(context->GetIsolate()); | 198 v8::HandleScope scope(context->GetIsolate()); |
105 v8::Context::Scope contextScope(context); | 199 v8::Context::Scope contextScope(context); |
106 context->SetEmbedderData(static_cast<int>(gin::kDebugIdIndex), v8String(cont
ext->GetIsolate(), contextDebugData)); | 200 context->SetEmbedderData(static_cast<int>(gin::kDebugIdIndex), v8String(cont
ext->GetIsolate(), contextDebugData)); |
107 } | 201 } |
108 | 202 |
109 void V8Debugger::getCompiledScripts(const String& contextDebugDataSubstring, Vec
tor<ScriptDebugListener::ParsedScript>& result) | 203 void V8Debugger::getCompiledScripts(const String& contextDebugDataSubstring, Vec
tor<ParsedScript>& result) |
110 { | 204 { |
111 v8::HandleScope scope(m_isolate); | 205 v8::HandleScope scope(m_isolate); |
112 v8::Context::Scope contextScope(debuggerContext()); | 206 v8::Context::Scope contextScope(debuggerContext()); |
113 | 207 |
114 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); | 208 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); |
115 ASSERT(!debuggerScript->IsUndefined()); | 209 ASSERT(!debuggerScript->IsUndefined()); |
116 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); | 210 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); |
117 v8::Local<v8::Value> argv[] = { v8String(m_isolate, contextDebugDataSubstrin
g) }; | 211 v8::Local<v8::Value> argv[] = { v8String(m_isolate, contextDebugDataSubstrin
g) }; |
118 v8::Local<v8::Value> value; | 212 v8::Local<v8::Value> value; |
119 if (!V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript
, WTF_ARRAY_LENGTH(argv), argv, m_isolate).ToLocal(&value)) | 213 if (!V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript
, WTF_ARRAY_LENGTH(argv), argv, m_isolate).ToLocal(&value)) |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 breakpointIds.resize(hitBreakpointNumbers->Length()); | 589 breakpointIds.resize(hitBreakpointNumbers->Length()); |
496 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 590 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
497 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); | 591 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); |
498 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); | 592 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); |
499 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; | 593 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; |
500 } | 594 } |
501 } | 595 } |
502 | 596 |
503 m_pausedScriptState = pausedScriptState; | 597 m_pausedScriptState = pausedScriptState; |
504 m_executionState = executionState; | 598 m_executionState = executionState; |
505 ScriptDebugListener::SkipPauseRequest result = listener->didPause(pausedScri
ptState, currentCallFrames(), ScriptValue(pausedScriptState, exception), breakpo
intIds, isPromiseRejection); | 599 SkipPauseRequest result = listener->didPause(pausedScriptState, currentCallF
rames(), ScriptValue(pausedScriptState, exception), breakpointIds, isPromiseReje
ction); |
506 if (result == ScriptDebugListener::NoSkip) { | 600 if (result == NoSkip) { |
507 m_runningNestedMessageLoop = true; | 601 m_runningNestedMessageLoop = true; |
508 m_client->runMessageLoopOnPause(pausedScriptState->context()); | 602 m_client->runMessageLoopOnPause(pausedScriptState->context()); |
509 m_runningNestedMessageLoop = false; | 603 m_runningNestedMessageLoop = false; |
510 } | 604 } |
511 m_pausedScriptState.clear(); | 605 m_pausedScriptState.clear(); |
512 m_executionState.Clear(); | 606 m_executionState.Clear(); |
513 | 607 |
514 if (result == ScriptDebugListener::StepFrame) { | 608 if (result == StepFrame) { |
515 v8::Local<v8::Value> argv[] = { executionState }; | 609 v8::Local<v8::Value> argv[] = { executionState }; |
516 callDebuggerMethod("stepFrameStatement", 1, argv); | 610 callDebuggerMethod("stepFrameStatement", 1, argv); |
517 } else if (result == ScriptDebugListener::StepInto) { | 611 } else if (result == StepInto) { |
518 v8::Local<v8::Value> argv[] = { executionState }; | 612 v8::Local<v8::Value> argv[] = { executionState }; |
519 callDebuggerMethod(stepIntoV8MethodName, 1, argv); | 613 callDebuggerMethod(stepIntoV8MethodName, 1, argv); |
520 } else if (result == ScriptDebugListener::StepOut) { | 614 } else if (result == StepOut) { |
521 v8::Local<v8::Value> argv[] = { executionState }; | 615 v8::Local<v8::Value> argv[] = { executionState }; |
522 callDebuggerMethod(stepOutV8MethodName, 1, argv); | 616 callDebuggerMethod(stepOutV8MethodName, 1, argv); |
523 } | 617 } |
524 } | 618 } |
525 | 619 |
526 void V8Debugger::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetail
s) | 620 void V8Debugger::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetail
s) |
527 { | 621 { |
528 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); | 622 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); |
529 thisPtr->handleV8DebugEvent(eventDetails); | 623 thisPtr->handleV8DebugEvent(eventDetails); |
530 } | 624 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 int status = promiseDetails->Get(v8InternalizedString("status"))->ToInteger(
m_isolate)->Value(); | 695 int status = promiseDetails->Get(v8InternalizedString("status"))->ToInteger(
m_isolate)->Value(); |
602 v8::Local<v8::Value> parentPromise = promiseDetails->Get(v8InternalizedStrin
g("parentPromise")); | 696 v8::Local<v8::Value> parentPromise = promiseDetails->Get(v8InternalizedStrin
g("parentPromise")); |
603 | 697 |
604 m_pausedScriptState = pausedScriptState; | 698 m_pausedScriptState = pausedScriptState; |
605 m_executionState = executionState; | 699 m_executionState = executionState; |
606 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise
, status); | 700 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise
, status); |
607 m_pausedScriptState.clear(); | 701 m_pausedScriptState.clear(); |
608 m_executionState.Clear(); | 702 m_executionState.Clear(); |
609 } | 703 } |
610 | 704 |
611 ScriptDebugListener::ParsedScript V8Debugger::createParsedScript(v8::Local<v8::O
bject> object, CompileResult compileResult) | 705 V8Debugger::ParsedScript V8Debugger::createParsedScript(v8::Local<v8::Object> ob
ject, CompileResult compileResult) |
612 { | 706 { |
613 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); | 707 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); |
614 ASSERT(!id.IsEmpty() && id->IsInt32()); | 708 ASSERT(!id.IsEmpty() && id->IsInt32()); |
615 | 709 |
616 ScriptDebugListener::ParsedScript parsedScript; | 710 ParsedScript parsedScript; |
617 parsedScript.scriptId = String::number(id->Int32Value()); | 711 parsedScript.scriptId = String::number(id->Int32Value()); |
618 parsedScript.script.setURL(toCoreStringWithUndefinedOrNullCheck(object->Get(
v8InternalizedString("name")))) | 712 parsedScript.script.setURL(toCoreStringWithUndefinedOrNullCheck(object->Get(
v8InternalizedString("name")))) |
619 .setSourceURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Interna
lizedString("sourceURL")))) | 713 .setSourceURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Interna
lizedString("sourceURL")))) |
620 .setSourceMappingURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8
InternalizedString("sourceMappingURL")))) | 714 .setSourceMappingURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8
InternalizedString("sourceMappingURL")))) |
621 .setSource(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Internaliz
edString("source")))) | 715 .setSource(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Internaliz
edString("source")))) |
622 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(
m_isolate)->Value()) | 716 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(
m_isolate)->Value()) |
623 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte
ger(m_isolate)->Value()) | 717 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte
ger(m_isolate)->Value()) |
624 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is
olate)->Value()) | 718 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is
olate)->Value()) |
625 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(
m_isolate)->Value()) | 719 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(
m_isolate)->Value()) |
626 .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))
->ToBoolean(m_isolate)->Value()) | 720 .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))
->ToBoolean(m_isolate)->Value()) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 800 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
707 } | 801 } |
708 | 802 |
709 | 803 |
710 bool V8Debugger::isPaused() | 804 bool V8Debugger::isPaused() |
711 { | 805 { |
712 return m_pausedScriptState; | 806 return m_pausedScriptState; |
713 } | 807 } |
714 | 808 |
715 } // namespace blink | 809 } // namespace blink |
OLD | NEW |