| 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 22 matching lines...) Expand all Loading... |
| 33 #include "platform/inspector_protocol/Values.h" | 33 #include "platform/inspector_protocol/Values.h" |
| 34 #include "platform/v8_inspector/Atomics.h" | 34 #include "platform/v8_inspector/Atomics.h" |
| 35 #include "platform/v8_inspector/DebuggerScript.h" | 35 #include "platform/v8_inspector/DebuggerScript.h" |
| 36 #include "platform/v8_inspector/JavaScriptCallFrame.h" | 36 #include "platform/v8_inspector/JavaScriptCallFrame.h" |
| 37 #include "platform/v8_inspector/ScriptBreakpoint.h" | 37 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 38 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 38 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 39 #include "platform/v8_inspector/V8JavaScriptCallFrame.h" | 39 #include "platform/v8_inspector/V8JavaScriptCallFrame.h" |
| 40 #include "platform/v8_inspector/V8StackTraceImpl.h" | 40 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 41 #include "platform/v8_inspector/V8StringUtil.h" | 41 #include "platform/v8_inspector/V8StringUtil.h" |
| 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 42 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 43 #include "wtf/Vector.h" | |
| 44 | 43 |
| 45 namespace blink { | 44 namespace blink { |
| 46 | 45 |
| 47 namespace { | 46 namespace { |
| 48 const char stepIntoV8MethodName[] = "stepIntoStatement"; | 47 const char stepIntoV8MethodName[] = "stepIntoStatement"; |
| 49 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 48 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
| 50 volatile int s_lastContextId = 0; | 49 volatile int s_lastContextId = 0; |
| 51 | 50 |
| 52 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) | 51 inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) |
| 53 { | 52 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 148 } |
| 150 | 149 |
| 151 void V8DebuggerImpl::addAgent(int contextGroupId, V8DebuggerAgentImpl* agent) | 150 void V8DebuggerImpl::addAgent(int contextGroupId, V8DebuggerAgentImpl* agent) |
| 152 { | 151 { |
| 153 ASSERT(contextGroupId); | 152 ASSERT(contextGroupId); |
| 154 ASSERT(!m_agentsMap.contains(contextGroupId)); | 153 ASSERT(!m_agentsMap.contains(contextGroupId)); |
| 155 if (m_agentsMap.isEmpty()) | 154 if (m_agentsMap.isEmpty()) |
| 156 enable(); | 155 enable(); |
| 157 m_agentsMap.set(contextGroupId, agent); | 156 m_agentsMap.set(contextGroupId, agent); |
| 158 | 157 |
| 159 Vector<V8DebuggerParsedScript> compiledScripts; | 158 protocol::Vector<V8DebuggerParsedScript> compiledScripts; |
| 160 getCompiledScripts(contextGroupId, compiledScripts); | 159 getCompiledScripts(contextGroupId, compiledScripts); |
| 161 for (size_t i = 0; i < compiledScripts.size(); i++) | 160 for (size_t i = 0; i < compiledScripts.size(); i++) |
| 162 agent->didParseSource(compiledScripts[i]); | 161 agent->didParseSource(compiledScripts[i]); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void V8DebuggerImpl::removeAgent(int contextGroupId) | 164 void V8DebuggerImpl::removeAgent(int contextGroupId) |
| 166 { | 165 { |
| 167 ASSERT(contextGroupId); | 166 ASSERT(contextGroupId); |
| 168 if (!m_agentsMap.contains(contextGroupId)) | 167 if (!m_agentsMap.contains(contextGroupId)) |
| 169 return; | 168 return; |
| 170 | 169 |
| 171 if (!m_pausedContext.IsEmpty() && getGroupId(m_pausedContext) == contextGrou
pId) | 170 if (!m_pausedContext.IsEmpty() && getGroupId(m_pausedContext) == contextGrou
pId) |
| 172 continueProgram(); | 171 continueProgram(); |
| 173 | 172 |
| 174 m_agentsMap.remove(contextGroupId); | 173 m_agentsMap.remove(contextGroupId); |
| 175 | 174 |
| 176 if (m_agentsMap.isEmpty()) | 175 if (m_agentsMap.isEmpty()) |
| 177 disable(); | 176 disable(); |
| 178 } | 177 } |
| 179 | 178 |
| 180 V8DebuggerAgentImpl* V8DebuggerImpl::getAgentForContext(v8::Local<v8::Context> c
ontext) | 179 V8DebuggerAgentImpl* V8DebuggerImpl::getAgentForContext(v8::Local<v8::Context> c
ontext) |
| 181 { | 180 { |
| 182 int groupId = getGroupId(context); | 181 int groupId = getGroupId(context); |
| 183 if (!groupId) | 182 if (!groupId) |
| 184 return nullptr; | 183 return nullptr; |
| 185 return m_agentsMap.get(groupId); | 184 return m_agentsMap.get(groupId); |
| 186 } | 185 } |
| 187 | 186 |
| 188 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, Vector<V8DebuggerPar
sedScript>& result) | 187 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
ebuggerParsedScript>& result) |
| 189 { | 188 { |
| 190 v8::HandleScope scope(m_isolate); | 189 v8::HandleScope scope(m_isolate); |
| 191 v8::Context::Scope contextScope(debuggerContext()); | 190 v8::Context::Scope contextScope(debuggerContext()); |
| 192 | 191 |
| 193 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 192 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 194 ASSERT(!debuggerScript->IsUndefined()); | 193 ASSERT(!debuggerScript->IsUndefined()); |
| 195 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); | 194 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d
ebuggerScript->Get(v8InternalizedString("getScripts"))); |
| 196 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; | 195 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId)
}; |
| 197 v8::Local<v8::Value> value; | 196 v8::Local<v8::Value> value; |
| 198 if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_
ARRAY_LENGTH(argv), argv).ToLocal(&value)) | 197 if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_
ARRAY_LENGTH(argv), argv).ToLocal(&value)) |
| 199 return; | 198 return; |
| 200 ASSERT(value->IsArray()); | 199 ASSERT(value->IsArray()); |
| 201 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); | 200 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); |
| 202 result.reserveCapacity(scriptsArray->Length()); | 201 result.resize(scriptsArray->Length()); |
| 203 for (unsigned i = 0; i < scriptsArray->Length(); ++i) | 202 for (unsigned i = 0; i < scriptsArray->Length(); ++i) |
| 204 result.append(createParsedScript(v8::Local<v8::Object>::Cast(scriptsArra
y->Get(v8::Integer::New(m_isolate, i))), true)); | 203 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray-
>Get(v8::Integer::New(m_isolate, i))), true); |
| 205 } | 204 } |
| 206 | 205 |
| 207 String V8DebuggerImpl::setBreakpoint(const String& sourceID, const ScriptBreakpo
int& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool inte
rstatementLocation) | 206 String V8DebuggerImpl::setBreakpoint(const String& sourceID, const ScriptBreakpo
int& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool inte
rstatementLocation) |
| 208 { | 207 { |
| 209 v8::HandleScope scope(m_isolate); | 208 v8::HandleScope scope(m_isolate); |
| 210 v8::Context::Scope contextScope(debuggerContext()); | 209 v8::Context::Scope contextScope(debuggerContext()); |
| 211 | 210 |
| 212 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 211 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
| 213 info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID))
; | 212 info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID))
; |
| 214 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc
riptBreakpoint.lineNumber)); | 213 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc
riptBreakpoint.lineNumber)); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8
::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8
::Array> hitBreakpointNumbers, bool isPromiseRejection) | 532 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8
::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8
::Array> hitBreakpointNumbers, bool isPromiseRejection) |
| 534 { | 533 { |
| 535 // Don't allow nested breaks. | 534 // Don't allow nested breaks. |
| 536 if (m_runningNestedMessageLoop) | 535 if (m_runningNestedMessageLoop) |
| 537 return; | 536 return; |
| 538 | 537 |
| 539 V8DebuggerAgentImpl* agent = getAgentForContext(pausedContext); | 538 V8DebuggerAgentImpl* agent = getAgentForContext(pausedContext); |
| 540 if (!agent) | 539 if (!agent) |
| 541 return; | 540 return; |
| 542 | 541 |
| 543 Vector<String> breakpointIds; | 542 protocol::Vector<String> breakpointIds; |
| 544 if (!hitBreakpointNumbers.IsEmpty()) { | 543 if (!hitBreakpointNumbers.IsEmpty()) { |
| 545 breakpointIds.resize(hitBreakpointNumbers->Length()); | 544 breakpointIds.resize(hitBreakpointNumbers->Length()); |
| 546 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 545 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
| 547 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); | 546 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); |
| 548 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); | 547 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); |
| 549 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; | 548 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; |
| 550 } | 549 } |
| 551 } | 550 } |
| 552 | 551 |
| 553 m_pausedContext = pausedContext; | 552 m_pausedContext = pausedContext; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 800 } |
| 802 | 801 |
| 803 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 802 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
| 804 { | 803 { |
| 805 if (m_regexContext.IsEmpty()) | 804 if (m_regexContext.IsEmpty()) |
| 806 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 805 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
| 807 return m_regexContext.Get(m_isolate); | 806 return m_regexContext.Get(m_isolate); |
| 808 } | 807 } |
| 809 | 808 |
| 810 } // namespace blink | 809 } // namespace blink |
| OLD | NEW |