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

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

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