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

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

Issue 1129473003: DevTools: respond with error when Debugger command is sent to disabled debugger agent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 void InspectorDebuggerAgent::init() 175 void InspectorDebuggerAgent::init()
176 { 176 {
177 m_promiseTracker = PromiseTracker::create(this, scriptDebugServer().isolate( )); 177 m_promiseTracker = PromiseTracker::create(this, scriptDebugServer().isolate( ));
178 // FIXME: make breakReason optional so that there was no need to init it wit h "other". 178 // FIXME: make breakReason optional so that there was no need to init it wit h "other".
179 clearBreakDetails(); 179 clearBreakDetails();
180 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, ScriptDebugServ er::DontPauseOnExceptions); 180 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, ScriptDebugServ er::DontPauseOnExceptions);
181 } 181 }
182 182
183 bool InspectorDebuggerAgent::checkEnabled(ErrorString* errorString)
184 {
185 if (enabled())
186 return true;
187 *errorString = "Debugger agent is not enabled";
188 return false;
189 }
190
183 void InspectorDebuggerAgent::enable() 191 void InspectorDebuggerAgent::enable()
184 { 192 {
185 m_instrumentingAgents->setInspectorDebuggerAgent(this); 193 m_instrumentingAgents->setInspectorDebuggerAgent(this);
186 194
187 startListeningScriptDebugServer(); 195 startListeningScriptDebugServer();
188 // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends 196 // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends
189 scriptDebugServer().setBreakpointsActivated(true); 197 scriptDebugServer().setBreakpointsActivated(true);
190 198
191 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); 199 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true);
192 if (m_listener) 200 if (m_listener)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 setPauseOnExceptionsImpl(&error, pauseState); 283 setPauseOnExceptionsImpl(&error, pauseState);
276 m_cachedSkipStackRegExp = compileSkipCallFramePattern(m_state->getString (DebuggerAgentState::skipStackPattern)); 284 m_cachedSkipStackRegExp = compileSkipCallFramePattern(m_state->getString (DebuggerAgentState::skipStackPattern));
277 increaseCachedSkipStackGeneration(); 285 increaseCachedSkipStackGeneration();
278 m_skipContentScripts = m_state->getBoolean(DebuggerAgentState::skipConte ntScripts); 286 m_skipContentScripts = m_state->getBoolean(DebuggerAgentState::skipConte ntScripts);
279 m_skipAllPauses = m_state->getBoolean(DebuggerAgentState::skipAllPauses) ; 287 m_skipAllPauses = m_state->getBoolean(DebuggerAgentState::skipAllPauses) ;
280 internalSetAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyn cCallStackDepth)); 288 internalSetAsyncCallStackDepth(m_state->getLong(DebuggerAgentState::asyn cCallStackDepth));
281 promiseTracker().setEnabled(m_state->getBoolean(DebuggerAgentState::prom iseTrackerEnabled), m_state->getBoolean(DebuggerAgentState::promiseTrackerCaptur eStacks)); 289 promiseTracker().setEnabled(m_state->getBoolean(DebuggerAgentState::prom iseTrackerEnabled), m_state->getBoolean(DebuggerAgentState::promiseTrackerCaptur eStacks));
282 } 290 }
283 } 291 }
284 292
285 void InspectorDebuggerAgent::setBreakpointsActive(ErrorString*, bool active) 293 void InspectorDebuggerAgent::setBreakpointsActive(ErrorString* errorString, bool active)
286 { 294 {
295 if (!checkEnabled(errorString))
296 return;
287 scriptDebugServer().setBreakpointsActivated(active); 297 scriptDebugServer().setBreakpointsActivated(active);
288 } 298 }
289 299
290 void InspectorDebuggerAgent::setSkipAllPauses(ErrorString*, bool skipped) 300 void InspectorDebuggerAgent::setSkipAllPauses(ErrorString*, bool skipped)
291 { 301 {
292 m_skipAllPauses = skipped; 302 m_skipAllPauses = skipped;
293 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); 303 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses);
294 } 304 }
295 305
296 bool InspectorDebuggerAgent::isPaused() 306 bool InspectorDebuggerAgent::isPaused()
297 { 307 {
298 return scriptDebugServer().isPaused(); 308 return scriptDebugServer().isPaused();
299 } 309 }
300 310
301 void InspectorDebuggerAgent::addMessageToConsole(ConsoleMessage* consoleMessage) 311 void InspectorDebuggerAgent::addMessageToConsole(ConsoleMessage* consoleMessage)
302 { 312 {
313 ASSERT(enabled());
303 if (consoleMessage->type() == AssertMessageType && scriptDebugServer().pause OnExceptionsState() != ScriptDebugServer::DontPauseOnExceptions) 314 if (consoleMessage->type() == AssertMessageType && scriptDebugServer().pause OnExceptionsState() != ScriptDebugServer::DontPauseOnExceptions)
304 breakProgram(InspectorFrontend::Debugger::Reason::Assert, nullptr); 315 breakProgram(InspectorFrontend::Debugger::Reason::Assert, nullptr);
305 } 316 }
306 317
307 static PassRefPtr<JSONObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex) 318 static PassRefPtr<JSONObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex)
308 { 319 {
309 RefPtr<JSONObject> breakpointObject = JSONObject::create(); 320 RefPtr<JSONObject> breakpointObject = JSONObject::create();
310 breakpointObject->setString(DebuggerAgentState::url, url); 321 breakpointObject->setString(DebuggerAgentState::url, url);
311 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); 322 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber);
312 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); 323 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return; 406 return;
396 } 407 }
397 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); 408 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
398 actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, UserB reakpointSource); 409 actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, UserB reakpointSource);
399 if (actualLocation) 410 if (actualLocation)
400 *outBreakpointId = breakpointId; 411 *outBreakpointId = breakpointId;
401 else 412 else
402 *errorString = "Could not resolve breakpoint"; 413 *errorString = "Could not resolve breakpoint";
403 } 414 }
404 415
405 void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakp ointId) 416 void InspectorDebuggerAgent::removeBreakpoint(ErrorString* errorString, const St ring& breakpointId)
406 { 417 {
418 if (!checkEnabled(errorString))
419 return;
407 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints); 420 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints);
408 breakpointsCookie->remove(breakpointId); 421 breakpointsCookie->remove(breakpointId);
409 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCoo kie); 422 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCoo kie);
410 removeBreakpoint(breakpointId); 423 removeBreakpoint(breakpointId);
411 } 424 }
412 425
413 void InspectorDebuggerAgent::removeBreakpoint(const String& breakpointId) 426 void InspectorDebuggerAgent::removeBreakpoint(const String& breakpointId)
414 { 427 {
428 ASSERT(enabled());
415 BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIds Iterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); 429 BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIds Iterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId);
416 if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpoin tIds.end()) 430 if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpoin tIds.end())
417 return; 431 return;
418 for (size_t i = 0; i < debugServerBreakpointIdsIterator->value.size(); ++i) { 432 for (size_t i = 0; i < debugServerBreakpointIdsIterator->value.size(); ++i) {
419 const String& debugServerBreakpointId = debugServerBreakpointIdsIterator ->value[i]; 433 const String& debugServerBreakpointId = debugServerBreakpointIdsIterator ->value[i];
420 scriptDebugServer().removeBreakpoint(debugServerBreakpointId); 434 scriptDebugServer().removeBreakpoint(debugServerBreakpointId);
421 m_serverBreakpoints.remove(debugServerBreakpointId); 435 m_serverBreakpoints.remove(debugServerBreakpointId);
422 } 436 }
423 m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIter ator); 437 m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIter ator);
424 } 438 }
425 439
426 void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr<JSONObject>& location, const bool* interstateLocationOpt) 440 void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, const RefPtr<JSONObject>& location, const bool* interstateLocationOpt)
427 { 441 {
442 if (!checkEnabled(errorString))
443 return;
428 if (!m_continueToLocationBreakpointId.isEmpty()) { 444 if (!m_continueToLocationBreakpointId.isEmpty()) {
429 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); 445 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
430 m_continueToLocationBreakpointId = ""; 446 m_continueToLocationBreakpointId = "";
431 } 447 }
432 448
433 String scriptId; 449 String scriptId;
434 int lineNumber; 450 int lineNumber;
435 int columnNumber; 451 int columnNumber;
436 452
437 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber)) 453 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber))
(...skipping 23 matching lines...) Expand all
461 { 477 {
462 if (!assertPaused(errorString)) 478 if (!assertPaused(errorString))
463 return; 479 return;
464 m_currentCallStack = scriptDebugServer().currentCallFrames(); 480 m_currentCallStack = scriptDebugServer().currentCallFrames();
465 callFrames = currentCallFrames(); 481 callFrames = currentCallFrames();
466 asyncStackTrace = currentAsyncStackTrace(); 482 asyncStackTrace = currentAsyncStackTrace();
467 } 483 }
468 484
469 bool InspectorDebuggerAgent::isCallStackEmptyOrBlackboxed() 485 bool InspectorDebuggerAgent::isCallStackEmptyOrBlackboxed()
470 { 486 {
487 ASSERT(enabled());
471 for (int index = 0; ; ++index) { 488 for (int index = 0; ; ++index) {
472 RefPtrWillBeRawPtr<JavaScriptCallFrame> frame = scriptDebugServer().call FrameNoScopes(index); 489 RefPtrWillBeRawPtr<JavaScriptCallFrame> frame = scriptDebugServer().call FrameNoScopes(index);
473 if (!frame) 490 if (!frame)
474 break; 491 break;
475 if (!isCallFrameWithUnknownScriptOrBlackboxed(frame.release())) 492 if (!isCallFrameWithUnknownScriptOrBlackboxed(frame.release()))
476 return false; 493 return false;
477 } 494 }
478 return true; 495 return true;
479 } 496 }
480 497
481 bool InspectorDebuggerAgent::isTopCallFrameBlackboxed() 498 bool InspectorDebuggerAgent::isTopCallFrameBlackboxed()
482 { 499 {
500 ASSERT(enabled());
483 return isCallFrameWithUnknownScriptOrBlackboxed(scriptDebugServer().callFram eNoScopes(0)); 501 return isCallFrameWithUnknownScriptOrBlackboxed(scriptDebugServer().callFram eNoScopes(0));
484 } 502 }
485 503
486 bool InspectorDebuggerAgent::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr WillBeRawPtr<JavaScriptCallFrame> pFrame) 504 bool InspectorDebuggerAgent::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr WillBeRawPtr<JavaScriptCallFrame> pFrame)
487 { 505 {
488 RefPtrWillBeRawPtr<JavaScriptCallFrame> frame = pFrame; 506 RefPtrWillBeRawPtr<JavaScriptCallFrame> frame = pFrame;
489 if (!frame) 507 if (!frame)
490 return true; 508 return true;
491 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID())); 509 ScriptsMap::iterator it = m_scripts.find(String::number(frame->sourceID()));
492 if (it == m_scripts.end()) { 510 if (it == m_scripts.end()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 552
535 if (!m_skippedStepFrameCount) 553 if (!m_skippedStepFrameCount)
536 m_recursionLevelForStepFrame = 1; 554 m_recursionLevelForStepFrame = 1;
537 555
538 ++m_skippedStepFrameCount; 556 ++m_skippedStepFrameCount;
539 return ScriptDebugListener::StepFrame; 557 return ScriptDebugListener::StepFrame;
540 } 558 }
541 559
542 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint & breakpoint, BreakpointSource source) 560 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint & breakpoint, BreakpointSource source)
543 { 561 {
562 ASSERT(enabled());
544 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 563 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
545 if (scriptIterator == m_scripts.end()) 564 if (scriptIterator == m_scripts.end())
546 return nullptr; 565 return nullptr;
547 Script& script = scriptIterator->value; 566 Script& script = scriptIterator->value;
548 if (breakpoint.lineNumber < script.startLine() || script.endLine() < breakpo int.lineNumber) 567 if (breakpoint.lineNumber < script.startLine() || script.endLine() < breakpo int.lineNumber)
549 return nullptr; 568 return nullptr;
550 569
551 int actualLineNumber; 570 int actualLineNumber;
552 int actualColumnNumber; 571 int actualColumnNumber;
553 String debugServerBreakpointId = scriptDebugServer().setBreakpoint(scriptId, breakpoint, &actualLineNumber, &actualColumnNumber, false); 572 String debugServerBreakpointId = scriptDebugServer().setBreakpoint(scriptId, breakpoint, &actualLineNumber, &actualColumnNumber, false);
(...skipping 19 matching lines...) Expand all
573 { 592 {
574 ScriptsMap::iterator it = m_scripts.find(scriptId); 593 ScriptsMap::iterator it = m_scripts.find(scriptId);
575 if (it != m_scripts.end()) 594 if (it != m_scripts.end())
576 results = ContentSearchUtils::searchInTextByLines(it->value.source(), qu ery, asBool(optionalCaseSensitive), asBool(optionalIsRegex)); 595 results = ContentSearchUtils::searchInTextByLines(it->value.source(), qu ery, asBool(optionalCaseSensitive), asBool(optionalIsRegex));
577 else 596 else
578 *error = "No script for id: " + scriptId; 597 *error = "No script for id: " + scriptId;
579 } 598 }
580 599
581 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S tring& newContent, const bool* const preview, RefPtr<Array<CallFrame> >& newCall Frames, RefPtr<JSONObject>& result, RefPtr<StackTrace>& asyncStackTrace) 600 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S tring& newContent, const bool* const preview, RefPtr<Array<CallFrame> >& newCall Frames, RefPtr<JSONObject>& result, RefPtr<StackTrace>& asyncStackTrace)
582 { 601 {
602 if (!checkEnabled(error))
603 return;
583 if (!scriptDebugServer().setScriptSource(scriptId, newContent, asBool(previe w), error, errorData, &m_currentCallStack, &result)) 604 if (!scriptDebugServer().setScriptSource(scriptId, newContent, asBool(previe w), error, errorData, &m_currentCallStack, &result))
584 return; 605 return;
585 606
586 newCallFrames = currentCallFrames(); 607 newCallFrames = currentCallFrames();
587 asyncStackTrace = currentAsyncStackTrace(); 608 asyncStackTrace = currentAsyncStackTrace();
588 609
589 ScriptsMap::iterator it = m_scripts.find(scriptId); 610 ScriptsMap::iterator it = m_scripts.find(scriptId);
590 if (it == m_scripts.end()) 611 if (it == m_scripts.end())
591 return; 612 return;
592 String url = it->value.url(); 613 String url = it->value.url();
(...skipping 15 matching lines...) Expand all
608 } 629 }
609 630
610 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r esult); 631 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r esult);
611 m_currentCallStack = scriptDebugServer().currentCallFrames(); 632 m_currentCallStack = scriptDebugServer().currentCallFrames();
612 newCallFrames = currentCallFrames(); 633 newCallFrames = currentCallFrames();
613 asyncStackTrace = currentAsyncStackTrace(); 634 asyncStackTrace = currentAsyncStackTrace();
614 } 635 }
615 636
616 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s criptId, String* scriptSource) 637 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s criptId, String* scriptSource)
617 { 638 {
639 if (!checkEnabled(error))
640 return;
618 ScriptsMap::iterator it = m_scripts.find(scriptId); 641 ScriptsMap::iterator it = m_scripts.find(scriptId);
619 if (it == m_scripts.end()) { 642 if (it == m_scripts.end()) {
620 *error = "No script for id: " + scriptId; 643 *error = "No script for id: " + scriptId;
621 return; 644 return;
622 } 645 }
623 646
624 String url = it->value.url(); 647 String url = it->value.url();
625 if (!url.isEmpty() && getEditedScript(url, scriptSource)) 648 if (!url.isEmpty() && getEditedScript(url, scriptSource))
626 return; 649 return;
627 *scriptSource = it->value.source(); 650 *scriptSource = it->value.source();
628 } 651 }
629 652
630 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<FunctionDetails>& details) 653 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<FunctionDetails>& details)
631 { 654 {
655 if (!checkEnabled(errorString))
656 return;
632 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(functionId); 657 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(functionId);
633 if (injectedScript.isEmpty()) { 658 if (injectedScript.isEmpty()) {
634 *errorString = "Function object id is obsolete"; 659 *errorString = "Function object id is obsolete";
635 return; 660 return;
636 } 661 }
637 injectedScript.getFunctionDetails(errorString, functionId, &details); 662 injectedScript.getFunctionDetails(errorString, functionId, &details);
638 } 663 }
639 664
640 void InspectorDebuggerAgent::getGeneratorObjectDetails(ErrorString* errorString, const String& objectId, RefPtr<GeneratorObjectDetails>& details) 665 void InspectorDebuggerAgent::getGeneratorObjectDetails(ErrorString* errorString, const String& objectId, RefPtr<GeneratorObjectDetails>& details)
641 { 666 {
667 if (!checkEnabled(errorString))
668 return;
642 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); 669 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId);
643 if (injectedScript.isEmpty()) { 670 if (injectedScript.isEmpty()) {
644 *errorString = "Inspected frame has gone"; 671 *errorString = "Inspected frame has gone";
645 return; 672 return;
646 } 673 }
647 injectedScript.getGeneratorObjectDetails(errorString, objectId, &details); 674 injectedScript.getGeneratorObjectDetails(errorString, objectId, &details);
648 } 675 }
649 676
650 void InspectorDebuggerAgent::getCollectionEntries(ErrorString* errorString, cons t String& objectId, RefPtr<TypeBuilder::Array<CollectionEntry> >& entries) 677 void InspectorDebuggerAgent::getCollectionEntries(ErrorString* errorString, cons t String& objectId, RefPtr<TypeBuilder::Array<CollectionEntry> >& entries)
651 { 678 {
679 if (!checkEnabled(errorString))
680 return;
652 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); 681 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId);
653 if (injectedScript.isEmpty()) { 682 if (injectedScript.isEmpty()) {
654 *errorString = "Inspected frame has gone"; 683 *errorString = "Inspected frame has gone";
655 return; 684 return;
656 } 685 }
657 injectedScript.getCollectionEntries(errorString, objectId, &entries); 686 injectedScript.getCollectionEntries(errorString, objectId, &entries);
658 } 687 }
659 688
660 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data) 689 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data)
661 { 690 {
691 ASSERT(enabled());
662 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP aused()) 692 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP aused())
663 return; 693 return;
664 m_breakReason = breakReason; 694 m_breakReason = breakReason;
665 m_breakAuxData = data; 695 m_breakAuxData = data;
666 m_pausingOnNativeEvent = true; 696 m_pausingOnNativeEvent = true;
667 m_skipNextDebuggerStepOut = false; 697 m_skipNextDebuggerStepOut = false;
668 scriptDebugServer().setPauseOnNextStatement(true); 698 scriptDebugServer().setPauseOnNextStatement(true);
669 } 699 }
670 700
671 void InspectorDebuggerAgent::schedulePauseOnNextStatementIfSteppingInto() 701 void InspectorDebuggerAgent::schedulePauseOnNextStatementIfSteppingInto()
672 { 702 {
703 ASSERT(enabled());
673 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || isP aused()) 704 if (m_scheduledDebuggerStep != StepInto || m_javaScriptPauseScheduled || isP aused())
674 return; 705 return;
675 clearBreakDetails(); 706 clearBreakDetails();
676 m_pausingOnNativeEvent = false; 707 m_pausingOnNativeEvent = false;
677 m_skippedStepFrameCount = 0; 708 m_skippedStepFrameCount = 0;
678 m_recursionLevelForStepFrame = 0; 709 m_recursionLevelForStepFrame = 0;
679 scriptDebugServer().setPauseOnNextStatement(true); 710 scriptDebugServer().setPauseOnNextStatement(true);
680 } 711 }
681 712
682 void InspectorDebuggerAgent::didFireTimer() 713 void InspectorDebuggerAgent::didFireTimer()
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (!parentPromise.IsEmpty() && parentPromise->IsObject()) 754 if (!parentPromise.IsEmpty() && parentPromise->IsObject())
724 return; 755 return;
725 if (status < 0) 756 if (status < 0)
726 m_listener->didRejectPromise(); 757 m_listener->didRejectPromise();
727 else if (status > 0) 758 else if (status > 0)
728 m_listener->didResolvePromise(); 759 m_listener->didResolvePromise();
729 else 760 else
730 m_listener->didCreatePromise(); 761 m_listener->didCreatePromise();
731 } 762 }
732 763
733 void InspectorDebuggerAgent::pause(ErrorString*) 764 void InspectorDebuggerAgent::pause(ErrorString* errorString)
734 { 765 {
766 if (!checkEnabled(errorString))
767 return;
735 if (m_javaScriptPauseScheduled || isPaused()) 768 if (m_javaScriptPauseScheduled || isPaused())
736 return; 769 return;
737 clearBreakDetails(); 770 clearBreakDetails();
738 clearStepIntoAsync(); 771 clearStepIntoAsync();
739 m_javaScriptPauseScheduled = true; 772 m_javaScriptPauseScheduled = true;
740 m_scheduledDebuggerStep = NoStep; 773 m_scheduledDebuggerStep = NoStep;
741 m_skippedStepFrameCount = 0; 774 m_skippedStepFrameCount = 0;
742 m_steppingFromFramework = false; 775 m_steppingFromFramework = false;
743 scriptDebugServer().setPauseOnNextStatement(true); 776 scriptDebugServer().setPauseOnNextStatement(true);
744 } 777 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 *errorString = "Can only perform operation if async call stacks are enab led."; 832 *errorString = "Can only perform operation if async call stacks are enab led.";
800 return; 833 return;
801 } 834 }
802 clearStepIntoAsync(); 835 clearStepIntoAsync();
803 m_startingStepIntoAsync = true; 836 m_startingStepIntoAsync = true;
804 stepInto(errorString); 837 stepInto(errorString);
805 } 838 }
806 839
807 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons t String& stringPauseState) 840 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons t String& stringPauseState)
808 { 841 {
842 if (!checkEnabled(errorString))
843 return;
809 ScriptDebugServer::PauseOnExceptionsState pauseState; 844 ScriptDebugServer::PauseOnExceptionsState pauseState;
810 if (stringPauseState == "none") 845 if (stringPauseState == "none")
811 pauseState = ScriptDebugServer::DontPauseOnExceptions; 846 pauseState = ScriptDebugServer::DontPauseOnExceptions;
812 else if (stringPauseState == "all") 847 else if (stringPauseState == "all")
813 pauseState = ScriptDebugServer::PauseOnAllExceptions; 848 pauseState = ScriptDebugServer::PauseOnAllExceptions;
814 else if (stringPauseState == "uncaught") 849 else if (stringPauseState == "uncaught")
815 pauseState = ScriptDebugServer::PauseOnUncaughtExceptions; 850 pauseState = ScriptDebugServer::PauseOnUncaughtExceptions;
816 else { 851 else {
817 *errorString = "Unknown pause on exceptions mode: " + stringPauseState; 852 *errorString = "Unknown pause on exceptions mode: " + stringPauseState;
818 return; 853 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", asBool(includ eCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasTh rown, &exceptionDetails); 895 injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, asyncCal lStacks, callFrameId, expression, objectGroup ? *objectGroup : "", asBool(includ eCommandLineAPI), asBool(returnByValue), asBool(generatePreview), &result, wasTh rown, &exceptionDetails);
861 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { 896 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
862 unmuteConsole(); 897 unmuteConsole();
863 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 898 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
864 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 899 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
865 } 900 }
866 } 901 }
867 902
868 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, bool persistScript, const int* execution ContextId, TypeBuilder::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>& exceptionDetails) 903 void InspectorDebuggerAgent::compileScript(ErrorString* errorString, const Strin g& expression, const String& sourceURL, bool persistScript, const int* execution ContextId, TypeBuilder::OptOutput<ScriptId>* scriptId, RefPtr<ExceptionDetails>& exceptionDetails)
869 { 904 {
905 if (!checkEnabled(errorString))
906 return;
870 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 907 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
871 if (injectedScript.isEmpty()) { 908 if (injectedScript.isEmpty()) {
872 *errorString = "Inspected frame has gone"; 909 *errorString = "Inspected frame has gone";
873 return; 910 return;
874 } 911 }
875 912
876 String scriptIdValue; 913 String scriptIdValue;
877 String exceptionDetailsText; 914 String exceptionDetailsText;
878 int lineNumberValue = 0; 915 int lineNumberValue = 0;
879 int columnNumberValue = 0; 916 int columnNumberValue = 0;
880 RefPtrWillBeRawPtr<ScriptCallStack> stackTraceValue = nullptr; 917 RefPtrWillBeRawPtr<ScriptCallStack> stackTraceValue = nullptr;
881 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, persistScript, &scriptIdValue, &exceptionDetailsText, &lineNumberValu e, &columnNumberValue, &stackTraceValue); 918 scriptDebugServer().compileScript(injectedScript.scriptState(), expression, sourceURL, persistScript, &scriptIdValue, &exceptionDetailsText, &lineNumberValu e, &columnNumberValue, &stackTraceValue);
882 if (!scriptIdValue && !exceptionDetailsText) { 919 if (!scriptIdValue && !exceptionDetailsText) {
883 *errorString = "Script compilation failed"; 920 *errorString = "Script compilation failed";
884 return; 921 return;
885 } 922 }
886 *scriptId = scriptIdValue; 923 *scriptId = scriptIdValue;
887 if (!scriptIdValue.isEmpty()) 924 if (!scriptIdValue.isEmpty())
888 return; 925 return;
889 926
890 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText); 927 exceptionDetails = ExceptionDetails::create().setText(exceptionDetailsText);
891 exceptionDetails->setLine(lineNumberValue); 928 exceptionDetails->setLine(lineNumberValue);
892 exceptionDetails->setColumn(columnNumberValue); 929 exceptionDetails->setColumn(columnNumberValue);
893 if (stackTraceValue && stackTraceValue->size() > 0) 930 if (stackTraceValue && stackTraceValue->size() > 0)
894 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray()); 931 exceptionDetails->setStackTrace(stackTraceValue->buildInspectorArray());
895 } 932 }
896 933
897 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, RefPtr<ExceptionDetails>& exceptionDetails) 934 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId& scriptId, const int* executionContextId, const String* const objectGroup, const bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result, RefPtr<ExceptionDetails>& exceptionDetails)
898 { 935 {
936 if (!checkEnabled(errorString))
937 return;
899 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId); 938 InjectedScript injectedScript = injectedScriptForEval(errorString, execution ContextId);
900 if (injectedScript.isEmpty()) { 939 if (injectedScript.isEmpty()) {
901 *errorString = "Inspected frame has gone"; 940 *errorString = "Inspected frame has gone";
902 return; 941 return;
903 } 942 }
904 943
905 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState(); 944 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s criptDebugServer().pauseOnExceptionsState();
906 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { 945 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
907 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions) 946 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce ptions)
908 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions); 947 scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::Don tPauseOnExceptions);
(...skipping 22 matching lines...) Expand all
931 970
932 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { 971 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
933 unmuteConsole(); 972 unmuteConsole();
934 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState) 973 if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExcep tionsState)
935 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState); 974 scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExcepti onsState);
936 } 975 }
937 } 976 }
938 977
939 void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scop eNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const S tring* callFrameId, const String* functionObjectId) 978 void InspectorDebuggerAgent::setVariableValue(ErrorString* errorString, int scop eNumber, const String& variableName, const RefPtr<JSONObject>& newValue, const S tring* callFrameId, const String* functionObjectId)
940 { 979 {
980 if (!checkEnabled(errorString))
981 return;
941 InjectedScript injectedScript; 982 InjectedScript injectedScript;
942 if (callFrameId) { 983 if (callFrameId) {
943 if (!isPaused() || m_currentCallStack.isEmpty()) { 984 if (!isPaused() || m_currentCallStack.isEmpty()) {
944 *errorString = "Attempt to access callframe when debugger is not on pause"; 985 *errorString = "Attempt to access callframe when debugger is not on pause";
945 return; 986 return;
946 } 987 }
947 injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*cal lFrameId); 988 injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*cal lFrameId);
948 if (injectedScript.isEmpty()) { 989 if (injectedScript.isEmpty()) {
949 *errorString = "Inspected frame has gone"; 990 *errorString = "Inspected frame has gone";
950 return; 991 return;
951 } 992 }
952 } else if (functionObjectId) { 993 } else if (functionObjectId) {
953 injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*fun ctionObjectId); 994 injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*fun ctionObjectId);
954 if (injectedScript.isEmpty()) { 995 if (injectedScript.isEmpty()) {
955 *errorString = "Function object id cannot be resolved"; 996 *errorString = "Function object id cannot be resolved";
956 return; 997 return;
957 } 998 }
958 } else { 999 } else {
959 *errorString = "Either call frame or function object must be specified"; 1000 *errorString = "Either call frame or function object must be specified";
960 return; 1001 return;
961 } 1002 }
962 String newValueString = newValue->toJSONString(); 1003 String newValueString = newValue->toJSONString();
963 1004
964 injectedScript.setVariableValue(errorString, m_currentCallStack, callFrameId , functionObjectId, scopeNumber, variableName, newValueString); 1005 injectedScript.setVariableValue(errorString, m_currentCallStack, callFrameId , functionObjectId, scopeNumber, variableName, newValueString);
965 } 1006 }
966 1007
967 void InspectorDebuggerAgent::skipStackFrames(ErrorString* errorString, const Str ing* pattern, const bool* skipContentScripts) 1008 void InspectorDebuggerAgent::skipStackFrames(ErrorString* errorString, const Str ing* pattern, const bool* skipContentScripts)
968 { 1009 {
1010 if (!checkEnabled(errorString))
1011 return;
969 OwnPtr<ScriptRegexp> compiled; 1012 OwnPtr<ScriptRegexp> compiled;
970 String patternValue = pattern ? *pattern : ""; 1013 String patternValue = pattern ? *pattern : "";
971 if (!patternValue.isEmpty()) { 1014 if (!patternValue.isEmpty()) {
972 compiled = compileSkipCallFramePattern(patternValue); 1015 compiled = compileSkipCallFramePattern(patternValue);
973 if (!compiled) { 1016 if (!compiled) {
974 *errorString = "Invalid regular expression"; 1017 *errorString = "Invalid regular expression";
975 return; 1018 return;
976 } 1019 }
977 } 1020 }
978 m_state->setString(DebuggerAgentState::skipStackPattern, patternValue); 1021 m_state->setString(DebuggerAgentState::skipStackPattern, patternValue);
979 m_cachedSkipStackRegExp = compiled.release(); 1022 m_cachedSkipStackRegExp = compiled.release();
980 increaseCachedSkipStackGeneration(); 1023 increaseCachedSkipStackGeneration();
981 m_skipContentScripts = asBool(skipContentScripts); 1024 m_skipContentScripts = asBool(skipContentScripts);
982 m_state->setBoolean(DebuggerAgentState::skipContentScripts, m_skipContentScr ipts); 1025 m_state->setBoolean(DebuggerAgentState::skipContentScripts, m_skipContentScr ipts);
983 } 1026 }
984 1027
985 void InspectorDebuggerAgent::setAsyncCallStackDepth(ErrorString*, int depth) 1028 void InspectorDebuggerAgent::setAsyncCallStackDepth(ErrorString* errorString, in t depth)
986 { 1029 {
1030 if (!checkEnabled(errorString))
1031 return;
987 m_state->setLong(DebuggerAgentState::asyncCallStackDepth, depth); 1032 m_state->setLong(DebuggerAgentState::asyncCallStackDepth, depth);
988 internalSetAsyncCallStackDepth(depth); 1033 internalSetAsyncCallStackDepth(depth);
989 } 1034 }
990 1035
991 void InspectorDebuggerAgent::enablePromiseTracker(ErrorString*, const bool* capt ureStacks) 1036 void InspectorDebuggerAgent::enablePromiseTracker(ErrorString* errorString, cons t bool* captureStacks)
992 { 1037 {
1038 if (!checkEnabled(errorString))
1039 return;
993 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, true); 1040 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, true);
994 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, asBool( captureStacks)); 1041 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, asBool( captureStacks));
995 promiseTracker().setEnabled(true, asBool(captureStacks)); 1042 promiseTracker().setEnabled(true, asBool(captureStacks));
996 } 1043 }
997 1044
998 void InspectorDebuggerAgent::disablePromiseTracker(ErrorString*) 1045 void InspectorDebuggerAgent::disablePromiseTracker(ErrorString* errorString)
999 { 1046 {
1047 if (!checkEnabled(errorString))
1048 return;
1000 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); 1049 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false);
1001 promiseTracker().setEnabled(false, false); 1050 promiseTracker().setEnabled(false, false);
1002 } 1051 }
1003 1052
1004 void InspectorDebuggerAgent::getPromiseById(ErrorString* errorString, int promis eId, const String* objectGroup, RefPtr<RemoteObject>& promise) 1053 void InspectorDebuggerAgent::getPromiseById(ErrorString* errorString, int promis eId, const String* objectGroup, RefPtr<RemoteObject>& promise)
1005 { 1054 {
1055 if (!checkEnabled(errorString))
1056 return;
1006 if (!promiseTracker().isEnabled()) { 1057 if (!promiseTracker().isEnabled()) {
1007 *errorString = "Promise tracking is disabled"; 1058 *errorString = "Promise tracking is disabled";
1008 return; 1059 return;
1009 } 1060 }
1010 ScriptValue value = promiseTracker().promiseById(promiseId); 1061 ScriptValue value = promiseTracker().promiseById(promiseId);
1011 if (value.isEmpty()) { 1062 if (value.isEmpty()) {
1012 *errorString = "Promise with specified ID not found."; 1063 *errorString = "Promise with specified ID not found.";
1013 return; 1064 return;
1014 } 1065 }
1015 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState()); 1066 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(v alue.scriptState());
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 frontend()->resumed(); 1582 frontend()->resumed();
1532 } 1583 }
1533 1584
1534 bool InspectorDebuggerAgent::canBreakProgram() 1585 bool InspectorDebuggerAgent::canBreakProgram()
1535 { 1586 {
1536 return scriptDebugServer().canBreakProgram(); 1587 return scriptDebugServer().canBreakProgram();
1537 } 1588 }
1538 1589
1539 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E num breakReason, PassRefPtr<JSONObject> data) 1590 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E num breakReason, PassRefPtr<JSONObject> data)
1540 { 1591 {
1592 ASSERT(enabled());
1541 if (m_skipAllPauses || m_pausedScriptState || isCallStackEmptyOrBlackboxed() ) 1593 if (m_skipAllPauses || m_pausedScriptState || isCallStackEmptyOrBlackboxed() )
1542 return; 1594 return;
1543 m_breakReason = breakReason; 1595 m_breakReason = breakReason;
1544 m_breakAuxData = data; 1596 m_breakAuxData = data;
1545 m_scheduledDebuggerStep = NoStep; 1597 m_scheduledDebuggerStep = NoStep;
1546 m_steppingFromFramework = false; 1598 m_steppingFromFramework = false;
1547 m_pausingOnNativeEvent = false; 1599 m_pausingOnNativeEvent = false;
1548 clearStepIntoAsync(); 1600 clearStepIntoAsync();
1549 scriptDebugServer().breakProgram(); 1601 scriptDebugServer().breakProgram();
1550 } 1602 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 visitor->trace(m_v8AsyncCallTracker); 1680 visitor->trace(m_v8AsyncCallTracker);
1629 visitor->trace(m_promiseTracker); 1681 visitor->trace(m_promiseTracker);
1630 visitor->trace(m_asyncOperations); 1682 visitor->trace(m_asyncOperations);
1631 visitor->trace(m_currentAsyncCallChain); 1683 visitor->trace(m_currentAsyncCallChain);
1632 visitor->trace(m_asyncCallTrackingListeners); 1684 visitor->trace(m_asyncCallTrackingListeners);
1633 #endif 1685 #endif
1634 InspectorBaseAgent::trace(visitor); 1686 InspectorBaseAgent::trace(visitor);
1635 } 1687 }
1636 1688
1637 } // namespace blink 1689 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698