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

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

Issue 360053002: Revert of DevTools: Debugger StepInto/Out/Over initiated from a framework should not black-box it. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co lumnNumber) + breakpointIdSuffix(source); 99 return scriptId + ':' + String::number(lineNumber) + ':' + String::number(co lumnNumber) + breakpointIdSuffix(source);
100 } 100 }
101 101
102 InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedSc riptManager) 102 InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedSc riptManager)
103 : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger") 103 : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger")
104 , m_injectedScriptManager(injectedScriptManager) 104 , m_injectedScriptManager(injectedScriptManager)
105 , m_frontend(0) 105 , m_frontend(0)
106 , m_pausedScriptState(nullptr) 106 , m_pausedScriptState(nullptr)
107 , m_javaScriptPauseScheduled(false) 107 , m_javaScriptPauseScheduled(false)
108 , m_debuggerStepScheduled(false) 108 , m_debuggerStepScheduled(false)
109 , m_steppingFromFramework(false)
110 , m_pausingOnNativeEvent(false) 109 , m_pausingOnNativeEvent(false)
111 , m_listener(0) 110 , m_listener(0)
112 , m_skippedStepInCount(0) 111 , m_skippedStepInCount(0)
113 , m_skipAllPauses(false) 112 , m_skipAllPauses(false)
114 { 113 {
115 } 114 }
116 115
117 InspectorDebuggerAgent::~InspectorDebuggerAgent() 116 InspectorDebuggerAgent::~InspectorDebuggerAgent()
118 { 117 {
119 ASSERT(!m_instrumentingAgents->inspectorDebuggerAgent()); 118 ASSERT(!m_instrumentingAgents->inspectorDebuggerAgent());
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 { 467 {
469 String scriptIdString = String::number(frame->sourceID()); 468 String scriptIdString = String::number(frame->sourceID());
470 ScriptsMap::iterator it = m_scripts.find(scriptIdString); 469 ScriptsMap::iterator it = m_scripts.find(scriptIdString);
471 if (it == m_scripts.end()) 470 if (it == m_scripts.end())
472 return String(); 471 return String();
473 return it->value.url; 472 return it->value.url;
474 } 473 }
475 474
476 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipExceptio nPause() 475 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipExceptio nPause()
477 { 476 {
478 if (m_steppingFromFramework)
479 return ScriptDebugListener::NoSkip;
480
481 // FIXME: Fast return: if (!m_cachedSkipStackRegExp && !has_any_anti_breakpo int) return ScriptDebugListener::NoSkip; 477 // FIXME: Fast return: if (!m_cachedSkipStackRegExp && !has_any_anti_breakpo int) return ScriptDebugListener::NoSkip;
482 478
483 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa llFrameNoScopes(); 479 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa llFrameNoScopes();
484 if (!topFrame) 480 if (!topFrame)
485 return ScriptDebugListener::NoSkip; 481 return ScriptDebugListener::NoSkip;
486 482
487 String topFrameScriptUrl = scriptURL(topFrame.get()); 483 String topFrameScriptUrl = scriptURL(topFrame.get());
488 if (m_cachedSkipStackRegExp && !topFrameScriptUrl.isEmpty() && m_cachedSkipS tackRegExp->match(topFrameScriptUrl) != -1) 484 if (m_cachedSkipStackRegExp && !topFrameScriptUrl.isEmpty() && m_cachedSkipS tackRegExp->match(topFrameScriptUrl) != -1)
489 return ScriptDebugListener::Continue; 485 return ScriptDebugListener::Continue;
490 486
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 continue; 519 continue;
524 520
525 return ScriptDebugListener::Continue; 521 return ScriptDebugListener::Continue;
526 } 522 }
527 523
528 return ScriptDebugListener::NoSkip; 524 return ScriptDebugListener::NoSkip;
529 } 525 }
530 526
531 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipStepPaus e() 527 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipStepPaus e()
532 { 528 {
533 if (!m_cachedSkipStackRegExp || m_steppingFromFramework) 529 if (!m_cachedSkipStackRegExp)
534 return ScriptDebugListener::NoSkip; 530 return ScriptDebugListener::NoSkip;
535 531
536 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa llFrameNoScopes(); 532 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa llFrameNoScopes();
537 String scriptUrl = scriptURL(topFrame.get()); 533 String scriptUrl = scriptURL(topFrame.get());
538 if (scriptUrl.isEmpty() || m_cachedSkipStackRegExp->match(scriptUrl) == -1) 534 if (scriptUrl.isEmpty() || m_cachedSkipStackRegExp->match(scriptUrl) == -1)
539 return ScriptDebugListener::NoSkip; 535 return ScriptDebugListener::NoSkip;
540 536
541 if (m_skippedStepInCount == 0) { 537 if (m_skippedStepInCount == 0) {
542 m_minFrameCountForSkip = scriptDebugServer().frameCount(); 538 m_minFrameCountForSkip = scriptDebugServer().frameCount();
543 m_skippedStepInCount = 1; 539 m_skippedStepInCount = 1;
544 return ScriptDebugListener::StepInto; 540 return ScriptDebugListener::StepInto;
545 } 541 }
546 542
547 if (m_skippedStepInCount < maxSkipStepInCount && topFrame->isAtReturn() && s criptDebugServer().frameCount() <= m_minFrameCountForSkip) 543 if (m_skippedStepInCount < maxSkipStepInCount && topFrame->isAtReturn() && s criptDebugServer().frameCount() <= m_minFrameCountForSkip)
548 m_skippedStepInCount = maxSkipStepInCount; 544 m_skippedStepInCount = maxSkipStepInCount;
549 545
550 if (m_skippedStepInCount >= maxSkipStepInCount) { 546 if (m_skippedStepInCount >= maxSkipStepInCount) {
551 if (m_pausingOnNativeEvent) { 547 if (m_pausingOnNativeEvent) {
552 m_pausingOnNativeEvent = false; 548 m_pausingOnNativeEvent = false;
553 m_skippedStepInCount = 0; 549 m_skippedStepInCount = 0;
554 return ScriptDebugListener::Continue; 550 return ScriptDebugListener::Continue;
555 } 551 }
556 return ScriptDebugListener::StepOut; 552 return ScriptDebugListener::StepOut;
557 } 553 }
558 554
559 ++m_skippedStepInCount; 555 ++m_skippedStepInCount;
560 return ScriptDebugListener::StepInto; 556 return ScriptDebugListener::StepInto;
561 } 557 }
562 558
563 bool InspectorDebuggerAgent::isTopCallFrameInFramework()
564 {
565 if (!m_cachedSkipStackRegExp)
566 return false;
567
568 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa llFrameNoScopes();
569 String scriptUrl = scriptURL(topFrame.get());
570 return !scriptUrl.isEmpty() && m_cachedSkipStackRegExp->match(scriptUrl) != -1;
571 }
572
573 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint & breakpoint, BreakpointSource source) 559 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint & breakpoint, BreakpointSource source)
574 { 560 {
575 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 561 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
576 if (scriptIterator == m_scripts.end()) 562 if (scriptIterator == m_scripts.end())
577 return nullptr; 563 return nullptr;
578 Script& script = scriptIterator->value; 564 Script& script = scriptIterator->value;
579 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint. lineNumber) 565 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint. lineNumber)
580 return nullptr; 566 return nullptr;
581 567
582 int actualLineNumber; 568 int actualLineNumber;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 clearBreakDetails(); 776 clearBreakDetails();
791 m_javaScriptPauseScheduled = true; 777 m_javaScriptPauseScheduled = true;
792 scriptDebugServer().setPauseOnNextStatement(true); 778 scriptDebugServer().setPauseOnNextStatement(true);
793 } 779 }
794 780
795 void InspectorDebuggerAgent::resume(ErrorString* errorString) 781 void InspectorDebuggerAgent::resume(ErrorString* errorString)
796 { 782 {
797 if (!assertPaused(errorString)) 783 if (!assertPaused(errorString))
798 return; 784 return;
799 m_debuggerStepScheduled = false; 785 m_debuggerStepScheduled = false;
800 m_steppingFromFramework = false;
801 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup); 786 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup);
802 scriptDebugServer().continueProgram(); 787 scriptDebugServer().continueProgram();
803 } 788 }
804 789
805 void InspectorDebuggerAgent::stepOver(ErrorString* errorString) 790 void InspectorDebuggerAgent::stepOver(ErrorString* errorString)
806 { 791 {
807 if (!assertPaused(errorString)) 792 if (!assertPaused(errorString))
808 return; 793 return;
809 m_debuggerStepScheduled = true; 794 m_debuggerStepScheduled = true;
810 m_steppingFromFramework = isTopCallFrameInFramework();
811 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup); 795 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup);
812 scriptDebugServer().stepOverStatement(); 796 scriptDebugServer().stepOverStatement();
813 } 797 }
814 798
815 void InspectorDebuggerAgent::stepInto(ErrorString* errorString) 799 void InspectorDebuggerAgent::stepInto(ErrorString* errorString)
816 { 800 {
817 if (!assertPaused(errorString)) 801 if (!assertPaused(errorString))
818 return; 802 return;
819 m_debuggerStepScheduled = true; 803 m_debuggerStepScheduled = true;
820 m_steppingFromFramework = isTopCallFrameInFramework();
821 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup); 804 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup);
822 scriptDebugServer().stepIntoStatement(); 805 scriptDebugServer().stepIntoStatement();
823 if (m_listener) 806 if (m_listener)
824 m_listener->stepInto(); 807 m_listener->stepInto();
825 } 808 }
826 809
827 void InspectorDebuggerAgent::stepOut(ErrorString* errorString) 810 void InspectorDebuggerAgent::stepOut(ErrorString* errorString)
828 { 811 {
829 if (!assertPaused(errorString)) 812 if (!assertPaused(errorString))
830 return; 813 return;
831 m_debuggerStepScheduled = true; 814 m_debuggerStepScheduled = true;
832 m_steppingFromFramework = isTopCallFrameInFramework();
833 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup); 815 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac eObjectGroup);
834 scriptDebugServer().stepOutOfFunction(); 816 scriptDebugServer().stepOutOfFunction();
835 } 817 }
836 818
837 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons t String& stringPauseState) 819 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons t String& stringPauseState)
838 { 820 {
839 ScriptDebugServer::PauseOnExceptionsState pauseState; 821 ScriptDebugServer::PauseOnExceptionsState pauseState;
840 if (stringPauseState == "none") 822 if (stringPauseState == "none")
841 pauseState = ScriptDebugServer::DontPauseOnExceptions; 823 pauseState = ScriptDebugServer::DontPauseOnExceptions;
842 else if (stringPauseState == "all") 824 else if (stringPauseState == "all")
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1165
1184 BreakpointSource source = breakpointIterator->value.second; 1166 BreakpointSource source = breakpointIterator->value.second;
1185 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s ource == DebugCommandBreakpointSource) 1167 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s ource == DebugCommandBreakpointSource)
1186 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman d; 1168 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman d;
1187 } 1169 }
1188 } 1170 }
1189 1171
1190 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr eakpointIds, currentAsyncStackTrace()); 1172 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr eakpointIds, currentAsyncStackTrace());
1191 m_javaScriptPauseScheduled = false; 1173 m_javaScriptPauseScheduled = false;
1192 m_debuggerStepScheduled = false; 1174 m_debuggerStepScheduled = false;
1193 m_steppingFromFramework = false;
1194 m_pausingOnNativeEvent = false; 1175 m_pausingOnNativeEvent = false;
1195 m_skippedStepInCount = 0; 1176 m_skippedStepInCount = 0;
1196 1177
1197 if (!m_continueToLocationBreakpointId.isEmpty()) { 1178 if (!m_continueToLocationBreakpointId.isEmpty()) {
1198 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); 1179 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
1199 m_continueToLocationBreakpointId = ""; 1180 m_continueToLocationBreakpointId = "";
1200 } 1181 }
1201 if (m_listener) 1182 if (m_listener)
1202 m_listener->didPause(); 1183 m_listener->didPause();
1203 return result; 1184 return result;
(...skipping 12 matching lines...) Expand all
1216 return scriptDebugServer().canBreakProgram(); 1197 return scriptDebugServer().canBreakProgram();
1217 } 1198 }
1218 1199
1219 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E num breakReason, PassRefPtr<JSONObject> data) 1200 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E num breakReason, PassRefPtr<JSONObject> data)
1220 { 1201 {
1221 if (m_skipAllPauses) 1202 if (m_skipAllPauses)
1222 return; 1203 return;
1223 m_breakReason = breakReason; 1204 m_breakReason = breakReason;
1224 m_breakAuxData = data; 1205 m_breakAuxData = data;
1225 m_debuggerStepScheduled = false; 1206 m_debuggerStepScheduled = false;
1226 m_steppingFromFramework = false;
1227 m_pausingOnNativeEvent = false; 1207 m_pausingOnNativeEvent = false;
1228 scriptDebugServer().breakProgram(); 1208 scriptDebugServer().breakProgram();
1229 } 1209 }
1230 1210
1231 void InspectorDebuggerAgent::clear() 1211 void InspectorDebuggerAgent::clear()
1232 { 1212 {
1233 m_pausedScriptState = nullptr; 1213 m_pausedScriptState = nullptr;
1234 m_currentCallStack = ScriptValue(); 1214 m_currentCallStack = ScriptValue();
1235 m_scripts.clear(); 1215 m_scripts.clear();
1236 m_breakpointIdToDebugServerBreakpointIds.clear(); 1216 m_breakpointIdToDebugServerBreakpointIds.clear();
1237 m_asyncCallStackTracker.clear(); 1217 m_asyncCallStackTracker.clear();
1238 m_continueToLocationBreakpointId = String(); 1218 m_continueToLocationBreakpointId = String();
1239 clearBreakDetails(); 1219 clearBreakDetails();
1240 m_javaScriptPauseScheduled = false; 1220 m_javaScriptPauseScheduled = false;
1241 m_debuggerStepScheduled = false; 1221 m_debuggerStepScheduled = false;
1242 m_steppingFromFramework = false;
1243 m_pausingOnNativeEvent = false; 1222 m_pausingOnNativeEvent = false;
1244 ErrorString error; 1223 ErrorString error;
1245 setOverlayMessage(&error, 0); 1224 setOverlayMessage(&error, 0);
1246 } 1225 }
1247 1226
1248 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) 1227 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString)
1249 { 1228 {
1250 if (!m_pausedScriptState) { 1229 if (!m_pausedScriptState) {
1251 *errorString = "Can only perform operation while paused."; 1230 *errorString = "Can only perform operation while paused.";
1252 return false; 1231 return false;
(...skipping 23 matching lines...) Expand all
1276 { 1255 {
1277 m_scripts.clear(); 1256 m_scripts.clear();
1278 m_breakpointIdToDebugServerBreakpointIds.clear(); 1257 m_breakpointIdToDebugServerBreakpointIds.clear();
1279 m_asyncCallStackTracker.clear(); 1258 m_asyncCallStackTracker.clear();
1280 if (m_frontend) 1259 if (m_frontend)
1281 m_frontend->globalObjectCleared(); 1260 m_frontend->globalObjectCleared();
1282 } 1261 }
1283 1262
1284 } // namespace WebCore 1263 } // namespace WebCore
1285 1264
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