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

Side by Side Diff: src/inspector/v8-debugger.h

Issue 2816043006: [inspector] avoid cloning of async call chains (Closed)
Patch Set: lines and columns in stack string should be 1-based Created 3 years, 8 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
« no previous file with comments | « src/inspector/v8-console.cc ('k') | src/inspector/v8-debugger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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_V8DEBUGGER_H_ 5 #ifndef V8_INSPECTOR_V8DEBUGGER_H_
6 #define V8_INSPECTOR_V8DEBUGGER_H_ 6 #define V8_INSPECTOR_V8DEBUGGER_H_
7 7
8 #include <list>
8 #include <vector> 9 #include <vector>
9 10
10 #include "src/base/macros.h" 11 #include "src/base/macros.h"
11 #include "src/debug/debug-interface.h" 12 #include "src/debug/debug-interface.h"
12 #include "src/inspector/java-script-call-frame.h" 13 #include "src/inspector/java-script-call-frame.h"
13 #include "src/inspector/protocol/Debugger.h" 14 #include "src/inspector/protocol/Debugger.h"
14 #include "src/inspector/protocol/Forward.h" 15 #include "src/inspector/protocol/Forward.h"
15 #include "src/inspector/protocol/Runtime.h" 16 #include "src/inspector/protocol/Runtime.h"
16 #include "src/inspector/v8-debugger-script.h" 17 #include "src/inspector/v8-debugger-script.h"
17 #include "src/inspector/wasm-translation.h" 18 #include "src/inspector/wasm-translation.h"
18 19
19 #include "include/v8-inspector.h" 20 #include "include/v8-inspector.h"
20 21
21 namespace v8_inspector { 22 namespace v8_inspector {
22 23
24 class AsyncStackTrace;
23 struct ScriptBreakpoint; 25 struct ScriptBreakpoint;
26 class V8Debugger;
24 class V8DebuggerAgentImpl; 27 class V8DebuggerAgentImpl;
25 class V8InspectorImpl; 28 class V8InspectorImpl;
26 class V8StackTraceImpl; 29 class V8StackTraceImpl;
27 30
28 using protocol::Response; 31 using protocol::Response;
29 using ScheduleStepIntoAsyncCallback = 32 using ScheduleStepIntoAsyncCallback =
30 protocol::Debugger::Backend::ScheduleStepIntoAsyncCallback; 33 protocol::Debugger::Backend::ScheduleStepIntoAsyncCallback;
31 34
32 class V8Debugger : public v8::debug::DebugDelegate { 35 class V8Debugger : public v8::debug::DebugDelegate {
33 public: 36 public:
34 V8Debugger(v8::Isolate*, V8InspectorImpl*); 37 V8Debugger(v8::Isolate*, V8InspectorImpl*);
35 ~V8Debugger(); 38 ~V8Debugger();
36 39
37 bool enabled() const; 40 bool enabled() const;
41 v8::Isolate* isolate() const { return m_isolate; }
38 42
39 String16 setBreakpoint(const ScriptBreakpoint&, int* actualLineNumber, 43 String16 setBreakpoint(const ScriptBreakpoint&, int* actualLineNumber,
40 int* actualColumnNumber); 44 int* actualColumnNumber);
41 void removeBreakpoint(const String16& breakpointId); 45 void removeBreakpoint(const String16& breakpointId);
42 void setBreakpointsActivated(bool); 46 void setBreakpointsActivated(bool);
43 bool breakpointsActivated() const { return m_breakpointsActivated; } 47 bool breakpointsActivated() const { return m_breakpointsActivated; }
44 48
45 v8::debug::ExceptionBreakState getPauseOnExceptionsState(); 49 v8::debug::ExceptionBreakState getPauseOnExceptionsState();
46 void setPauseOnExceptionsState(v8::debug::ExceptionBreakState); 50 void setPauseOnExceptionsState(v8::debug::ExceptionBreakState);
47 bool canBreakProgram(); 51 bool canBreakProgram();
(...skipping 21 matching lines...) Expand all
69 // Passing 0 will result in reporting all scripts. 73 // Passing 0 will result in reporting all scripts.
70 void getCompiledScripts(int contextGroupId, 74 void getCompiledScripts(int contextGroupId,
71 std::vector<std::unique_ptr<V8DebuggerScript>>&); 75 std::vector<std::unique_ptr<V8DebuggerScript>>&);
72 void enable(); 76 void enable();
73 void disable(); 77 void disable();
74 78
75 bool isPaused() const { return m_runningNestedMessageLoop; } 79 bool isPaused() const { return m_runningNestedMessageLoop; }
76 v8::Local<v8::Context> pausedContext() { return m_pausedContext; } 80 v8::Local<v8::Context> pausedContext() { return m_pausedContext; }
77 81
78 int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; } 82 int maxAsyncCallChainDepth() { return m_maxAsyncCallStackDepth; }
79 V8StackTraceImpl* currentAsyncCallChain();
80 V8StackTraceImpl* currentAsyncTaskCreationStack();
81 void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int); 83 void setAsyncCallStackDepth(V8DebuggerAgentImpl*, int);
84
85 std::shared_ptr<AsyncStackTrace> currentAsyncParent();
86 std::shared_ptr<AsyncStackTrace> currentAsyncCreation();
87
82 std::unique_ptr<V8StackTraceImpl> createStackTrace(v8::Local<v8::StackTrace>); 88 std::unique_ptr<V8StackTraceImpl> createStackTrace(v8::Local<v8::StackTrace>);
83 std::unique_ptr<V8StackTraceImpl> captureStackTrace(bool fullStack); 89 std::unique_ptr<V8StackTraceImpl> captureStackTrace(bool fullStack);
84 90
85 v8::MaybeLocal<v8::Array> internalProperties(v8::Local<v8::Context>, 91 v8::MaybeLocal<v8::Array> internalProperties(v8::Local<v8::Context>,
86 v8::Local<v8::Value>); 92 v8::Local<v8::Value>);
87 93
88 void asyncTaskScheduled(const StringView& taskName, void* task, 94 void asyncTaskScheduled(const StringView& taskName, void* task,
89 bool recurring); 95 bool recurring);
90 void asyncTaskCanceled(void* task); 96 void asyncTaskCanceled(void* task);
91 void asyncTaskStarted(void* task); 97 void asyncTaskStarted(void* task);
92 void asyncTaskFinished(void* task); 98 void asyncTaskFinished(void* task);
93 void allAsyncTasksCanceled(); 99 void allAsyncTasksCanceled();
94 100
95 void muteScriptParsedEvents(); 101 void muteScriptParsedEvents();
96 void unmuteScriptParsedEvents(); 102 void unmuteScriptParsedEvents();
97 103
98 V8InspectorImpl* inspector() { return m_inspector; } 104 V8InspectorImpl* inspector() { return m_inspector; }
99 105
100 WasmTranslation* wasmTranslation() { return &m_wasmTranslation; } 106 WasmTranslation* wasmTranslation() { return &m_wasmTranslation; }
101 107
102 void setMaxAsyncTaskStacksForTest(int limit) { m_maxAsyncCallStacks = limit; } 108 void setMaxAsyncTaskStacksForTest(int limit);
103 109
104 private: 110 private:
105 void compileDebuggerScript(); 111 void compileDebuggerScript();
106 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, 112 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName,
107 int argc, 113 int argc,
108 v8::Local<v8::Value> argv[], 114 v8::Local<v8::Value> argv[],
109 bool catchExceptions); 115 bool catchExceptions);
110 v8::Local<v8::Context> debuggerContext() const; 116 v8::Local<v8::Context> debuggerContext() const;
111 void clearBreakpoints(); 117 void clearBreakpoints();
112 118
(...skipping 24 matching lines...) Expand all
137 bool recurring); 143 bool recurring);
138 void asyncTaskCanceledForStack(void* task); 144 void asyncTaskCanceledForStack(void* task);
139 void asyncTaskStartedForStack(void* task); 145 void asyncTaskStartedForStack(void* task);
140 void asyncTaskFinishedForStack(void* task); 146 void asyncTaskFinishedForStack(void* task);
141 147
142 void asyncTaskCandidateForStepping(void* task); 148 void asyncTaskCandidateForStepping(void* task);
143 void asyncTaskStartedForStepping(void* task); 149 void asyncTaskStartedForStepping(void* task);
144 void asyncTaskFinishedForStepping(void* task); 150 void asyncTaskFinishedForStepping(void* task);
145 void asyncTaskCanceledForStepping(void* task); 151 void asyncTaskCanceledForStepping(void* task);
146 152
147 void registerAsyncTaskIfNeeded(void* task);
148
149 // v8::debug::DebugEventListener implementation. 153 // v8::debug::DebugEventListener implementation.
150 void PromiseEventOccurred(v8::debug::PromiseDebugActionType type, int id, 154 void PromiseEventOccurred(v8::debug::PromiseDebugActionType type, int id,
151 int parentId, bool createdByUser) override; 155 int parentId, bool createdByUser) override;
152 void ScriptCompiled(v8::Local<v8::debug::Script> script, 156 void ScriptCompiled(v8::Local<v8::debug::Script> script,
153 bool has_compile_error) override; 157 bool has_compile_error) override;
154 void BreakProgramRequested(v8::Local<v8::Context> paused_context, 158 void BreakProgramRequested(v8::Local<v8::Context> paused_context,
155 v8::Local<v8::Object> exec_state, 159 v8::Local<v8::Object> exec_state,
156 v8::Local<v8::Value> break_points_hit) override; 160 v8::Local<v8::Value> break_points_hit) override;
157 void ExceptionThrown(v8::Local<v8::Context> paused_context, 161 void ExceptionThrown(v8::Local<v8::Context> paused_context,
158 v8::Local<v8::Object> exec_state, 162 v8::Local<v8::Object> exec_state,
(...skipping 12 matching lines...) Expand all
171 v8::Global<v8::Object> m_debuggerScript; 175 v8::Global<v8::Object> m_debuggerScript;
172 v8::Global<v8::Context> m_debuggerContext; 176 v8::Global<v8::Context> m_debuggerContext;
173 v8::Local<v8::Object> m_executionState; 177 v8::Local<v8::Object> m_executionState;
174 v8::Local<v8::Context> m_pausedContext; 178 v8::Local<v8::Context> m_pausedContext;
175 bool m_runningNestedMessageLoop; 179 bool m_runningNestedMessageLoop;
176 int m_ignoreScriptParsedEventsCounter; 180 int m_ignoreScriptParsedEventsCounter;
177 bool m_scheduledOOMBreak = false; 181 bool m_scheduledOOMBreak = false;
178 int m_targetContextGroupId = 0; 182 int m_targetContextGroupId = 0;
179 183
180 using AsyncTaskToStackTrace = 184 using AsyncTaskToStackTrace =
181 protocol::HashMap<void*, std::unique_ptr<V8StackTraceImpl>>; 185 protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>;
182 AsyncTaskToStackTrace m_asyncTaskStacks; 186 AsyncTaskToStackTrace m_asyncTaskStacks;
183 AsyncTaskToStackTrace m_asyncTaskCreationStacks; 187 AsyncTaskToStackTrace m_asyncTaskCreationStacks;
184 int m_maxAsyncCallStacks; 188 int m_maxAsyncCallStacks;
185 std::map<int, void*> m_idToTask;
186 std::unordered_map<void*, int> m_taskToId;
187 int m_lastTaskId;
188 protocol::HashSet<void*> m_recurringTasks; 189 protocol::HashSet<void*> m_recurringTasks;
189 int m_maxAsyncCallStackDepth; 190 int m_maxAsyncCallStackDepth;
191
190 std::vector<void*> m_currentTasks; 192 std::vector<void*> m_currentTasks;
191 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks; 193 std::vector<std::shared_ptr<AsyncStackTrace>> m_currentAsyncParent;
192 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentCreationStacks; 194 std::vector<std::shared_ptr<AsyncStackTrace>> m_currentAsyncCreation;
195
196 void collectOldAsyncStacksIfNeeded();
197 void removeOldAsyncTasks(AsyncTaskToStackTrace& map);
198 int m_asyncStacksCount = 0;
199 // V8Debugger owns all the async stacks, while most of the other references
200 // are weak, which allows to collect some stacks when there are too many.
201 std::list<std::shared_ptr<AsyncStackTrace>> m_allAsyncStacks;
202
193 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap; 203 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap;
194 protocol::HashMap<void*, void*> m_parentTask; 204 protocol::HashMap<void*, void*> m_parentTask;
195 protocol::HashMap<void*, void*> m_firstNextTask; 205 protocol::HashMap<void*, void*> m_firstNextTask;
196 void* m_taskWithScheduledBreak = nullptr; 206 void* m_taskWithScheduledBreak = nullptr;
197 207
198 std::unique_ptr<ScheduleStepIntoAsyncCallback> m_stepIntoAsyncCallback; 208 std::unique_ptr<ScheduleStepIntoAsyncCallback> m_stepIntoAsyncCallback;
199 bool m_breakRequested = false; 209 bool m_breakRequested = false;
200 210
201 v8::debug::ExceptionBreakState m_pauseOnExceptionsState; 211 v8::debug::ExceptionBreakState m_pauseOnExceptionsState;
202 212
203 WasmTranslation m_wasmTranslation; 213 WasmTranslation m_wasmTranslation;
204 214
205 DISALLOW_COPY_AND_ASSIGN(V8Debugger); 215 DISALLOW_COPY_AND_ASSIGN(V8Debugger);
206 }; 216 };
207 217
208 } // namespace v8_inspector 218 } // namespace v8_inspector
209 219
210 #endif // V8_INSPECTOR_V8DEBUGGER_H_ 220 #endif // V8_INSPECTOR_V8DEBUGGER_H_
OLDNEW
« no previous file with comments | « src/inspector/v8-console.cc ('k') | src/inspector/v8-debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698