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) 2010-2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010-2011 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 } | 650 } |
651 | 651 |
652 void InspectorDebuggerAgent::cancelPauseOnNextStatement() | 652 void InspectorDebuggerAgent::cancelPauseOnNextStatement() |
653 { | 653 { |
654 if (m_javaScriptPauseScheduled) | 654 if (m_javaScriptPauseScheduled) |
655 return; | 655 return; |
656 clearBreakDetails(); | 656 clearBreakDetails(); |
657 scriptDebugServer().setPauseOnNextStatement(false); | 657 scriptDebugServer().setPauseOnNextStatement(false); |
658 } | 658 } |
659 | 659 |
660 void InspectorDebuggerAgent::requestAsyncCallFramesIfNeeded() | |
661 { | |
662 if (m_asyncCallStackTracker.isEnabled()) | |
663 scriptDebugServer().requestAsyncCallFrames(); | |
yurys
2013/11/28 09:18:16
Why do we need this roundtrip into the debug serve
| |
664 } | |
665 | |
666 void InspectorDebuggerAgent::didRequestAsyncCallFrames(ScriptValue callFrames) | |
667 { | |
668 m_asyncCallStackTracker.didRequestAsyncCallFrames(callFrames); | |
669 } | |
670 | |
671 void InspectorDebuggerAgent::didInstallTimer(ExecutionContext*, int timerId, int timeout, bool singleShot) | |
672 { | |
673 m_asyncCallStackTracker.didInstallTimer(timerId, singleShot); | |
674 requestAsyncCallFramesIfNeeded(); | |
675 } | |
676 | |
677 void InspectorDebuggerAgent::didRemoveTimer(ExecutionContext*, int timerId) | |
678 { | |
679 m_asyncCallStackTracker.didRemoveTimer(timerId); | |
680 } | |
681 | |
682 bool InspectorDebuggerAgent::willFireTimer(ExecutionContext*, int timerId) | |
683 { | |
684 m_asyncCallStackTracker.willFireTimer(timerId); | |
685 return true; | |
686 } | |
687 | |
660 void InspectorDebuggerAgent::didFireTimer() | 688 void InspectorDebuggerAgent::didFireTimer() |
661 { | 689 { |
690 m_asyncCallStackTracker.didAsyncCall(); | |
662 cancelPauseOnNextStatement(); | 691 cancelPauseOnNextStatement(); |
663 } | 692 } |
664 | 693 |
694 void InspectorDebuggerAgent::didRequestAnimationFrame(Document*, int callbackId) | |
695 { | |
696 m_asyncCallStackTracker.didRequestAnimationFrame(callbackId); | |
697 requestAsyncCallFramesIfNeeded(); | |
698 } | |
699 | |
700 void InspectorDebuggerAgent::didCancelAnimationFrame(Document*, int callbackId) | |
701 { | |
702 m_asyncCallStackTracker.didCancelAnimationFrame(callbackId); | |
703 } | |
704 | |
705 bool InspectorDebuggerAgent::willFireAnimationFrame(Document*, int callbackId) | |
706 { | |
707 m_asyncCallStackTracker.willFireAnimationFrame(callbackId); | |
708 return true; | |
709 } | |
710 | |
711 void InspectorDebuggerAgent::didFireAnimationFrame() | |
712 { | |
713 m_asyncCallStackTracker.didAsyncCall(); | |
714 } | |
715 | |
665 void InspectorDebuggerAgent::didHandleEvent() | 716 void InspectorDebuggerAgent::didHandleEvent() |
666 { | 717 { |
667 cancelPauseOnNextStatement(); | 718 cancelPauseOnNextStatement(); |
668 } | 719 } |
669 | 720 |
670 void InspectorDebuggerAgent::pause(ErrorString*) | 721 void InspectorDebuggerAgent::pause(ErrorString*) |
671 { | 722 { |
672 if (m_javaScriptPauseScheduled) | 723 if (m_javaScriptPauseScheduled) |
673 return; | 724 return; |
674 clearBreakDetails(); | 725 clearBreakDetails(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
879 compiled = compileSkipCallFramePattern(patternValue); | 930 compiled = compileSkipCallFramePattern(patternValue); |
880 if (!compiled) { | 931 if (!compiled) { |
881 *errorString = "Invalid regular expression"; | 932 *errorString = "Invalid regular expression"; |
882 return; | 933 return; |
883 } | 934 } |
884 } | 935 } |
885 m_state->setString(DebuggerAgentState::skipStackPattern, patternValue); | 936 m_state->setString(DebuggerAgentState::skipStackPattern, patternValue); |
886 m_cachedSkipStackRegExp = compiled.release(); | 937 m_cachedSkipStackRegExp = compiled.release(); |
887 } | 938 } |
888 | 939 |
940 void InspectorDebuggerAgent::setAsyncCallStackDepth(ErrorString*, int depth) | |
941 { | |
942 m_asyncCallStackTracker.setAsyncCallStackDepth(depth); | |
943 } | |
944 | |
889 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) | 945 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive Text) |
890 { | 946 { |
891 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { | 947 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP auseOnExceptions) { |
892 RefPtr<JSONObject> directive = JSONObject::create(); | 948 RefPtr<JSONObject> directive = JSONObject::create(); |
893 directive->setString("directiveText", directiveText); | 949 directive->setString("directiveText", directiveText); |
894 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); | 950 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv e.release()); |
895 } | 951 } |
896 } | 952 } |
897 | 953 |
898 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() | 954 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() |
899 { | 955 { |
900 if (!m_pausedScriptState) | 956 if (!m_pausedScriptState) |
901 return Array<CallFrame>::create(); | 957 return Array<CallFrame>::create(); |
902 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m _pausedScriptState); | 958 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m _pausedScriptState); |
903 if (injectedScript.hasNoValue()) { | 959 if (injectedScript.hasNoValue()) { |
904 ASSERT_NOT_REACHED(); | 960 ASSERT_NOT_REACHED(); |
905 return Array<CallFrame>::create(); | 961 return Array<CallFrame>::create(); |
906 } | 962 } |
907 return injectedScript.wrapCallFrames(m_currentCallStack); | 963 RefPtr<Array<CallFrame> > result = injectedScript.wrapCallFrames(m_currentCa llStack); |
964 if (!result->length()) | |
965 return result.release(); | |
966 RefPtr<Array<CallFrame> > lastCallFrames = result; | |
967 AsyncCallStackTracker::AsyncCallStackIterator asyncCallStacks = m_asyncCallS tackTracker.currentAsyncCallStack(); | |
968 while (asyncCallStacks.hasNext()) { | |
969 RefPtr<CallFrame> last = CallFrame::runtimeCast(lastCallFrames->asArray( )->get(lastCallFrames->length() - 1)); | |
970 lastCallFrames = injectedScript.wrapCallFrames(asyncCallStacks.next()); | |
971 if (!lastCallFrames->length()) | |
972 break; | |
973 last->setAsyncCallFrames(lastCallFrames); | |
974 } | |
975 return result.release(); | |
908 } | 976 } |
909 | 977 |
910 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) | 978 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) |
911 { | 979 { |
912 bool deprecated; | 980 bool deprecated; |
913 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co ntentSearchUtils::JavaScriptMagicComment, &deprecated); | 981 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co ntentSearchUtils::JavaScriptMagicComment, &deprecated); |
914 if (!sourceMapURL.isEmpty()) { | 982 if (!sourceMapURL.isEmpty()) { |
915 // FIXME: add deprecated console message here. | 983 // FIXME: add deprecated console message here. |
916 return sourceMapURL; | 984 return sourceMapURL; |
917 } | 985 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 ASSERT(scriptState && !m_pausedScriptState); | 1050 ASSERT(scriptState && !m_pausedScriptState); |
983 m_pausedScriptState = scriptState; | 1051 m_pausedScriptState = scriptState; |
984 m_currentCallStack = callFrames; | 1052 m_currentCallStack = callFrames; |
985 | 1053 |
986 m_skipStepInCount = numberOfStepsBeforeStepOut; | 1054 m_skipStepInCount = numberOfStepsBeforeStepOut; |
987 | 1055 |
988 if (!exception.hasNoValue()) { | 1056 if (!exception.hasNoValue()) { |
989 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptF or(scriptState); | 1057 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptF or(scriptState); |
990 if (!injectedScript.hasNoValue()) { | 1058 if (!injectedScript.hasNoValue()) { |
991 m_breakReason = InspectorFrontend::Debugger::Reason::Exception; | 1059 m_breakReason = InspectorFrontend::Debugger::Reason::Exception; |
992 m_breakAuxData = injectedScript.wrapObject(exception, "backtrace")-> openAccessors(); | 1060 m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebug gerAgent::backtraceObjectGroup)->openAccessors(); |
993 // m_breakAuxData might be null after this. | 1061 // m_breakAuxData might be null after this. |
994 } | 1062 } |
995 } | 1063 } |
996 | 1064 |
997 RefPtr<Array<String> > hitBreakpointIds = Array<String>::create(); | 1065 RefPtr<Array<String> > hitBreakpointIds = Array<String>::create(); |
998 | 1066 |
999 for (Vector<String>::const_iterator i = hitBreakpoints.begin(); i != hitBrea kpoints.end(); ++i) { | 1067 for (Vector<String>::const_iterator i = hitBreakpoints.begin(); i != hitBrea kpoints.end(); ++i) { |
1000 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(*i); | 1068 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(*i); |
1001 if (breakpointIterator != m_serverBreakpoints.end()) { | 1069 if (breakpointIterator != m_serverBreakpoints.end()) { |
1002 const String& localId = breakpointIterator->value.first; | 1070 const String& localId = breakpointIterator->value.first; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 m_breakAuxData = data; | 1108 m_breakAuxData = data; |
1041 scriptDebugServer().breakProgram(); | 1109 scriptDebugServer().breakProgram(); |
1042 } | 1110 } |
1043 | 1111 |
1044 void InspectorDebuggerAgent::clear() | 1112 void InspectorDebuggerAgent::clear() |
1045 { | 1113 { |
1046 m_pausedScriptState = 0; | 1114 m_pausedScriptState = 0; |
1047 m_currentCallStack = ScriptValue(); | 1115 m_currentCallStack = ScriptValue(); |
1048 m_scripts.clear(); | 1116 m_scripts.clear(); |
1049 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1117 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1118 m_asyncCallStackTracker.clear(); | |
1050 m_continueToLocationBreakpointId = String(); | 1119 m_continueToLocationBreakpointId = String(); |
1051 clearBreakDetails(); | 1120 clearBreakDetails(); |
1052 m_javaScriptPauseScheduled = false; | 1121 m_javaScriptPauseScheduled = false; |
1053 ErrorString error; | 1122 ErrorString error; |
1054 setOverlayMessage(&error, 0); | 1123 setOverlayMessage(&error, 0); |
1055 } | 1124 } |
1056 | 1125 |
1057 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) | 1126 bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString) |
1058 { | 1127 { |
1059 if (!m_pausedScriptState) { | 1128 if (!m_pausedScriptState) { |
(...skipping 18 matching lines...) Expand all Loading... | |
1078 | 1147 |
1079 void InspectorDebuggerAgent::removeBreakpoint(const String& scriptId, int lineNu mber, int columnNumber, BreakpointSource source) | 1148 void InspectorDebuggerAgent::removeBreakpoint(const String& scriptId, int lineNu mber, int columnNumber, BreakpointSource source) |
1080 { | 1149 { |
1081 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so urce)); | 1150 removeBreakpoint(generateBreakpointId(scriptId, lineNumber, columnNumber, so urce)); |
1082 } | 1151 } |
1083 | 1152 |
1084 void InspectorDebuggerAgent::reset() | 1153 void InspectorDebuggerAgent::reset() |
1085 { | 1154 { |
1086 m_scripts.clear(); | 1155 m_scripts.clear(); |
1087 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1156 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1157 m_asyncCallStackTracker.clear(); | |
1088 if (m_frontend) | 1158 if (m_frontend) |
1089 m_frontend->globalObjectCleared(); | 1159 m_frontend->globalObjectCleared(); |
1090 } | 1160 } |
1091 | 1161 |
1092 } // namespace WebCore | 1162 } // namespace WebCore |
1093 | 1163 |
OLD | NEW |