Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: Source/core/inspector/V8DebuggerAgent.cpp

Issue 1286343003: DevTools: make InspectorDebuggerAgent aggregate V8DebuggerAgent instead of inheriting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed dgozman's comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/inspector/V8DebuggerAgent.h ('k') | Source/core/inspector/WorkerDebuggerAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "core/inspector/V8DebuggerAgent.h" 6 #include "core/inspector/V8DebuggerAgent.h"
7 7
8 #include "bindings/core/v8/ScriptCallStackFactory.h" 8 #include "bindings/core/v8/ScriptCallStackFactory.h"
9 #include "bindings/core/v8/ScriptRegexp.h" 9 #include "bindings/core/v8/ScriptRegexp.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return V8JavaScriptCallFrame::unwrap(value); 115 return V8JavaScriptCallFrame::unwrap(value);
116 } 116 }
117 117
118 static PassRefPtrWillBeRawPtr<ScriptCallStack> toScriptCallStack(v8::Local<v8::O bject> callFrames) 118 static PassRefPtrWillBeRawPtr<ScriptCallStack> toScriptCallStack(v8::Local<v8::O bject> callFrames)
119 { 119 {
120 RefPtr<JavaScriptCallFrame> jsCallFrame = toJavaScriptCallFrame(callFrames); 120 RefPtr<JavaScriptCallFrame> jsCallFrame = toJavaScriptCallFrame(callFrames);
121 return jsCallFrame ? toScriptCallStack(jsCallFrame.get()) : nullptr; 121 return jsCallFrame ? toScriptCallStack(jsCallFrame.get()) : nullptr;
122 } 122 }
123 123
124 V8DebuggerAgent::V8DebuggerAgent(InjectedScriptManager* injectedScriptManager, V 8Debugger* debugger, V8DebuggerAgent::Client* client, int contextGroupId) 124 V8DebuggerAgent::V8DebuggerAgent(InjectedScriptManager* injectedScriptManager, V 8Debugger* debugger, V8DebuggerAgent::Client* client, int contextGroupId)
125 : InspectorBaseAgent<V8DebuggerAgent, InspectorFrontend::Debugger>("Debugger ") 125 : m_injectedScriptManager(injectedScriptManager)
126 , m_injectedScriptManager(injectedScriptManager)
127 , m_debugger(debugger) 126 , m_debugger(debugger)
128 , m_client(client) 127 , m_client(client)
129 , m_contextGroupId(contextGroupId) 128 , m_contextGroupId(contextGroupId)
129 , m_state(nullptr)
130 , m_frontend(nullptr)
130 , m_isolate(debugger->isolate()) 131 , m_isolate(debugger->isolate())
131 , m_pausedScriptState(nullptr) 132 , m_pausedScriptState(nullptr)
132 , m_breakReason(InspectorFrontend::Debugger::Reason::Other) 133 , m_breakReason(InspectorFrontend::Debugger::Reason::Other)
133 , m_scheduledDebuggerStep(NoStep) 134 , m_scheduledDebuggerStep(NoStep)
134 , m_skipNextDebuggerStepOut(false) 135 , m_skipNextDebuggerStepOut(false)
135 , m_javaScriptPauseScheduled(false) 136 , m_javaScriptPauseScheduled(false)
136 , m_steppingFromFramework(false) 137 , m_steppingFromFramework(false)
137 , m_pausingOnNativeEvent(false) 138 , m_pausingOnNativeEvent(false)
138 , m_pausingOnAsyncOperation(false) 139 , m_pausingOnAsyncOperation(false)
139 , m_skippedStepFrameCount(0) 140 , m_skippedStepFrameCount(0)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return m_state->getBoolean(DebuggerAgentState::debuggerEnabled); 201 return m_state->getBoolean(DebuggerAgentState::debuggerEnabled);
201 } 202 }
202 203
203 void V8DebuggerAgent::enable(ErrorString*) 204 void V8DebuggerAgent::enable(ErrorString*)
204 { 205 {
205 if (enabled()) 206 if (enabled())
206 return; 207 return;
207 208
208 enable(); 209 enable();
209 210
210 ASSERT(frontend()); 211 ASSERT(m_frontend);
211 } 212 }
212 213
213 void V8DebuggerAgent::disable(ErrorString*) 214 void V8DebuggerAgent::disable(ErrorString*)
214 { 215 {
215 if (!enabled()) 216 if (!enabled())
216 return; 217 return;
217 218
218 disable(); 219 disable();
219 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false); 220 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, false);
220 } 221 }
(...skipping 20 matching lines...) Expand all
241 if (depth <= 0) { 242 if (depth <= 0) {
242 m_maxAsyncCallStackDepth = 0; 243 m_maxAsyncCallStackDepth = 0;
243 resetAsyncCallTracker(); 244 resetAsyncCallTracker();
244 } else { 245 } else {
245 m_maxAsyncCallStackDepth = depth; 246 m_maxAsyncCallStackDepth = depth;
246 } 247 }
247 for (auto& listener: m_asyncCallTrackingListeners) 248 for (auto& listener: m_asyncCallTrackingListeners)
248 listener->asyncCallTrackingStateChanged(m_maxAsyncCallStackDepth); 249 listener->asyncCallTrackingStateChanged(m_maxAsyncCallStackDepth);
249 } 250 }
250 251
252 void V8DebuggerAgent::clearFrontend()
253 {
254 ErrorString error;
255 disable(&error);
256 ASSERT(m_frontend);
257 m_frontend = nullptr;
258 }
259
251 void V8DebuggerAgent::restore() 260 void V8DebuggerAgent::restore()
252 { 261 {
253 if (enabled()) { 262 if (enabled()) {
254 frontend()->globalObjectCleared(); 263 m_frontend->globalObjectCleared();
255 enable(); 264 enable();
256 long pauseState = m_state->getLong(DebuggerAgentState::pauseOnExceptions State, V8Debugger::DontPauseOnExceptions); 265 long pauseState = m_state->getLong(DebuggerAgentState::pauseOnExceptions State, V8Debugger::DontPauseOnExceptions);
257 String error; 266 String error;
258 setPauseOnExceptionsImpl(&error, pauseState); 267 setPauseOnExceptionsImpl(&error, pauseState);
259 m_cachedSkipStackRegExp = compileSkipCallFramePattern(m_state->getString (DebuggerAgentState::skipStackPattern)); 268 m_cachedSkipStackRegExp = compileSkipCallFramePattern(m_state->getString (DebuggerAgentState::skipStackPattern));
260 increaseCachedSkipStackGeneration(); 269 increaseCachedSkipStackGeneration();
261 m_skipContentScripts = m_state->getBoolean(DebuggerAgentState::skipConte ntScripts); 270 m_skipContentScripts = m_state->getBoolean(DebuggerAgentState::skipConte ntScripts);
262 m_skipAllPauses = m_state->getBoolean(DebuggerAgentState::skipAllPauses) ; 271 m_skipAllPauses = m_state->getBoolean(DebuggerAgentState::skipAllPauses) ;
263 internalSetAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyn cCallStackDepth)); 272 internalSetAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyn cCallStackDepth));
264 promiseTracker().setEnabled(m_state->getBoolean(DebuggerAgentState::prom iseTrackerEnabled), m_state->getBoolean(DebuggerAgentState::promiseTrackerCaptur eStacks)); 273 promiseTracker().setEnabled(m_state->getBoolean(DebuggerAgentState::prom iseTrackerEnabled), m_state->getBoolean(DebuggerAgentState::promiseTrackerCaptur eStacks));
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 ASSERT(enabled()); 706 ASSERT(enabled());
698 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || isP aused()) 707 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || isP aused())
699 return; 708 return;
700 clearBreakDetails(); 709 clearBreakDetails();
701 m_pausingOnNativeEvent = false; 710 m_pausingOnNativeEvent = false;
702 m_skippedStepFrameCount = 0; 711 m_skippedStepFrameCount = 0;
703 m_recursionLevelForStepFrame = 0; 712 m_recursionLevelForStepFrame = 0;
704 debugger().setPauseOnNextStatement(true); 713 debugger().setPauseOnNextStatement(true);
705 } 714 }
706 715
707 void V8DebuggerAgent::didFireTimer()
708 {
709 cancelPauseOnNextStatement();
710 }
711
712 void V8DebuggerAgent::didHandleEvent()
713 {
714 cancelPauseOnNextStatement();
715 }
716
717 void V8DebuggerAgent::cancelPauseOnNextStatement() 716 void V8DebuggerAgent::cancelPauseOnNextStatement()
718 { 717 {
719 if (m_javaScriptPauseScheduled || isPaused()) 718 if (m_javaScriptPauseScheduled || isPaused())
720 return; 719 return;
721 clearBreakDetails(); 720 clearBreakDetails();
722 m_pausingOnNativeEvent = false; 721 m_pausingOnNativeEvent = false;
723 debugger().setPauseOnNextStatement(false); 722 debugger().setPauseOnNextStatement(false);
724 } 723 }
725 724
726 bool V8DebuggerAgent::v8AsyncTaskEventsEnabled() const 725 bool V8DebuggerAgent::v8AsyncTaskEventsEnabled() const
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 if (value.isEmpty()) { 1100 if (value.isEmpty()) {
1102 *errorString = "Promise with specified ID not found."; 1101 *errorString = "Promise with specified ID not found.";
1103 return; 1102 return;
1104 } 1103 }
1105 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState()); 1104 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState());
1106 promise = injectedScript.wrapObject(value, objectGroup ? *objectGroup : ""); 1105 promise = injectedScript.wrapObject(value, objectGroup ? *objectGroup : "");
1107 } 1106 }
1108 1107
1109 void V8DebuggerAgent::didUpdatePromise(InspectorFrontend::Debugger::EventType::E num eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise) 1108 void V8DebuggerAgent::didUpdatePromise(InspectorFrontend::Debugger::EventType::E num eventType, PassRefPtr<TypeBuilder::Debugger::PromiseDetails> promise)
1110 { 1109 {
1111 if (frontend()) 1110 if (m_frontend)
1112 frontend()->promiseUpdated(eventType, promise); 1111 m_frontend->promiseUpdated(eventType, promise);
1113 } 1112 }
1114 1113
1115 int V8DebuggerAgent::traceAsyncOperationStarting(const String& description) 1114 int V8DebuggerAgent::traceAsyncOperationStarting(const String& description)
1116 { 1115 {
1117 v8::HandleScope scope(m_isolate); 1116 v8::HandleScope scope(m_isolate);
1118 v8::Local<v8::Object> callFrames = debugger().currentCallFramesForAsyncStack (); 1117 v8::Local<v8::Object> callFrames = debugger().currentCallFramesForAsyncStack ();
1119 RefPtrWillBeRawPtr<AsyncCallChain> chain = nullptr; 1118 RefPtrWillBeRawPtr<AsyncCallChain> chain = nullptr;
1120 if (callFrames.IsEmpty()) { 1119 if (callFrames.IsEmpty()) {
1121 if (m_currentAsyncCallChain) 1120 if (m_currentAsyncCallChain)
1122 chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get( ), m_maxAsyncCallStackDepth); 1121 chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get( ), m_maxAsyncCallStackDepth);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 } 1223 }
1225 m_asyncOperations.remove(operationId); 1224 m_asyncOperations.remove(operationId);
1226 m_asyncOperationBreakpoints.remove(operationId); 1225 m_asyncOperationBreakpoints.remove(operationId);
1227 m_pausingAsyncOperations.remove(operationId); 1226 m_pausingAsyncOperations.remove(operationId);
1228 shouldNotify = !m_asyncOperationNotifications.take(operationId); 1227 shouldNotify = !m_asyncOperationNotifications.take(operationId);
1229 } 1228 }
1230 if (m_startingStepIntoAsync) { 1229 if (m_startingStepIntoAsync) {
1231 if (!m_pausingOnAsyncOperation && m_pausingAsyncOperations.isEmpty()) 1230 if (!m_pausingOnAsyncOperation && m_pausingAsyncOperations.isEmpty())
1232 clearStepIntoAsync(); 1231 clearStepIntoAsync();
1233 } 1232 }
1234 if (frontend() && shouldNotify) 1233 if (m_frontend && shouldNotify)
1235 frontend()->asyncOperationCompleted(operationId); 1234 m_frontend->asyncOperationCompleted(operationId);
1236 } 1235 }
1237 1236
1238 void V8DebuggerAgent::flushAsyncOperationEvents(ErrorString*) 1237 void V8DebuggerAgent::flushAsyncOperationEvents(ErrorString*)
1239 { 1238 {
1240 if (!frontend()) 1239 if (!m_frontend)
1241 return; 1240 return;
1242 1241
1243 for (int operationId : m_asyncOperationNotifications) { 1242 for (int operationId : m_asyncOperationNotifications) {
1244 RefPtrWillBeRawPtr<AsyncCallChain> chain = m_asyncOperations.get(operati onId); 1243 RefPtrWillBeRawPtr<AsyncCallChain> chain = m_asyncOperations.get(operati onId);
1245 ASSERT(chain); 1244 ASSERT(chain);
1246 const AsyncCallStackVector& callStacks = chain->callStacks(); 1245 const AsyncCallStackVector& callStacks = chain->callStacks();
1247 ASSERT(!callStacks.isEmpty()); 1246 ASSERT(!callStacks.isEmpty());
1248 1247
1249 RefPtr<AsyncOperation> operation; 1248 RefPtr<AsyncOperation> operation;
1250 RefPtr<AsyncStackTrace> lastAsyncStackTrace; 1249 RefPtr<AsyncStackTrace> lastAsyncStackTrace;
(...skipping 14 matching lines...) Expand all
1265 .setCallFrames(scriptCallStack->buildInspectorArray()); 1264 .setCallFrames(scriptCallStack->buildInspectorArray());
1266 asyncStackTrace->setDescription(callStack->description()); 1265 asyncStackTrace->setDescription(callStack->description());
1267 if (lastAsyncStackTrace) 1266 if (lastAsyncStackTrace)
1268 lastAsyncStackTrace->setAsyncStackTrace(asyncStackTrace); 1267 lastAsyncStackTrace->setAsyncStackTrace(asyncStackTrace);
1269 else 1268 else
1270 operation->setAsyncStackTrace(asyncStackTrace); 1269 operation->setAsyncStackTrace(asyncStackTrace);
1271 lastAsyncStackTrace = asyncStackTrace.release(); 1270 lastAsyncStackTrace = asyncStackTrace.release();
1272 } 1271 }
1273 1272
1274 if (operation) 1273 if (operation)
1275 frontend()->asyncOperationStarted(operation.release()); 1274 m_frontend->asyncOperationStarted(operation.release());
1276 } 1275 }
1277 1276
1278 m_asyncOperationNotifications.clear(); 1277 m_asyncOperationNotifications.clear();
1279 } 1278 }
1280 1279
1281 void V8DebuggerAgent::clearCurrentAsyncOperation() 1280 void V8DebuggerAgent::clearCurrentAsyncOperation()
1282 { 1281 {
1283 if (m_pendingTraceAsyncOperationCompleted && m_currentAsyncOperationId != un knownAsyncOperationId) 1282 if (m_pendingTraceAsyncOperationCompleted && m_currentAsyncOperationId != un knownAsyncOperationId)
1284 traceAsyncOperationCompleted(m_currentAsyncOperationId); 1283 traceAsyncOperationCompleted(m_currentAsyncOperationId);
1285 1284
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 *errorString = "Can only perform operation while tracking async call sta cks."; 1322 *errorString = "Can only perform operation while tracking async call sta cks.";
1324 return; 1323 return;
1325 } 1324 }
1326 if (operationId <= 0) { 1325 if (operationId <= 0) {
1327 *errorString = "Wrong async operation id."; 1326 *errorString = "Wrong async operation id.";
1328 return; 1327 return;
1329 } 1328 }
1330 m_asyncOperationBreakpoints.remove(operationId); 1329 m_asyncOperationBreakpoints.remove(operationId);
1331 } 1330 }
1332 1331
1333 void V8DebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
1334 {
1335 if (debugger().pauseOnExceptionsState() != V8Debugger::DontPauseOnExceptions ) {
1336 RefPtr<JSONObject> directive = JSONObject::create();
1337 directive->setString("directiveText", directiveText);
1338 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release());
1339 }
1340 }
1341
1342 void V8DebuggerAgent::addAsyncCallTrackingListener(AsyncCallTrackingListener* li stener) 1332 void V8DebuggerAgent::addAsyncCallTrackingListener(AsyncCallTrackingListener* li stener)
1343 { 1333 {
1344 m_asyncCallTrackingListeners.add(listener); 1334 m_asyncCallTrackingListeners.add(listener);
1345 } 1335 }
1346 1336
1347 void V8DebuggerAgent::removeAsyncCallTrackingListener(AsyncCallTrackingListener* listener) 1337 void V8DebuggerAgent::removeAsyncCallTrackingListener(AsyncCallTrackingListener* listener)
1348 { 1338 {
1349 ASSERT(m_asyncCallTrackingListeners.contains(listener)); 1339 ASSERT(m_asyncCallTrackingListeners.contains(listener));
1350 m_asyncCallTrackingListeners.remove(listener); 1340 m_asyncCallTrackingListeners.remove(listener);
1351 } 1341 }
1352 1342
1353 void V8DebuggerAgent::willCallFunction(ExecutionContext*, const DevToolsFunction Info& info) 1343 void V8DebuggerAgent::willCallFunction(int scriptId)
1354 { 1344 {
1355 changeJavaScriptRecursionLevel(+1); 1345 changeJavaScriptRecursionLevel(+1);
1356 // Fast return. 1346 // Fast return.
1357 if (m_scheduledDebuggerStep != StepInto) 1347 if (m_scheduledDebuggerStep != StepInto)
1358 return; 1348 return;
1359 // Skip unknown scripts (e.g. InjectedScript). 1349 // Skip unknown scripts (e.g. InjectedScript).
1360 if (!m_scripts.contains(String::number(info.scriptId()))) 1350 if (!m_scripts.contains(String::number(scriptId)))
1361 return; 1351 return;
1362 schedulePauseOnNextStatementIfSteppingInto(); 1352 schedulePauseOnNextStatementIfSteppingInto();
1363 } 1353 }
1364 1354
1365 void V8DebuggerAgent::didCallFunction() 1355 void V8DebuggerAgent::didCallFunction()
1366 { 1356 {
1367 changeJavaScriptRecursionLevel(-1); 1357 changeJavaScriptRecursionLevel(-1);
1368 } 1358 }
1369 1359
1370 void V8DebuggerAgent::willEvaluateScript(const String&, int) 1360 void V8DebuggerAgent::willEvaluateScript()
1371 { 1361 {
1372 changeJavaScriptRecursionLevel(+1); 1362 changeJavaScriptRecursionLevel(+1);
1373 schedulePauseOnNextStatementIfSteppingInto(); 1363 schedulePauseOnNextStatementIfSteppingInto();
1374 } 1364 }
1375 1365
1376 void V8DebuggerAgent::didEvaluateScript() 1366 void V8DebuggerAgent::didEvaluateScript()
1377 { 1367 {
1378 changeJavaScriptRecursionLevel(-1); 1368 changeJavaScriptRecursionLevel(-1);
1379 } 1369 }
1380 1370
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 bool isInternalScript = script.isInternalScript(); 1491 bool isInternalScript = script.isInternalScript();
1502 bool hasSourceURL = script.hasSourceURL(); 1492 bool hasSourceURL = script.hasSourceURL();
1503 String scriptURL = script.sourceURL(); 1493 String scriptURL = script.sourceURL();
1504 String sourceMapURL = sourceMapURLForScript(script, parsedScript.compileResu lt); 1494 String sourceMapURL = sourceMapURLForScript(script, parsedScript.compileResu lt);
1505 1495
1506 const String* sourceMapURLParam = sourceMapURL.isNull() ? nullptr : &sourceM apURL; 1496 const String* sourceMapURLParam = sourceMapURL.isNull() ? nullptr : &sourceM apURL;
1507 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr; 1497 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr;
1508 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr; 1498 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr;
1509 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; 1499 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1510 if (!hasSyntaxError) 1500 if (!hasSyntaxError)
1511 frontend()->scriptParsed(parsedScript.scriptId, scriptURL, script.startL ine(), script.startColumn(), script.endLine(), script.endColumn(), isContentScri ptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam); 1501 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL ine(), script.startColumn(), script.endLine(), script.endColumn(), isContentScri ptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam);
1512 else 1502 else
1513 frontend()->scriptFailedToParse(parsedScript.scriptId, scriptURL, script .startLine(), script.startColumn(), script.endLine(), script.endColumn(), isCont entScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam); 1503 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script .startLine(), script.startColumn(), script.endLine(), script.endColumn(), isCont entScriptParam, isInternalScriptParam, sourceMapURLParam, hasSourceURLParam);
1514 1504
1515 m_scripts.set(parsedScript.scriptId, script); 1505 m_scripts.set(parsedScript.scriptId, script);
1516 1506
1517 if (scriptURL.isEmpty() || hasSyntaxError) 1507 if (scriptURL.isEmpty() || hasSyntaxError)
1518 return; 1508 return;
1519 1509
1520 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints); 1510 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints);
1521 for (auto& cookie : *breakpointsCookie) { 1511 for (auto& cookie : *breakpointsCookie) {
1522 RefPtr<JSONObject> breakpointObject = cookie.value->asObject(); 1512 RefPtr<JSONObject> breakpointObject = cookie.value->asObject();
1523 bool isRegex; 1513 bool isRegex;
1524 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); 1514 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex);
1525 String url; 1515 String url;
1526 breakpointObject->getString(DebuggerAgentState::url, &url); 1516 breakpointObject->getString(DebuggerAgentState::url, &url);
1527 if (!matches(scriptURL, url, isRegex)) 1517 if (!matches(scriptURL, url, isRegex))
1528 continue; 1518 continue;
1529 ScriptBreakpoint breakpoint; 1519 ScriptBreakpoint breakpoint;
1530 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber); 1520 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber);
1531 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber); 1521 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber);
1532 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1522 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1533 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(coo kie.key, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1523 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(coo kie.key, parsedScript.scriptId, breakpoint, UserBreakpointSource);
1534 if (location) 1524 if (location)
1535 frontend()->breakpointResolved(cookie.key, location); 1525 m_frontend->breakpointResolved(cookie.key, location);
1536 } 1526 }
1537 } 1527 }
1538 1528
1539 V8DebuggerListener::SkipPauseRequest V8DebuggerAgent::didPause(v8::Local<v8::Con text> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> v8exceptio n, const Vector<String>& hitBreakpoints, bool isPromiseRejection) 1529 V8DebuggerListener::SkipPauseRequest V8DebuggerAgent::didPause(v8::Local<v8::Con text> context, v8::Local<v8::Object> callFrames, v8::Local<v8::Value> v8exceptio n, const Vector<String>& hitBreakpoints, bool isPromiseRejection)
1540 { 1530 {
1541 ScriptState* scriptState = ScriptState::from(context); 1531 ScriptState* scriptState = ScriptState::from(context);
1542 ScriptValue exception(scriptState, v8exception); 1532 ScriptValue exception(scriptState, v8exception);
1543 1533
1544 V8DebuggerListener::SkipPauseRequest result; 1534 V8DebuggerListener::SkipPauseRequest result;
1545 if (m_skipAllPauses) 1535 if (m_skipAllPauses)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1579
1590 BreakpointSource source = breakpointIterator->value.second; 1580 BreakpointSource source = breakpointIterator->value.second;
1591 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s ource == DebugCommandBreakpointSource) 1581 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s ource == DebugCommandBreakpointSource)
1592 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman d; 1582 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman d;
1593 } 1583 }
1594 } 1584 }
1595 1585
1596 if (!m_asyncOperationNotifications.isEmpty()) 1586 if (!m_asyncOperationNotifications.isEmpty())
1597 flushAsyncOperationEvents(nullptr); 1587 flushAsyncOperationEvents(nullptr);
1598 1588
1599 frontend()->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr eakpointIds, currentAsyncStackTrace()); 1589 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr eakpointIds, currentAsyncStackTrace());
1600 m_scheduledDebuggerStep = NoStep; 1590 m_scheduledDebuggerStep = NoStep;
1601 m_javaScriptPauseScheduled = false; 1591 m_javaScriptPauseScheduled = false;
1602 m_steppingFromFramework = false; 1592 m_steppingFromFramework = false;
1603 m_pausingOnNativeEvent = false; 1593 m_pausingOnNativeEvent = false;
1604 m_skippedStepFrameCount = 0; 1594 m_skippedStepFrameCount = 0;
1605 m_recursionLevelForStepFrame = 0; 1595 m_recursionLevelForStepFrame = 0;
1606 clearStepIntoAsync(); 1596 clearStepIntoAsync();
1607 1597
1608 if (!m_continueToLocationBreakpointId.isEmpty()) { 1598 if (!m_continueToLocationBreakpointId.isEmpty()) {
1609 debugger().removeBreakpoint(m_continueToLocationBreakpointId); 1599 debugger().removeBreakpoint(m_continueToLocationBreakpointId);
1610 m_continueToLocationBreakpointId = ""; 1600 m_continueToLocationBreakpointId = "";
1611 } 1601 }
1612 return result; 1602 return result;
1613 } 1603 }
1614 1604
1615 void V8DebuggerAgent::didContinue() 1605 void V8DebuggerAgent::didContinue()
1616 { 1606 {
1617 m_pausedScriptState = nullptr; 1607 m_pausedScriptState = nullptr;
1618 m_currentCallStack.Reset(); 1608 m_currentCallStack.Reset();
1619 clearBreakDetails(); 1609 clearBreakDetails();
1620 frontend()->resumed(); 1610 m_frontend->resumed();
1621 } 1611 }
1622 1612
1623 bool V8DebuggerAgent::canBreakProgram() 1613 bool V8DebuggerAgent::canBreakProgram()
1624 { 1614 {
1625 return debugger().canBreakProgram(); 1615 return debugger().canBreakProgram();
1626 } 1616 }
1627 1617
1628 void V8DebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::Enum bre akReason, PassRefPtr<JSONObject> data) 1618 void V8DebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::Enum bre akReason, PassRefPtr<JSONObject> data)
1629 { 1619 {
1630 ASSERT(enabled()); 1620 ASSERT(enabled());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so urce)); 1685 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so urce));
1696 } 1686 }
1697 1687
1698 void V8DebuggerAgent::reset() 1688 void V8DebuggerAgent::reset()
1699 { 1689 {
1700 m_scheduledDebuggerStep = NoStep; 1690 m_scheduledDebuggerStep = NoStep;
1701 m_scripts.clear(); 1691 m_scripts.clear();
1702 m_breakpointIdToDebuggerBreakpointIds.clear(); 1692 m_breakpointIdToDebuggerBreakpointIds.clear();
1703 resetAsyncCallTracker(); 1693 resetAsyncCallTracker();
1704 promiseTracker().clear(); 1694 promiseTracker().clear();
1705 if (frontend()) 1695 if (m_frontend)
1706 frontend()->globalObjectCleared(); 1696 m_frontend->globalObjectCleared();
1707 }
1708
1709 DEFINE_TRACE(V8DebuggerAgent)
1710 {
1711 #if ENABLE(OILPAN)
1712 visitor->trace(m_injectedScriptManager);
1713 visitor->trace(m_v8AsyncCallTracker);
1714 visitor->trace(m_promiseTracker);
1715 visitor->trace(m_asyncOperations);
1716 visitor->trace(m_currentAsyncCallChain);
1717 visitor->trace(m_asyncCallTrackingListeners);
1718 #endif
1719 InspectorBaseAgent::trace(visitor);
1720 } 1697 }
1721 1698
1722 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> V8DebuggerAgent::createExcep tionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) 1699 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> V8DebuggerAgent::createExcep tionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message)
1723 { 1700 {
1724 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); 1701 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe xt(toCoreStringWithUndefinedOrNullCheck(message->Get()));
1725 exceptionDetails->setLine(message->GetLineNumber()); 1702 exceptionDetails->setLine(message->GetLineNumber());
1726 exceptionDetails->setColumn(message->GetStartColumn()); 1703 exceptionDetails->setColumn(message->GetStartColumn());
1727 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); 1704 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace();
1728 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) 1705 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0)
1729 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); 1706 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray());
1730 return exceptionDetails.release(); 1707 return exceptionDetails.release();
1731 } 1708 }
1732 1709
1733 } // namespace blink 1710 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/V8DebuggerAgent.h ('k') | Source/core/inspector/WorkerDebuggerAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698