OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
| 6 #define V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
| 7 |
| 8 #include "src/inspector/Allocator.h" |
| 9 #include "src/inspector/JavaScriptCallFrame.h" |
| 10 #include "src/inspector/protocol/Debugger.h" |
| 11 #include "src/inspector/protocol/Forward.h" |
| 12 |
| 13 #include <vector> |
| 14 |
| 15 namespace v8_inspector { |
| 16 |
| 17 struct ScriptBreakpoint; |
| 18 class JavaScriptCallFrame; |
| 19 class PromiseTracker; |
| 20 class V8Debugger; |
| 21 class V8DebuggerScript; |
| 22 class V8InspectorImpl; |
| 23 class V8InspectorSessionImpl; |
| 24 class V8Regex; |
| 25 class V8StackTraceImpl; |
| 26 |
| 27 using protocol::ErrorString; |
| 28 using protocol::Maybe; |
| 29 |
| 30 class V8DebuggerAgentImpl : public protocol::Debugger::Backend { |
| 31 V8_INSPECTOR_DISALLOW_COPY(V8DebuggerAgentImpl); |
| 32 |
| 33 public: |
| 34 enum SkipPauseRequest { |
| 35 RequestNoSkip, |
| 36 RequestContinue, |
| 37 RequestStepInto, |
| 38 RequestStepOut, |
| 39 RequestStepFrame |
| 40 }; |
| 41 |
| 42 enum BreakpointSource { |
| 43 UserBreakpointSource, |
| 44 DebugCommandBreakpointSource, |
| 45 MonitorCommandBreakpointSource |
| 46 }; |
| 47 |
| 48 V8DebuggerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, |
| 49 protocol::DictionaryValue* state); |
| 50 ~V8DebuggerAgentImpl() override; |
| 51 void restore(); |
| 52 |
| 53 // Part of the protocol. |
| 54 void enable(ErrorString*) override; |
| 55 void disable(ErrorString*) override; |
| 56 void setBreakpointsActive(ErrorString*, bool active) override; |
| 57 void setSkipAllPauses(ErrorString*, bool skip) override; |
| 58 void setBreakpointByUrl( |
| 59 ErrorString*, int lineNumber, const Maybe<String16>& optionalURL, |
| 60 const Maybe<String16>& optionalURLRegex, |
| 61 const Maybe<int>& optionalColumnNumber, |
| 62 const Maybe<String16>& optionalCondition, String16*, |
| 63 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) |
| 64 override; |
| 65 void setBreakpoint( |
| 66 ErrorString*, std::unique_ptr<protocol::Debugger::Location>, |
| 67 const Maybe<String16>& optionalCondition, String16*, |
| 68 std::unique_ptr<protocol::Debugger::Location>* actualLocation) override; |
| 69 void removeBreakpoint(ErrorString*, const String16& breakpointId) override; |
| 70 void continueToLocation( |
| 71 ErrorString*, std::unique_ptr<protocol::Debugger::Location>) override; |
| 72 void searchInContent( |
| 73 ErrorString*, const String16& scriptId, const String16& query, |
| 74 const Maybe<bool>& optionalCaseSensitive, |
| 75 const Maybe<bool>& optionalIsRegex, |
| 76 std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>>*) |
| 77 override; |
| 78 void setScriptSource( |
| 79 ErrorString*, const String16& inScriptId, const String16& inScriptSource, |
| 80 const Maybe<bool>& dryRun, |
| 81 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* optOutCallFrames, |
| 82 Maybe<bool>* optOutStackChanged, |
| 83 Maybe<protocol::Runtime::StackTrace>* optOutAsyncStackTrace, |
| 84 Maybe<protocol::Runtime::ExceptionDetails>* optOutCompileError) override; |
| 85 void restartFrame( |
| 86 ErrorString*, const String16& callFrameId, |
| 87 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>>* |
| 88 newCallFrames, |
| 89 Maybe<protocol::Runtime::StackTrace>* asyncStackTrace) override; |
| 90 void getScriptSource(ErrorString*, const String16& scriptId, |
| 91 String16* scriptSource) override; |
| 92 void pause(ErrorString*) override; |
| 93 void resume(ErrorString*) override; |
| 94 void stepOver(ErrorString*) override; |
| 95 void stepInto(ErrorString*) override; |
| 96 void stepOut(ErrorString*) override; |
| 97 void setPauseOnExceptions(ErrorString*, const String16& pauseState) override; |
| 98 void evaluateOnCallFrame( |
| 99 ErrorString*, const String16& callFrameId, const String16& expression, |
| 100 const Maybe<String16>& objectGroup, |
| 101 const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& silent, |
| 102 const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, |
| 103 std::unique_ptr<protocol::Runtime::RemoteObject>* result, |
| 104 Maybe<protocol::Runtime::ExceptionDetails>*) override; |
| 105 void setVariableValue( |
| 106 ErrorString*, int scopeNumber, const String16& variableName, |
| 107 std::unique_ptr<protocol::Runtime::CallArgument> newValue, |
| 108 const String16& callFrame) override; |
| 109 void setAsyncCallStackDepth(ErrorString*, int depth) override; |
| 110 void setBlackboxPatterns( |
| 111 ErrorString*, |
| 112 std::unique_ptr<protocol::Array<String16>> patterns) override; |
| 113 void setBlackboxedRanges( |
| 114 ErrorString*, const String16& scriptId, |
| 115 std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> |
| 116 positions) override; |
| 117 |
| 118 bool enabled(); |
| 119 |
| 120 void setBreakpointAt(const String16& scriptId, int lineNumber, |
| 121 int columnNumber, BreakpointSource, |
| 122 const String16& condition = String16()); |
| 123 void removeBreakpointAt(const String16& scriptId, int lineNumber, |
| 124 int columnNumber, BreakpointSource); |
| 125 void schedulePauseOnNextStatement( |
| 126 const String16& breakReason, |
| 127 std::unique_ptr<protocol::DictionaryValue> data); |
| 128 void cancelPauseOnNextStatement(); |
| 129 void breakProgram(const String16& breakReason, |
| 130 std::unique_ptr<protocol::DictionaryValue> data); |
| 131 void breakProgramOnException(const String16& breakReason, |
| 132 std::unique_ptr<protocol::DictionaryValue> data); |
| 133 |
| 134 void reset(); |
| 135 |
| 136 // Interface for V8InspectorImpl |
| 137 SkipPauseRequest didPause(v8::Local<v8::Context>, |
| 138 v8::Local<v8::Value> exception, |
| 139 const std::vector<String16>& hitBreakpoints, |
| 140 bool isPromiseRejection); |
| 141 void didContinue(); |
| 142 void didParseSource(std::unique_ptr<V8DebuggerScript>, bool success); |
| 143 void willExecuteScript(int scriptId); |
| 144 void didExecuteScript(); |
| 145 |
| 146 v8::Isolate* isolate() { return m_isolate; } |
| 147 |
| 148 private: |
| 149 bool checkEnabled(ErrorString*); |
| 150 void enable(); |
| 151 |
| 152 SkipPauseRequest shouldSkipExceptionPause(JavaScriptCallFrame* topCallFrame); |
| 153 SkipPauseRequest shouldSkipStepPause(JavaScriptCallFrame* topCallFrame); |
| 154 |
| 155 void schedulePauseOnNextStatementIfSteppingInto(); |
| 156 |
| 157 std::unique_ptr<protocol::Array<protocol::Debugger::CallFrame>> |
| 158 currentCallFrames(ErrorString*); |
| 159 std::unique_ptr<protocol::Runtime::StackTrace> currentAsyncStackTrace(); |
| 160 |
| 161 void changeJavaScriptRecursionLevel(int step); |
| 162 |
| 163 void setPauseOnExceptionsImpl(ErrorString*, int); |
| 164 |
| 165 std::unique_ptr<protocol::Debugger::Location> resolveBreakpoint( |
| 166 const String16& breakpointId, const String16& scriptId, |
| 167 const ScriptBreakpoint&, BreakpointSource); |
| 168 void removeBreakpoint(const String16& breakpointId); |
| 169 bool assertPaused(ErrorString*); |
| 170 void clearBreakDetails(); |
| 171 |
| 172 bool isCurrentCallStackEmptyOrBlackboxed(); |
| 173 bool isTopPausedCallFrameBlackboxed(); |
| 174 bool isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCallFrame*); |
| 175 |
| 176 void internalSetAsyncCallStackDepth(int); |
| 177 void increaseCachedSkipStackGeneration(); |
| 178 |
| 179 bool setBlackboxPattern(ErrorString*, const String16& pattern); |
| 180 |
| 181 using ScriptsMap = |
| 182 protocol::HashMap<String16, std::unique_ptr<V8DebuggerScript>>; |
| 183 using BreakpointIdToDebuggerBreakpointIdsMap = |
| 184 protocol::HashMap<String16, std::vector<String16>>; |
| 185 using DebugServerBreakpointToBreakpointIdAndSourceMap = |
| 186 protocol::HashMap<String16, std::pair<String16, BreakpointSource>>; |
| 187 using MuteBreakpoins = protocol::HashMap<String16, std::pair<String16, int>>; |
| 188 |
| 189 enum DebuggerStep { NoStep = 0, StepInto, StepOver, StepOut }; |
| 190 |
| 191 V8InspectorImpl* m_inspector; |
| 192 V8Debugger* m_debugger; |
| 193 V8InspectorSessionImpl* m_session; |
| 194 bool m_enabled; |
| 195 protocol::DictionaryValue* m_state; |
| 196 protocol::Debugger::Frontend m_frontend; |
| 197 v8::Isolate* m_isolate; |
| 198 v8::Global<v8::Context> m_pausedContext; |
| 199 JavaScriptCallFrames m_pausedCallFrames; |
| 200 ScriptsMap m_scripts; |
| 201 BreakpointIdToDebuggerBreakpointIdsMap m_breakpointIdToDebuggerBreakpointIds; |
| 202 DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints; |
| 203 String16 m_continueToLocationBreakpointId; |
| 204 String16 m_breakReason; |
| 205 std::unique_ptr<protocol::DictionaryValue> m_breakAuxData; |
| 206 DebuggerStep m_scheduledDebuggerStep; |
| 207 bool m_skipNextDebuggerStepOut; |
| 208 bool m_javaScriptPauseScheduled; |
| 209 bool m_steppingFromFramework; |
| 210 bool m_pausingOnNativeEvent; |
| 211 |
| 212 int m_skippedStepFrameCount; |
| 213 int m_recursionLevelForStepOut; |
| 214 int m_recursionLevelForStepFrame; |
| 215 bool m_skipAllPauses; |
| 216 |
| 217 std::unique_ptr<V8Regex> m_blackboxPattern; |
| 218 protocol::HashMap<String16, std::vector<std::pair<int, int>>> |
| 219 m_blackboxedPositions; |
| 220 }; |
| 221 |
| 222 } // namespace v8_inspector |
| 223 |
| 224 #endif // V8_INSPECTOR_V8DEBUGGERAGENTIMPL_H_ |
OLD | NEW |