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