Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InspectorImpl.h

Issue 2205913002: [DevTools] Split a part of V8Inspector into V8Debugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-inspector-rename
Patch Set: context scope! Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef V8InspectorImpl_h 31 #ifndef V8InspectorImpl_h
32 #define V8InspectorImpl_h 32 #define V8InspectorImpl_h
33 33
34 #include "platform/inspector_protocol/Allocator.h"
34 #include "platform/inspector_protocol/Collections.h" 35 #include "platform/inspector_protocol/Collections.h"
35 #include "platform/inspector_protocol/Maybe.h"
36 #include "platform/inspector_protocol/Platform.h" 36 #include "platform/inspector_protocol/Platform.h"
37 #include "platform/v8_inspector/JavaScriptCallFrame.h"
38 #include "platform/v8_inspector/V8DebuggerScript.h"
39 #include "platform/v8_inspector/protocol/Debugger.h"
40 #include "platform/v8_inspector/public/V8Inspector.h" 37 #include "platform/v8_inspector/public/V8Inspector.h"
41 38
42 #include <v8-debug.h> 39 #include <v8-debug.h>
43 #include <v8.h> 40 #include <v8.h>
44 #include <vector> 41 #include <vector>
45 42
46 namespace blink { 43 namespace blink {
47 44
48 using protocol::Maybe;
49
50 struct ScriptBreakpoint;
51 class InspectedContext; 45 class InspectedContext;
52 class V8ConsoleMessageStorage; 46 class V8ConsoleMessageStorage;
47 class V8Debugger;
53 class V8DebuggerAgentImpl; 48 class V8DebuggerAgentImpl;
54 class V8InspectorSessionImpl; 49 class V8InspectorSessionImpl;
55 class V8RuntimeAgentImpl; 50 class V8RuntimeAgentImpl;
56 class V8StackTraceImpl; 51 class V8StackTraceImpl;
57 52
58 class V8InspectorImpl : public V8Inspector { 53 class V8InspectorImpl : public V8Inspector {
59 PROTOCOL_DISALLOW_COPY(V8InspectorImpl); 54 PROTOCOL_DISALLOW_COPY(V8InspectorImpl);
60 public: 55 public:
61 V8InspectorImpl(v8::Isolate*, V8InspectorClient*); 56 V8InspectorImpl(v8::Isolate*, V8InspectorClient*);
62 ~V8InspectorImpl() override; 57 ~V8InspectorImpl() override;
63 58
64 static int contextId(v8::Local<v8::Context>);
65 static int getGroupId(v8::Local<v8::Context>);
66
67 bool enabled() const;
68
69 String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, in t* actualLineNumber, int* actualColumnNumber, bool interstatementLocation);
70 void removeBreakpoint(const String16& breakpointId);
71 void setBreakpointsActivated(bool);
72 bool breakpointsActivated() const { return m_breakpointsActivated; }
73
74 enum PauseOnExceptionsState {
75 DontPauseOnExceptions,
76 PauseOnAllExceptions,
77 PauseOnUncaughtExceptions
78 };
79 PauseOnExceptionsState getPauseOnExceptionsState();
80 void setPauseOnExceptionsState(PauseOnExceptionsState);
81 void setPauseOnNextStatement(bool);
82 bool canBreakProgram();
83 void breakProgram();
84 void continueProgram();
85 void stepIntoStatement();
86 void stepOverStatement();
87 void stepOutOfFunction();
88 void clearStepping();
89
90 bool setScriptSource(const String16& sourceID, v8::Local<v8::String> newSour ce, bool preview, ErrorString*, Maybe<protocol::Runtime::ExceptionDetails>*, Jav aScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged);
91 JavaScriptCallFrames currentCallFrames(int limit = 0);
92
93 // Each script inherits debug data from v8::Context where it has been compil ed.
94 // Only scripts whose debug data matches |contextGroupId| will be reported.
95 // Passing 0 will result in reporting all scripts.
96 void getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8De buggerScript>>&);
97 void debuggerAgentEnabled();
98 void debuggerAgentDisabled();
99
100 bool isPaused();
101 v8::Local<v8::Context> pausedContext() { return m_pausedContext; }
102 int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; }
103 V8StackTraceImpl* currentAsyncCallChain();
104 void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int);
105
106 v8::MaybeLocal<v8::Value> functionScopes(v8::Local<v8::Function>);
107 v8::MaybeLocal<v8::Array> internalProperties(v8::Local<v8::Context>, v8::Loc al<v8::Value>);
108
109 v8::Isolate* isolate() const { return m_isolate; } 59 v8::Isolate* isolate() const { return m_isolate; }
110 V8InspectorClient* client() { return m_client; } 60 V8InspectorClient* client() { return m_client; }
61 V8Debugger* debugger() { return m_debugger.get(); }
111 62
112 v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Loca l<v8::Script>); 63 v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Loca l<v8::Script>);
113 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8 ::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[] ); 64 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8 ::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[] );
114 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context> , v8::Local<v8::String>); 65 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context> , v8::Local<v8::String>);
115 v8::Local<v8::Script> compileScript(v8::Local<v8::Context>, v8::Local<v8::St ring>, const String16& fileName, bool markAsInternal); 66 v8::Local<v8::Script> compileScript(v8::Local<v8::Context>, v8::Local<v8::St ring>, const String16& fileName, bool markAsInternal);
116 v8::Local<v8::Context> regexContext(); 67 v8::Local<v8::Context> regexContext();
117 68
118 void enableStackCapturingIfNeeded(); 69 // V8Inspector implementation.
119 void disableStackCapturingIfNeeded();
120 V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId);
121 std::unique_ptr<V8StackTraceImpl> createStackTraceImpl(v8::Local<v8::StackTr ace>);
122 std::unique_ptr<V8StackTraceImpl> captureStackTraceImpl(bool fullStack);
123
124 // V8Debugger implementation
125 std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::Fr ontendChannel*, V8InspectorSessionClient*, const String16* state) override; 70 std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::Fr ontendChannel*, V8InspectorSessionClient*, const String16* state) override;
126 void contextCreated(const V8ContextInfo&) override; 71 void contextCreated(const V8ContextInfo&) override;
127 void contextDestroyed(v8::Local<v8::Context>) override; 72 void contextDestroyed(v8::Local<v8::Context>) override;
128 void resetContextGroup(int contextGroupId) override; 73 void resetContextGroup(int contextGroupId) override;
129 void willExecuteScript(v8::Local<v8::Context>, int scriptId) override; 74 void willExecuteScript(v8::Local<v8::Context>, int scriptId) override;
130 void didExecuteScript(v8::Local<v8::Context>) override; 75 void didExecuteScript(v8::Local<v8::Context>) override;
131 void idleStarted() override; 76 void idleStarted() override;
132 void idleFinished() override; 77 void idleFinished() override;
133 unsigned exceptionThrown(v8::Local<v8::Context>, const String16& message, v8 ::Local<v8::Value> exception, const String16& detailedMessage, const String16& u rl, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, i nt scriptId) override; 78 unsigned exceptionThrown(v8::Local<v8::Context>, const String16& message, v8 ::Local<v8::Value> exception, const String16& detailedMessage, const String16& u rl, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace>, i nt scriptId) override;
134 void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId, const St ring16& message) override; 79 void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId, const St ring16& message) override;
135 std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) ov erride; 80 std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) ov erride;
136 std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override; 81 std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override;
137 void asyncTaskScheduled(const String16& taskName, void* task, bool recurring ) override; 82 void asyncTaskScheduled(const String16& taskName, void* task, bool recurring ) override;
138 void asyncTaskCanceled(void* task) override; 83 void asyncTaskCanceled(void* task) override;
139 void asyncTaskStarted(void* task) override; 84 void asyncTaskStarted(void* task) override;
140 void asyncTaskFinished(void* task) override; 85 void asyncTaskFinished(void* task) override;
141 void allAsyncTasksCanceled() override; 86 void allAsyncTasksCanceled() override;
142 87
88 void enableStackCapturingIfNeeded();
89 void disableStackCapturingIfNeeded();
90 V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId);
143 using ContextByIdMap = protocol::HashMap<int, std::unique_ptr<InspectedConte xt>>; 91 using ContextByIdMap = protocol::HashMap<int, std::unique_ptr<InspectedConte xt>>;
144 void discardInspectedContext(int contextGroupId, int contextId); 92 void discardInspectedContext(int contextGroupId, int contextId);
145 const ContextByIdMap* contextGroup(int contextGroupId); 93 const ContextByIdMap* contextGroup(int contextGroupId);
146 void disconnect(V8InspectorSessionImpl*); 94 void disconnect(V8InspectorSessionImpl*);
147 V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId); 95 V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId);
148 InspectedContext* getContext(int groupId, int contextId) const; 96 InspectedContext* getContext(int groupId, int contextId) const;
97 V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId);
98 V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId);
149 99
150 private: 100 private:
151 void enable(); 101 v8::Isolate* m_isolate;
152 void disable(); 102 V8InspectorClient* m_client;
153 V8DebuggerAgentImpl* findEnabledDebuggerAgent(int contextGroupId); 103 std::unique_ptr<V8Debugger> m_debugger;
154 V8DebuggerAgentImpl* findEnabledDebuggerAgent(v8::Local<v8::Context>); 104 v8::Global<v8::Context> m_regexContext;
155 105 int m_capturingStackTracesCount;
156 void compileDebuggerScript(); 106 unsigned m_lastExceptionId;
157 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, int a rgc, v8::Local<v8::Value> argv[]);
158 v8::Local<v8::Context> debuggerContext() const;
159 void clearBreakpoints();
160
161 static void breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>&) ;
162 void handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8:: Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hit Breakpoints, bool isPromiseRejection = false);
163 static void v8DebugEventCallback(const v8::Debug::EventDetails&);
164 v8::Local<v8::Value> callInternalGetterFunction(v8::Local<v8::Object>, const char* functionName);
165 void handleV8DebugEvent(const v8::Debug::EventDetails&);
166
167 v8::Local<v8::String> v8InternalizedString(const char*) const;
168
169 void handleV8AsyncTaskEvent(v8::Local<v8::Context>, v8::Local<v8::Object> ex ecutionState, v8::Local<v8::Object> eventData);
170 107
171 using ContextsByGroupMap = protocol::HashMap<int, std::unique_ptr<ContextByI dMap>>; 108 using ContextsByGroupMap = protocol::HashMap<int, std::unique_ptr<ContextByI dMap>>;
109 ContextsByGroupMap m_contexts;
172 110
173 v8::Local<v8::Value> collectionEntries(v8::Local<v8::Context>, v8::Local<v8: :Object>);
174 v8::Local<v8::Value> generatorObjectLocation(v8::Local<v8::Object>);
175 v8::Local<v8::Value> functionLocation(v8::Local<v8::Context>, v8::Local<v8:: Function>);
176
177 v8::Isolate* m_isolate;
178 V8InspectorClient* m_client;
179 ContextsByGroupMap m_contexts;
180 using SessionMap = protocol::HashMap<int, V8InspectorSessionImpl*>; 111 using SessionMap = protocol::HashMap<int, V8InspectorSessionImpl*>;
181 SessionMap m_sessions; 112 SessionMap m_sessions;
113
182 using ConsoleStorageMap = protocol::HashMap<int, std::unique_ptr<V8ConsoleMe ssageStorage>>; 114 using ConsoleStorageMap = protocol::HashMap<int, std::unique_ptr<V8ConsoleMe ssageStorage>>;
183 ConsoleStorageMap m_consoleStorageMap; 115 ConsoleStorageMap m_consoleStorageMap;
184 int m_capturingStackTracesCount;
185 unsigned m_lastExceptionId;
186 int m_enabledAgentsCount;
187 bool m_breakpointsActivated;
188 v8::Global<v8::Object> m_debuggerScript;
189 v8::Global<v8::Context> m_debuggerContext;
190 v8::Local<v8::Object> m_executionState;
191 v8::Local<v8::Context> m_pausedContext;
192 bool m_runningNestedMessageLoop;
193 v8::Global<v8::Context> m_regexContext;
194
195 using AsyncTaskToStackTrace = protocol::HashMap<void*, std::unique_ptr<V8Sta ckTraceImpl>>;
196 AsyncTaskToStackTrace m_asyncTaskStacks;
197 protocol::HashSet<void*> m_recurringTasks;
198 int m_maxAsyncCallStackDepth;
199 std::vector<void*> m_currentTasks;
200 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks;
201 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap;
202 }; 116 };
203 117
204 } // namespace blink 118 } // namespace blink
205 119
206 120
207 #endif // V8InspectorImpl_h 121 #endif // V8InspectorImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698