OLD | NEW |
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 Loading... |
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) |
109 , m_pausingOnNativeEvent(false) | 110 , m_pausingOnNativeEvent(false) |
110 , m_listener(0) | 111 , m_listener(0) |
111 , m_skippedStepInCount(0) | 112 , m_skippedStepInCount(0) |
112 , m_skipAllPauses(false) | 113 , m_skipAllPauses(false) |
113 { | 114 { |
114 } | 115 } |
115 | 116 |
116 InspectorDebuggerAgent::~InspectorDebuggerAgent() | 117 InspectorDebuggerAgent::~InspectorDebuggerAgent() |
117 { | 118 { |
118 ASSERT(!m_instrumentingAgents->inspectorDebuggerAgent()); | 119 ASSERT(!m_instrumentingAgents->inspectorDebuggerAgent()); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 { | 468 { |
468 String scriptIdString = String::number(frame->sourceID()); | 469 String scriptIdString = String::number(frame->sourceID()); |
469 ScriptsMap::iterator it = m_scripts.find(scriptIdString); | 470 ScriptsMap::iterator it = m_scripts.find(scriptIdString); |
470 if (it == m_scripts.end()) | 471 if (it == m_scripts.end()) |
471 return String(); | 472 return String(); |
472 return it->value.url; | 473 return it->value.url; |
473 } | 474 } |
474 | 475 |
475 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipExceptio
nPause() | 476 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipExceptio
nPause() |
476 { | 477 { |
| 478 if (m_steppingFromFramework) |
| 479 return ScriptDebugListener::NoSkip; |
| 480 |
477 // FIXME: Fast return: if (!m_cachedSkipStackRegExp && !has_any_anti_breakpo
int) return ScriptDebugListener::NoSkip; | 481 // FIXME: Fast return: if (!m_cachedSkipStackRegExp && !has_any_anti_breakpo
int) return ScriptDebugListener::NoSkip; |
478 | 482 |
479 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa
llFrameNoScopes(); | 483 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa
llFrameNoScopes(); |
480 if (!topFrame) | 484 if (!topFrame) |
481 return ScriptDebugListener::NoSkip; | 485 return ScriptDebugListener::NoSkip; |
482 | 486 |
483 String topFrameScriptUrl = scriptURL(topFrame.get()); | 487 String topFrameScriptUrl = scriptURL(topFrame.get()); |
484 if (m_cachedSkipStackRegExp && !topFrameScriptUrl.isEmpty() && m_cachedSkipS
tackRegExp->match(topFrameScriptUrl) != -1) | 488 if (m_cachedSkipStackRegExp && !topFrameScriptUrl.isEmpty() && m_cachedSkipS
tackRegExp->match(topFrameScriptUrl) != -1) |
485 return ScriptDebugListener::Continue; | 489 return ScriptDebugListener::Continue; |
486 | 490 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 continue; | 523 continue; |
520 | 524 |
521 return ScriptDebugListener::Continue; | 525 return ScriptDebugListener::Continue; |
522 } | 526 } |
523 | 527 |
524 return ScriptDebugListener::NoSkip; | 528 return ScriptDebugListener::NoSkip; |
525 } | 529 } |
526 | 530 |
527 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipStepPaus
e() | 531 ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::shouldSkipStepPaus
e() |
528 { | 532 { |
529 if (!m_cachedSkipStackRegExp) | 533 if (!m_cachedSkipStackRegExp || m_steppingFromFramework) |
530 return ScriptDebugListener::NoSkip; | 534 return ScriptDebugListener::NoSkip; |
531 | 535 |
532 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa
llFrameNoScopes(); | 536 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa
llFrameNoScopes(); |
533 String scriptUrl = scriptURL(topFrame.get()); | 537 String scriptUrl = scriptURL(topFrame.get()); |
534 if (scriptUrl.isEmpty() || m_cachedSkipStackRegExp->match(scriptUrl) == -1) | 538 if (scriptUrl.isEmpty() || m_cachedSkipStackRegExp->match(scriptUrl) == -1) |
535 return ScriptDebugListener::NoSkip; | 539 return ScriptDebugListener::NoSkip; |
536 | 540 |
537 if (m_skippedStepInCount == 0) { | 541 if (m_skippedStepInCount == 0) { |
538 m_minFrameCountForSkip = scriptDebugServer().frameCount(); | 542 m_minFrameCountForSkip = scriptDebugServer().frameCount(); |
539 m_skippedStepInCount = 1; | 543 m_skippedStepInCount = 1; |
540 return ScriptDebugListener::StepInto; | 544 return ScriptDebugListener::StepInto; |
541 } | 545 } |
542 | 546 |
543 if (m_skippedStepInCount < maxSkipStepInCount && topFrame->isAtReturn() && s
criptDebugServer().frameCount() <= m_minFrameCountForSkip) | 547 if (m_skippedStepInCount < maxSkipStepInCount && topFrame->isAtReturn() && s
criptDebugServer().frameCount() <= m_minFrameCountForSkip) |
544 m_skippedStepInCount = maxSkipStepInCount; | 548 m_skippedStepInCount = maxSkipStepInCount; |
545 | 549 |
546 if (m_skippedStepInCount >= maxSkipStepInCount) { | 550 if (m_skippedStepInCount >= maxSkipStepInCount) { |
547 if (m_pausingOnNativeEvent) { | 551 if (m_pausingOnNativeEvent) { |
548 m_pausingOnNativeEvent = false; | 552 m_pausingOnNativeEvent = false; |
549 m_skippedStepInCount = 0; | 553 m_skippedStepInCount = 0; |
550 return ScriptDebugListener::Continue; | 554 return ScriptDebugListener::Continue; |
551 } | 555 } |
552 return ScriptDebugListener::StepOut; | 556 return ScriptDebugListener::StepOut; |
553 } | 557 } |
554 | 558 |
555 ++m_skippedStepInCount; | 559 ++m_skippedStepInCount; |
556 return ScriptDebugListener::StepInto; | 560 return ScriptDebugListener::StepInto; |
557 } | 561 } |
558 | 562 |
| 563 bool InspectorDebuggerAgent::isTopCallFrameInFramework() |
| 564 { |
| 565 if (!m_cachedSkipStackRegExp) |
| 566 return false; |
| 567 |
| 568 RefPtrWillBeRawPtr<JavaScriptCallFrame> topFrame = scriptDebugServer().topCa
llFrameNoScopes(); |
| 569 if (!topFrame) |
| 570 return false; |
| 571 |
| 572 String scriptUrl = scriptURL(topFrame.get()); |
| 573 return !scriptUrl.isEmpty() && m_cachedSkipStackRegExp->match(scriptUrl) !=
-1; |
| 574 } |
| 575 |
559 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak
point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint
& breakpoint, BreakpointSource source) | 576 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak
point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint
& breakpoint, BreakpointSource source) |
560 { | 577 { |
561 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 578 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
562 if (scriptIterator == m_scripts.end()) | 579 if (scriptIterator == m_scripts.end()) |
563 return nullptr; | 580 return nullptr; |
564 Script& script = scriptIterator->value; | 581 Script& script = scriptIterator->value; |
565 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.
lineNumber) | 582 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.
lineNumber) |
566 return nullptr; | 583 return nullptr; |
567 | 584 |
568 int actualLineNumber; | 585 int actualLineNumber; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 clearBreakDetails(); | 813 clearBreakDetails(); |
797 m_javaScriptPauseScheduled = true; | 814 m_javaScriptPauseScheduled = true; |
798 scriptDebugServer().setPauseOnNextStatement(true); | 815 scriptDebugServer().setPauseOnNextStatement(true); |
799 } | 816 } |
800 | 817 |
801 void InspectorDebuggerAgent::resume(ErrorString* errorString) | 818 void InspectorDebuggerAgent::resume(ErrorString* errorString) |
802 { | 819 { |
803 if (!assertPaused(errorString)) | 820 if (!assertPaused(errorString)) |
804 return; | 821 return; |
805 m_debuggerStepScheduled = false; | 822 m_debuggerStepScheduled = false; |
| 823 m_steppingFromFramework = false; |
806 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); | 824 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); |
807 scriptDebugServer().continueProgram(); | 825 scriptDebugServer().continueProgram(); |
808 } | 826 } |
809 | 827 |
810 void InspectorDebuggerAgent::stepOver(ErrorString* errorString) | 828 void InspectorDebuggerAgent::stepOver(ErrorString* errorString) |
811 { | 829 { |
812 if (!assertPaused(errorString)) | 830 if (!assertPaused(errorString)) |
813 return; | 831 return; |
814 m_debuggerStepScheduled = true; | 832 m_debuggerStepScheduled = true; |
| 833 m_steppingFromFramework = isTopCallFrameInFramework(); |
815 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); | 834 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); |
816 scriptDebugServer().stepOverStatement(); | 835 scriptDebugServer().stepOverStatement(); |
817 } | 836 } |
818 | 837 |
819 void InspectorDebuggerAgent::stepInto(ErrorString* errorString) | 838 void InspectorDebuggerAgent::stepInto(ErrorString* errorString) |
820 { | 839 { |
821 if (!assertPaused(errorString)) | 840 if (!assertPaused(errorString)) |
822 return; | 841 return; |
823 m_debuggerStepScheduled = true; | 842 m_debuggerStepScheduled = true; |
| 843 m_steppingFromFramework = isTopCallFrameInFramework(); |
824 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); | 844 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); |
825 scriptDebugServer().stepIntoStatement(); | 845 scriptDebugServer().stepIntoStatement(); |
826 if (m_listener) | 846 if (m_listener) |
827 m_listener->stepInto(); | 847 m_listener->stepInto(); |
828 } | 848 } |
829 | 849 |
830 void InspectorDebuggerAgent::stepOut(ErrorString* errorString) | 850 void InspectorDebuggerAgent::stepOut(ErrorString* errorString) |
831 { | 851 { |
832 if (!assertPaused(errorString)) | 852 if (!assertPaused(errorString)) |
833 return; | 853 return; |
834 m_debuggerStepScheduled = true; | 854 m_debuggerStepScheduled = true; |
| 855 m_steppingFromFramework = isTopCallFrameInFramework(); |
835 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); | 856 m_injectedScriptManager->releaseObjectGroup(InspectorDebuggerAgent::backtrac
eObjectGroup); |
836 scriptDebugServer().stepOutOfFunction(); | 857 scriptDebugServer().stepOutOfFunction(); |
837 } | 858 } |
838 | 859 |
839 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons
t String& stringPauseState) | 860 void InspectorDebuggerAgent::setPauseOnExceptions(ErrorString* errorString, cons
t String& stringPauseState) |
840 { | 861 { |
841 ScriptDebugServer::PauseOnExceptionsState pauseState; | 862 ScriptDebugServer::PauseOnExceptionsState pauseState; |
842 if (stringPauseState == "none") | 863 if (stringPauseState == "none") |
843 pauseState = ScriptDebugServer::DontPauseOnExceptions; | 864 pauseState = ScriptDebugServer::DontPauseOnExceptions; |
844 else if (stringPauseState == "all") | 865 else if (stringPauseState == "all") |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1206 |
1186 BreakpointSource source = breakpointIterator->value.second; | 1207 BreakpointSource source = breakpointIterator->value.second; |
1187 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) | 1208 if (m_breakReason == InspectorFrontend::Debugger::Reason::Other && s
ource == DebugCommandBreakpointSource) |
1188 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; | 1209 m_breakReason = InspectorFrontend::Debugger::Reason::DebugComman
d; |
1189 } | 1210 } |
1190 } | 1211 } |
1191 | 1212 |
1192 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds, currentAsyncStackTrace()); | 1213 m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBr
eakpointIds, currentAsyncStackTrace()); |
1193 m_javaScriptPauseScheduled = false; | 1214 m_javaScriptPauseScheduled = false; |
1194 m_debuggerStepScheduled = false; | 1215 m_debuggerStepScheduled = false; |
| 1216 m_steppingFromFramework = false; |
1195 m_pausingOnNativeEvent = false; | 1217 m_pausingOnNativeEvent = false; |
1196 m_skippedStepInCount = 0; | 1218 m_skippedStepInCount = 0; |
1197 | 1219 |
1198 if (!m_continueToLocationBreakpointId.isEmpty()) { | 1220 if (!m_continueToLocationBreakpointId.isEmpty()) { |
1199 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); | 1221 scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId); |
1200 m_continueToLocationBreakpointId = ""; | 1222 m_continueToLocationBreakpointId = ""; |
1201 } | 1223 } |
1202 if (m_listener) | 1224 if (m_listener) |
1203 m_listener->didPause(); | 1225 m_listener->didPause(); |
1204 return result; | 1226 return result; |
(...skipping 12 matching lines...) Expand all Loading... |
1217 return scriptDebugServer().canBreakProgram(); | 1239 return scriptDebugServer().canBreakProgram(); |
1218 } | 1240 } |
1219 | 1241 |
1220 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E
num breakReason, PassRefPtr<JSONObject> data) | 1242 void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::E
num breakReason, PassRefPtr<JSONObject> data) |
1221 { | 1243 { |
1222 if (m_skipAllPauses) | 1244 if (m_skipAllPauses) |
1223 return; | 1245 return; |
1224 m_breakReason = breakReason; | 1246 m_breakReason = breakReason; |
1225 m_breakAuxData = data; | 1247 m_breakAuxData = data; |
1226 m_debuggerStepScheduled = false; | 1248 m_debuggerStepScheduled = false; |
| 1249 m_steppingFromFramework = false; |
1227 m_pausingOnNativeEvent = false; | 1250 m_pausingOnNativeEvent = false; |
1228 scriptDebugServer().breakProgram(); | 1251 scriptDebugServer().breakProgram(); |
1229 } | 1252 } |
1230 | 1253 |
1231 void InspectorDebuggerAgent::clear() | 1254 void InspectorDebuggerAgent::clear() |
1232 { | 1255 { |
1233 m_pausedScriptState = nullptr; | 1256 m_pausedScriptState = nullptr; |
1234 m_currentCallStack = ScriptValue(); | 1257 m_currentCallStack = ScriptValue(); |
1235 m_scripts.clear(); | 1258 m_scripts.clear(); |
1236 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1259 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1237 m_asyncCallStackTracker.clear(); | 1260 m_asyncCallStackTracker.clear(); |
1238 m_continueToLocationBreakpointId = String(); | 1261 m_continueToLocationBreakpointId = String(); |
1239 clearBreakDetails(); | 1262 clearBreakDetails(); |
1240 m_javaScriptPauseScheduled = false; | 1263 m_javaScriptPauseScheduled = false; |
1241 m_debuggerStepScheduled = false; | 1264 m_debuggerStepScheduled = false; |
| 1265 m_steppingFromFramework = false; |
1242 m_pausingOnNativeEvent = false; | 1266 m_pausingOnNativeEvent = false; |
1243 ErrorString error; | 1267 ErrorString error; |
1244 setOverlayMessage(&error, 0); | 1268 setOverlayMessage(&error, 0); |
1245 } | 1269 } |
1246 | 1270 |
1247 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) | 1271 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) |
1248 { | 1272 { |
1249 if (!m_pausedScriptState) { | 1273 if (!m_pausedScriptState) { |
1250 *errorString = "Can only perform operation while paused."; | 1274 *errorString = "Can only perform operation while paused."; |
1251 return false; | 1275 return false; |
(...skipping 23 matching lines...) Expand all Loading... |
1275 { | 1299 { |
1276 m_scripts.clear(); | 1300 m_scripts.clear(); |
1277 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1301 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1278 m_asyncCallStackTracker.clear(); | 1302 m_asyncCallStackTracker.clear(); |
1279 if (m_frontend) | 1303 if (m_frontend) |
1280 m_frontend->globalObjectCleared(); | 1304 m_frontend->globalObjectCleared(); |
1281 } | 1305 } |
1282 | 1306 |
1283 } // namespace WebCore | 1307 } // namespace WebCore |
1284 | 1308 |
OLD | NEW |