| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ | 5 #ifndef V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
| 6 #define V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ | 6 #define V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
| 11 #include "src/inspector/java-script-call-frame.h" | 11 #include "src/inspector/java-script-call-frame.h" |
| 12 #include "src/inspector/protocol/Debugger.h" | 12 #include "src/inspector/protocol/Debugger.h" |
| 13 #include "src/inspector/protocol/Forward.h" | 13 #include "src/inspector/protocol/Forward.h" |
| 14 | 14 |
| 15 namespace v8_inspector { | 15 namespace v8_inspector { |
| 16 | 16 |
| 17 struct ScriptBreakpoint; | 17 struct ScriptBreakpoint; |
| 18 class JavaScriptCallFrame; | 18 class JavaScriptCallFrame; |
| 19 class PromiseTracker; | 19 class PromiseTracker; |
| 20 class V8Debugger; | 20 class V8Debugger; |
| 21 class V8DebuggerScript; | 21 class V8DebuggerScript; |
| 22 class V8InspectorImpl; | 22 class V8InspectorImpl; |
| 23 class V8InspectorSessionImpl; | 23 class V8InspectorSessionImpl; |
| 24 class V8Regex; | 24 class V8Regex; |
| 25 class V8StackTraceImpl; | 25 class V8StackTraceImpl; |
| 26 | 26 |
| 27 using protocol::ErrorString; | |
| 28 using protocol::Maybe; | 27 using protocol::Maybe; |
| 28 using protocol::Response; |
| 29 | 29 |
| 30 class V8DebuggerAgentImpl : public protocol::Debugger::Backend { | 30 class V8DebuggerAgentImpl : public protocol::Debugger::Backend { |
| 31 public: | 31 public: |
| 32 enum SkipPauseRequest { | 32 enum SkipPauseRequest { |
| 33 RequestNoSkip, | 33 RequestNoSkip, |
| 34 RequestContinue, | 34 RequestContinue, |
| 35 RequestStepInto, | 35 RequestStepInto, |
| 36 RequestStepOut, | 36 RequestStepOut, |
| 37 RequestStepFrame | 37 RequestStepFrame |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 enum BreakpointSource { | 40 enum BreakpointSource { |
| 41 UserBreakpointSource, | 41 UserBreakpointSource, |
| 42 DebugCommandBreakpointSource, | 42 DebugCommandBreakpointSource, |
| 43 MonitorCommandBreakpointSource | 43 MonitorCommandBreakpointSource |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 V8DebuggerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, | 46 V8DebuggerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, |
| 47 protocol::DictionaryValue* state); | 47 protocol::DictionaryValue* state); |
| 48 ~V8DebuggerAgentImpl() override; | 48 ~V8DebuggerAgentImpl() override; |
| 49 void restore(); | 49 void restore(); |
| 50 | 50 |
| 51 // Part of the protocol. | 51 // Part of the protocol. |
| 52 void enable(ErrorString*) override; | 52 Response enable() override; |
| 53 void disable(ErrorString*) override; | 53 Response disable() override; |
| 54 void setBreakpointsActive(ErrorString*, bool active) override; | 54 Response setBreakpointsActive(bool active) override; |
| 55 void setSkipAllPauses(ErrorString*, bool skip) override; | 55 Response setSkipAllPauses(bool skip) override; |
| 56 void setBreakpointByUrl( | 56 Response setBreakpointByUrl( |
| 57 ErrorString*, int lineNumber, const Maybe<String16>& optionalURL, | 57 int lineNumber, Maybe<String16> optionalURL, |
| 58 const Maybe<String16>& optionalURLRegex, | 58 Maybe<String16> optionalURLRegex, Maybe<int> optionalColumnNumber, |
| 59 const Maybe<int>& optionalColumnNumber, | 59 Maybe<String16> optionalCondition, String16*, |
| 60 const Maybe<String16>& optionalCondition, String16*, | |
| 61 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) | 60 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) |
| 62 override; | 61 override; |
| 63 void setBreakpoint( | 62 Response setBreakpoint( |
| 64 ErrorString*, std::unique_ptr<protocol::Debugger::Location>, | 63 std::unique_ptr<protocol::Debugger::Location>, |
| 65 const Maybe<String16>& optionalCondition, String16*, | 64 Maybe<String16> optionalCondition, String16*, |
| 66 std::unique_ptr<protocol::Debugger::Location>* actualLocation) override; | 65 std::unique_ptr<protocol::Debugger::Location>* actualLocation) override; |
| 67 void removeBreakpoint(ErrorString*, const String16& breakpointId) override; | 66 Response removeBreakpoint(const String16& breakpointId) override; |
| 68 void continueToLocation( | 67 Response continueToLocation( |
| 69 ErrorString*, std::unique_ptr<protocol::Debugger::Location>) override; | 68 std::unique_ptr<protocol::Debugger::Location>) override; |
| 70 void searchInContent( | 69 Response searchInContent( |
| 71 ErrorString*, const String16& scriptId, const String16& query, | 70 const String16& scriptId, const String16& query, |
| 72 const Maybe<bool>& optionalCaseSensitive, | 71 Maybe<bool> optionalCaseSensitive, Maybe<bool> optionalIsRegex, |
| 73 const Maybe<bool>& optionalIsRegex, | |
| 74 std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*) | 72 std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*) |
| 75 override; | 73 override; |
| 76 void setScriptSource( | 74 Response setScriptSource( |
| 77 ErrorString*, const String16& inScriptId, const String16& inScriptSource, | 75 const String16& inScriptId, const String16& inScriptSource, |
| 78 const Maybe<bool>& dryRun, | 76 Maybe<bool> dryRun, |
| 79 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames, | 77 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames, |
| 80 Maybe<bool>* optOutStackChanged, | 78 Maybe<bool>* optOutStackChanged, |
| 81 Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace, | 79 Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace, |
| 82 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override; | 80 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override; |
| 83 void restartFrame( | 81 Response restartFrame( |
| 84 ErrorString*, const String16& callFrameId, | 82 const String16& callFrameId, |
| 85 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>* | 83 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>* |
| 86 newCallFrames, | 84 newCallFrames, |
| 87 Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) override; | 85 Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) override; |
| 88 void getScriptSource(ErrorString*, const String16& scriptId, | 86 Response getScriptSource(const String16& scriptId, |
| 89 String16* scriptSource) override; | 87 String16* scriptSource) override; |
| 90 void pause(ErrorString*) override; | 88 Response pause() override; |
| 91 void resume(ErrorString*) override; | 89 Response resume() override; |
| 92 void stepOver(ErrorString*) override; | 90 Response stepOver() override; |
| 93 void stepInto(ErrorString*) override; | 91 Response stepInto() override; |
| 94 void stepOut(ErrorString*) override; | 92 Response stepOut() override; |
| 95 void setPauseOnExceptions(ErrorString*, const String16& pauseState) override; | 93 Response setPauseOnExceptions(const String16& pauseState) override; |
| 96 void evaluateOnCallFrame( | 94 Response evaluateOnCallFrame( |
| 97 ErrorString*, const String16& callFrameId, const String16& expression, | 95 const String16& callFrameId, const String16& expression, |
| 98 const Maybe<String16>& objectGroup, | 96 Maybe<String16> objectGroup, Maybe<bool> includeCommandLineAPI, |
| 99 const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& silent, | 97 Maybe<bool> silent, Maybe<bool> returnByValue, |
| 100 const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, | 98 Maybe<bool> generatePreview, |
| 101 std::unique_ptr<protocol::Runtime::RemoteObject>* result, | 99 std::unique_ptr<protocol::Runtime::RemoteObject>* result, |
| 102 Maybe<protocol::Runtime::ExceptionDetails>*) override; | 100 Maybe<protocol::Runtime::ExceptionDetails>*) override; |
| 103 void setVariableValue( | 101 Response setVariableValue( |
| 104 ErrorString*, int scopeNumber, const String16& variableName, | 102 int scopeNumber, const String16& variableName, |
| 105 std::unique_ptr<protocol::Runtime::CallArgument> newValue, | 103 std::unique_ptr<protocol::Runtime::CallArgument> newValue, |
| 106 const String16& callFrame) override; | 104 const String16& callFrame) override; |
| 107 void setAsyncCallStackDepth(ErrorString*, int depth) override; | 105 Response setAsyncCallStackDepth(int depth) override; |
| 108 void setBlackboxPatterns( | 106 Response setBlackboxPatterns( |
| 109 ErrorString*, | |
| 110 std::unique_ptr<protocol::Array<String16>> patterns) override; | 107 std::unique_ptr<protocol::Array<String16>> patterns) override; |
| 111 void setBlackboxedRanges( | 108 Response setBlackboxedRanges( |
| 112 ErrorString*, const String16& scriptId, | 109 const String16& scriptId, |
| 113 std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> | 110 std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> |
| 114 positions) override; | 111 positions) override; |
| 115 | 112 |
| 116 bool enabled(); | 113 bool enabled(); |
| 117 | 114 |
| 118 void setBreakpointAt(const String16& scriptId, int lineNumber, | 115 void setBreakpointAt(const String16& scriptId, int lineNumber, |
| 119 int columnNumber, BreakpointSource, | 116 int columnNumber, BreakpointSource, |
| 120 const String16& condition = String16()); | 117 const String16& condition = String16()); |
| 121 void removeBreakpointAt(const String16& scriptId, int lineNumber, | 118 void removeBreakpointAt(const String16& scriptId, int lineNumber, |
| 122 int columnNumber, BreakpointSource); | 119 int columnNumber, BreakpointSource); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 137 const std::vector<String16>& hitBreakpoints, | 134 const std::vector<String16>& hitBreakpoints, |
| 138 bool isPromiseRejection); | 135 bool isPromiseRejection); |
| 139 void didContinue(); | 136 void didContinue(); |
| 140 void didParseSource(std::unique_ptr<V8DebuggerScript>, bool success); | 137 void didParseSource(std::unique_ptr<V8DebuggerScript>, bool success); |
| 141 void willExecuteScript(int scriptId); | 138 void willExecuteScript(int scriptId); |
| 142 void didExecuteScript(); | 139 void didExecuteScript(); |
| 143 | 140 |
| 144 v8::Isolate* isolate() { return m_isolate; } | 141 v8::Isolate* isolate() { return m_isolate; } |
| 145 | 142 |
| 146 private: | 143 private: |
| 147 bool checkEnabled(ErrorString*); | 144 void enableImpl(); |
| 148 void enable(); | |
| 149 | 145 |
| 150 SkipPauseRequest shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame); | 146 SkipPauseRequest shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame); |
| 151 SkipPauseRequest shouldSkipStepPause(JavaScriptCallFrame* topCallFrame); | 147 SkipPauseRequest shouldSkipStepPause(JavaScriptCallFrame* topCallFrame); |
| 152 | 148 |
| 153 void schedulePauseOnNextStatementIfSteppingInto(); | 149 void schedulePauseOnNextStatementIfSteppingInto(); |
| 154 | 150 |
| 155 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> | 151 Response currentCallFrames( |
| 156 currentCallFrames(ErrorString*); | 152 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>*); |
| 157 std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace(); | 153 std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace(); |
| 158 | 154 |
| 159 void changeJavaScriptRecursionLevel(int step); | 155 void changeJavaScriptRecursionLevel(int step); |
| 160 | 156 |
| 161 void setPauseOnExceptionsImpl(int); | 157 void setPauseOnExceptionsImpl(int); |
| 162 | 158 |
| 163 std::unique_ptr<protocol::Debugger::Location> resolveBreakpoint( | 159 std::unique_ptr<protocol::Debugger::Location> resolveBreakpoint( |
| 164 const String16& breakpointId, const String16& scriptId, | 160 const String16& breakpointId, const String16& scriptId, |
| 165 const ScriptBreakpoint&, BreakpointSource); | 161 const ScriptBreakpoint&, BreakpointSource); |
| 166 void removeBreakpoint(const String16& breakpointId); | 162 void removeBreakpointImpl(const String16& breakpointId); |
| 167 bool assertPaused(ErrorString*); | |
| 168 void clearBreakDetails(); | 163 void clearBreakDetails(); |
| 169 | 164 |
| 170 bool isCurrentCallStackEmptyOrBlackboxed(); | 165 bool isCurrentCallStackEmptyOrBlackboxed(); |
| 171 bool isTopPausedCallFrameBlackboxed(); | 166 bool isTopPausedCallFrameBlackboxed(); |
| 172 bool isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCallFrame*); | 167 bool isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCallFrame*); |
| 173 | 168 |
| 174 void internalSetAsyncCallStackDepth(int); | 169 void internalSetAsyncCallStackDepth(int); |
| 175 void increaseCachedSkipStackGeneration(); | 170 void increaseCachedSkipStackGeneration(); |
| 176 | 171 |
| 177 bool setBlackboxPattern(ErrorString*, const String16& pattern); | 172 Response setBlackboxPattern(const String16& pattern); |
| 178 | 173 |
| 179 using ScriptsMap = | 174 using ScriptsMap = |
| 180 protocol::HashMap<String16, std::unique_ptr<V8DebuggerScript>>; | 175 protocol::HashMap<String16, std::unique_ptr<V8DebuggerScript>>; |
| 181 using BreakpointIdToDebuggerBreakpointIdsMap = | 176 using BreakpointIdToDebuggerBreakpointIdsMap = |
| 182 protocol::HashMap<String16, std::vector<String16>>; | 177 protocol::HashMap<String16, std::vector<String16>>; |
| 183 using DebugServerBreakpointToBreakpointIdAndSourceMap = | 178 using DebugServerBreakpointToBreakpointIdAndSourceMap = |
| 184 protocol::HashMap<String16, std::pair<String16, BreakpointSource>>; | 179 protocol::HashMap<String16, std::pair<String16, BreakpointSource>>; |
| 185 using MuteBreakpoins = protocol::HashMap<String16, std::pair<String16, int>>; | 180 using MuteBreakpoins = protocol::HashMap<String16, std::pair<String16, int>>; |
| 186 | 181 |
| 187 enum DebuggerStep { NoStep = 0, StepInto, StepOver, StepOut }; | 182 enum DebuggerStep { NoStep = 0, StepInto, StepOver, StepOut }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 215 std::unique_ptr<V8Regex> m_blackboxPattern; | 210 std::unique_ptr<V8Regex> m_blackboxPattern; |
| 216 protocol::HashMap<String16, std::vector<std::pair<int, int>>> | 211 protocol::HashMap<String16, std::vector<std::pair<int, int>>> |
| 217 m_blackboxedPositions; | 212 m_blackboxedPositions; |
| 218 | 213 |
| 219 DISALLOW_COPY_AND_ASSIGN(V8DebuggerAgentImpl); | 214 DISALLOW_COPY_AND_ASSIGN(V8DebuggerAgentImpl); |
| 220 }; | 215 }; |
| 221 | 216 |
| 222 } // namespace v8_inspector | 217 } // namespace v8_inspector |
| 223 | 218 |
| 224 #endif // V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ | 219 #endif // V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
| OLD | NEW |