OLD | NEW |
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 #include "src/inspector/v8-debugger.h" | 5 #include "src/inspector/v8-debugger.h" |
6 | 6 |
7 #include "src/inspector/debugger-script.h" | 7 #include "src/inspector/debugger-script.h" |
8 #include "src/inspector/protocol/Protocol.h" | 8 #include "src/inspector/protocol/Protocol.h" |
9 #include "src/inspector/script-breakpoint.h" | 9 #include "src/inspector/script-breakpoint.h" |
10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) | 50 V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector) |
51 : m_isolate(isolate), | 51 : m_isolate(isolate), |
52 m_inspector(inspector), | 52 m_inspector(inspector), |
53 m_lastContextId(0), | 53 m_lastContextId(0), |
54 m_enableCount(0), | 54 m_enableCount(0), |
55 m_breakpointsActivated(true), | 55 m_breakpointsActivated(true), |
56 m_runningNestedMessageLoop(false), | 56 m_runningNestedMessageLoop(false), |
57 m_ignoreScriptParsedEventsCounter(0), | 57 m_ignoreScriptParsedEventsCounter(0), |
58 m_maxAsyncCallStackDepth(0), | 58 m_maxAsyncCallStackDepth(0), |
59 m_pauseOnExceptionsState(v8::DebugInterface::NoBreakOnException), | 59 m_pauseOnExceptionsState(v8::debug::NoBreakOnException), |
60 m_wasmTranslation(isolate, this) {} | 60 m_wasmTranslation(isolate, this) {} |
61 | 61 |
62 V8Debugger::~V8Debugger() {} | 62 V8Debugger::~V8Debugger() {} |
63 | 63 |
64 void V8Debugger::enable() { | 64 void V8Debugger::enable() { |
65 if (m_enableCount++) return; | 65 if (m_enableCount++) return; |
66 DCHECK(!enabled()); | 66 DCHECK(!enabled()); |
67 v8::HandleScope scope(m_isolate); | 67 v8::HandleScope scope(m_isolate); |
68 v8::DebugInterface::SetDebugEventListener(m_isolate, | 68 v8::debug::DebugInterface::SetDebugEventListener( |
69 &V8Debugger::v8DebugEventCallback, | 69 m_isolate, &V8Debugger::v8DebugEventCallback, |
70 v8::External::New(m_isolate, this)); | 70 v8::External::New(m_isolate, this)); |
71 m_debuggerContext.Reset(m_isolate, | 71 m_debuggerContext.Reset( |
72 v8::DebugInterface::GetDebugContext(m_isolate)); | 72 m_isolate, v8::debug::DebugInterface::GetDebugContext(m_isolate)); |
73 v8::DebugInterface::ChangeBreakOnException( | 73 v8::debug::DebugInterface::ChangeBreakOnException( |
74 m_isolate, v8::DebugInterface::NoBreakOnException); | 74 m_isolate, v8::debug::NoBreakOnException); |
75 m_pauseOnExceptionsState = v8::DebugInterface::NoBreakOnException; | 75 m_pauseOnExceptionsState = v8::debug::NoBreakOnException; |
76 compileDebuggerScript(); | 76 compileDebuggerScript(); |
77 } | 77 } |
78 | 78 |
79 void V8Debugger::disable() { | 79 void V8Debugger::disable() { |
80 if (--m_enableCount) return; | 80 if (--m_enableCount) return; |
81 DCHECK(enabled()); | 81 DCHECK(enabled()); |
82 clearBreakpoints(); | 82 clearBreakpoints(); |
83 m_debuggerScript.Reset(); | 83 m_debuggerScript.Reset(); |
84 m_debuggerContext.Reset(); | 84 m_debuggerContext.Reset(); |
85 allAsyncTasksCanceled(); | 85 allAsyncTasksCanceled(); |
86 m_wasmTranslation.Clear(); | 86 m_wasmTranslation.Clear(); |
87 v8::DebugInterface::SetDebugEventListener(m_isolate, nullptr); | 87 v8::debug::DebugInterface::SetDebugEventListener(m_isolate, nullptr); |
88 } | 88 } |
89 | 89 |
90 bool V8Debugger::enabled() const { return !m_debuggerScript.IsEmpty(); } | 90 bool V8Debugger::enabled() const { return !m_debuggerScript.IsEmpty(); } |
91 | 91 |
92 // static | 92 // static |
93 int V8Debugger::contextId(v8::Local<v8::Context> context) { | 93 int V8Debugger::contextId(v8::Local<v8::Context> context) { |
94 v8::Local<v8::Value> data = | 94 v8::Local<v8::Value> data = |
95 context->GetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex)); | 95 context->GetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex)); |
96 if (data.IsEmpty() || !data->IsString()) return 0; | 96 if (data.IsEmpty() || !data->IsString()) return 0; |
97 String16 dataString = toProtocolString(data.As<v8::String>()); | 97 String16 dataString = toProtocolString(data.As<v8::String>()); |
(...skipping 15 matching lines...) Expand all Loading... |
113 if (dataString.isEmpty()) return 0; | 113 if (dataString.isEmpty()) return 0; |
114 size_t commaPos = dataString.find(","); | 114 size_t commaPos = dataString.find(","); |
115 if (commaPos == String16::kNotFound) return 0; | 115 if (commaPos == String16::kNotFound) return 0; |
116 return dataString.substring(0, commaPos).toInteger(); | 116 return dataString.substring(0, commaPos).toInteger(); |
117 } | 117 } |
118 | 118 |
119 void V8Debugger::getCompiledScripts( | 119 void V8Debugger::getCompiledScripts( |
120 int contextGroupId, | 120 int contextGroupId, |
121 std::vector<std::unique_ptr<V8DebuggerScript>>& result) { | 121 std::vector<std::unique_ptr<V8DebuggerScript>>& result) { |
122 v8::HandleScope scope(m_isolate); | 122 v8::HandleScope scope(m_isolate); |
123 v8::PersistentValueVector<v8::DebugInterface::Script> scripts(m_isolate); | 123 v8::PersistentValueVector<v8::debug::Script> scripts(m_isolate); |
124 v8::DebugInterface::GetLoadedScripts(m_isolate, scripts); | 124 v8::debug::DebugInterface::GetLoadedScripts(m_isolate, scripts); |
125 String16 contextPrefix = String16::fromInteger(contextGroupId) + ","; | 125 String16 contextPrefix = String16::fromInteger(contextGroupId) + ","; |
126 for (size_t i = 0; i < scripts.Size(); ++i) { | 126 for (size_t i = 0; i < scripts.Size(); ++i) { |
127 v8::Local<v8::DebugInterface::Script> script = scripts.Get(i); | 127 v8::Local<v8::debug::Script> script = scripts.Get(i); |
128 if (!script->WasCompiled()) continue; | 128 if (!script->WasCompiled()) continue; |
129 v8::Local<v8::String> v8ContextData; | 129 v8::Local<v8::String> v8ContextData; |
130 if (!script->ContextData().ToLocal(&v8ContextData)) continue; | 130 if (!script->ContextData().ToLocal(&v8ContextData)) continue; |
131 String16 contextData = toProtocolString(v8ContextData); | 131 String16 contextData = toProtocolString(v8ContextData); |
132 if (contextData.find(contextPrefix) != 0) continue; | 132 if (contextData.find(contextPrefix) != 0) continue; |
133 result.push_back(std::unique_ptr<V8DebuggerScript>( | 133 result.push_back(std::unique_ptr<V8DebuggerScript>( |
134 new V8DebuggerScript(m_isolate, script, false))); | 134 new V8DebuggerScript(m_isolate, script, false))); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
(...skipping 22 matching lines...) Expand all Loading... |
160 success = info->Set(context, toV8StringInternalized(m_isolate, "condition"), | 160 success = info->Set(context, toV8StringInternalized(m_isolate, "condition"), |
161 toV8String(m_isolate, breakpoint.condition)) | 161 toV8String(m_isolate, breakpoint.condition)) |
162 .FromMaybe(false); | 162 .FromMaybe(false); |
163 DCHECK(success); | 163 DCHECK(success); |
164 | 164 |
165 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast( | 165 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast( |
166 m_debuggerScript.Get(m_isolate) | 166 m_debuggerScript.Get(m_isolate) |
167 ->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint")) | 167 ->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint")) |
168 .ToLocalChecked()); | 168 .ToLocalChecked()); |
169 v8::Local<v8::Value> breakpointId = | 169 v8::Local<v8::Value> breakpointId = |
170 v8::DebugInterface::Call(debuggerContext(), setBreakpointFunction, info) | 170 v8::debug::DebugInterface::Call(debuggerContext(), setBreakpointFunction, |
| 171 info) |
171 .ToLocalChecked(); | 172 .ToLocalChecked(); |
172 if (!breakpointId->IsString()) return ""; | 173 if (!breakpointId->IsString()) return ""; |
173 *actualLineNumber = | 174 *actualLineNumber = |
174 info->Get(context, toV8StringInternalized(m_isolate, "lineNumber")) | 175 info->Get(context, toV8StringInternalized(m_isolate, "lineNumber")) |
175 .ToLocalChecked() | 176 .ToLocalChecked() |
176 ->Int32Value(context) | 177 ->Int32Value(context) |
177 .FromJust(); | 178 .FromJust(); |
178 *actualColumnNumber = | 179 *actualColumnNumber = |
179 info->Get(context, toV8StringInternalized(m_isolate, "columnNumber")) | 180 info->Get(context, toV8StringInternalized(m_isolate, "columnNumber")) |
180 .ToLocalChecked() | 181 .ToLocalChecked() |
(...skipping 14 matching lines...) Expand all Loading... |
195 toV8String(m_isolate, breakpointId)) | 196 toV8String(m_isolate, breakpointId)) |
196 .FromMaybe(false); | 197 .FromMaybe(false); |
197 DCHECK(success); | 198 DCHECK(success); |
198 | 199 |
199 v8::Local<v8::Function> removeBreakpointFunction = | 200 v8::Local<v8::Function> removeBreakpointFunction = |
200 v8::Local<v8::Function>::Cast( | 201 v8::Local<v8::Function>::Cast( |
201 m_debuggerScript.Get(m_isolate) | 202 m_debuggerScript.Get(m_isolate) |
202 ->Get(context, | 203 ->Get(context, |
203 toV8StringInternalized(m_isolate, "removeBreakpoint")) | 204 toV8StringInternalized(m_isolate, "removeBreakpoint")) |
204 .ToLocalChecked()); | 205 .ToLocalChecked()); |
205 v8::DebugInterface::Call(debuggerContext(), removeBreakpointFunction, info) | 206 v8::debug::DebugInterface::Call(debuggerContext(), removeBreakpointFunction, |
| 207 info) |
206 .ToLocalChecked(); | 208 .ToLocalChecked(); |
207 } | 209 } |
208 | 210 |
209 void V8Debugger::clearBreakpoints() { | 211 void V8Debugger::clearBreakpoints() { |
210 v8::HandleScope scope(m_isolate); | 212 v8::HandleScope scope(m_isolate); |
211 v8::Local<v8::Context> context = debuggerContext(); | 213 v8::Local<v8::Context> context = debuggerContext(); |
212 v8::Context::Scope contextScope(context); | 214 v8::Context::Scope contextScope(context); |
213 | 215 |
214 v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast( | 216 v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast( |
215 m_debuggerScript.Get(m_isolate) | 217 m_debuggerScript.Get(m_isolate) |
216 ->Get(context, toV8StringInternalized(m_isolate, "clearBreakpoints")) | 218 ->Get(context, toV8StringInternalized(m_isolate, "clearBreakpoints")) |
217 .ToLocalChecked()); | 219 .ToLocalChecked()); |
218 v8::DebugInterface::Call(debuggerContext(), clearBreakpoints) | 220 v8::debug::DebugInterface::Call(debuggerContext(), clearBreakpoints) |
219 .ToLocalChecked(); | 221 .ToLocalChecked(); |
220 } | 222 } |
221 | 223 |
222 void V8Debugger::setBreakpointsActivated(bool activated) { | 224 void V8Debugger::setBreakpointsActivated(bool activated) { |
223 if (!enabled()) { | 225 if (!enabled()) { |
224 UNREACHABLE(); | 226 UNREACHABLE(); |
225 return; | 227 return; |
226 } | 228 } |
227 v8::HandleScope scope(m_isolate); | 229 v8::HandleScope scope(m_isolate); |
228 v8::Local<v8::Context> context = debuggerContext(); | 230 v8::Local<v8::Context> context = debuggerContext(); |
229 v8::Context::Scope contextScope(context); | 231 v8::Context::Scope contextScope(context); |
230 | 232 |
231 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 233 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
232 bool success = false; | 234 bool success = false; |
233 success = info->Set(context, toV8StringInternalized(m_isolate, "enabled"), | 235 success = info->Set(context, toV8StringInternalized(m_isolate, "enabled"), |
234 v8::Boolean::New(m_isolate, activated)) | 236 v8::Boolean::New(m_isolate, activated)) |
235 .FromMaybe(false); | 237 .FromMaybe(false); |
236 DCHECK(success); | 238 DCHECK(success); |
237 v8::Local<v8::Function> setBreakpointsActivated = | 239 v8::Local<v8::Function> setBreakpointsActivated = |
238 v8::Local<v8::Function>::Cast( | 240 v8::Local<v8::Function>::Cast( |
239 m_debuggerScript.Get(m_isolate) | 241 m_debuggerScript.Get(m_isolate) |
240 ->Get(context, toV8StringInternalized(m_isolate, | 242 ->Get(context, toV8StringInternalized(m_isolate, |
241 "setBreakpointsActivated")) | 243 "setBreakpointsActivated")) |
242 .ToLocalChecked()); | 244 .ToLocalChecked()); |
243 v8::DebugInterface::Call(debuggerContext(), setBreakpointsActivated, info) | 245 v8::debug::DebugInterface::Call(debuggerContext(), setBreakpointsActivated, |
| 246 info) |
244 .ToLocalChecked(); | 247 .ToLocalChecked(); |
245 | 248 |
246 m_breakpointsActivated = activated; | 249 m_breakpointsActivated = activated; |
247 } | 250 } |
248 | 251 |
249 v8::DebugInterface::ExceptionBreakState | 252 v8::debug::ExceptionBreakState V8Debugger::getPauseOnExceptionsState() { |
250 V8Debugger::getPauseOnExceptionsState() { | |
251 DCHECK(enabled()); | 253 DCHECK(enabled()); |
252 return m_pauseOnExceptionsState; | 254 return m_pauseOnExceptionsState; |
253 } | 255 } |
254 | 256 |
255 void V8Debugger::setPauseOnExceptionsState( | 257 void V8Debugger::setPauseOnExceptionsState( |
256 v8::DebugInterface::ExceptionBreakState pauseOnExceptionsState) { | 258 v8::debug::ExceptionBreakState pauseOnExceptionsState) { |
257 DCHECK(enabled()); | 259 DCHECK(enabled()); |
258 if (m_pauseOnExceptionsState == pauseOnExceptionsState) return; | 260 if (m_pauseOnExceptionsState == pauseOnExceptionsState) return; |
259 v8::DebugInterface::ChangeBreakOnException(m_isolate, pauseOnExceptionsState); | 261 v8::debug::DebugInterface::ChangeBreakOnException(m_isolate, |
| 262 pauseOnExceptionsState); |
260 m_pauseOnExceptionsState = pauseOnExceptionsState; | 263 m_pauseOnExceptionsState = pauseOnExceptionsState; |
261 } | 264 } |
262 | 265 |
263 void V8Debugger::setPauseOnNextStatement(bool pause) { | 266 void V8Debugger::setPauseOnNextStatement(bool pause) { |
264 if (m_runningNestedMessageLoop) return; | 267 if (m_runningNestedMessageLoop) return; |
265 if (pause) | 268 if (pause) |
266 v8::DebugInterface::DebugBreak(m_isolate); | 269 v8::debug::DebugInterface::DebugBreak(m_isolate); |
267 else | 270 else |
268 v8::DebugInterface::CancelDebugBreak(m_isolate); | 271 v8::debug::DebugInterface::CancelDebugBreak(m_isolate); |
269 } | 272 } |
270 | 273 |
271 bool V8Debugger::canBreakProgram() { | 274 bool V8Debugger::canBreakProgram() { |
272 if (!m_breakpointsActivated) return false; | 275 if (!m_breakpointsActivated) return false; |
273 return m_isolate->InContext(); | 276 return m_isolate->InContext(); |
274 } | 277 } |
275 | 278 |
276 void V8Debugger::breakProgram() { | 279 void V8Debugger::breakProgram() { |
277 if (isPaused()) { | 280 if (isPaused()) { |
278 DCHECK(!m_runningNestedMessageLoop); | 281 DCHECK(!m_runningNestedMessageLoop); |
279 v8::Local<v8::Value> exception; | 282 v8::Local<v8::Value> exception; |
280 v8::Local<v8::Array> hitBreakpoints; | 283 v8::Local<v8::Array> hitBreakpoints; |
281 handleProgramBreak(m_pausedContext, m_executionState, exception, | 284 handleProgramBreak(m_pausedContext, m_executionState, exception, |
282 hitBreakpoints); | 285 hitBreakpoints); |
283 return; | 286 return; |
284 } | 287 } |
285 | 288 |
286 if (!canBreakProgram()) return; | 289 if (!canBreakProgram()) return; |
287 | 290 |
288 v8::HandleScope scope(m_isolate); | 291 v8::HandleScope scope(m_isolate); |
289 v8::Local<v8::Function> breakFunction; | 292 v8::Local<v8::Function> breakFunction; |
290 if (!v8::Function::New(m_isolate->GetCurrentContext(), | 293 if (!v8::Function::New(m_isolate->GetCurrentContext(), |
291 &V8Debugger::breakProgramCallback, | 294 &V8Debugger::breakProgramCallback, |
292 v8::External::New(m_isolate, this), 0, | 295 v8::External::New(m_isolate, this), 0, |
293 v8::ConstructorBehavior::kThrow) | 296 v8::ConstructorBehavior::kThrow) |
294 .ToLocal(&breakFunction)) | 297 .ToLocal(&breakFunction)) |
295 return; | 298 return; |
296 v8::DebugInterface::Call(debuggerContext(), breakFunction).ToLocalChecked(); | 299 v8::debug::DebugInterface::Call(debuggerContext(), breakFunction) |
| 300 .ToLocalChecked(); |
297 } | 301 } |
298 | 302 |
299 void V8Debugger::continueProgram() { | 303 void V8Debugger::continueProgram() { |
300 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); | 304 if (isPaused()) m_inspector->client()->quitMessageLoopOnPause(); |
301 m_pausedContext.Clear(); | 305 m_pausedContext.Clear(); |
302 m_executionState.Clear(); | 306 m_executionState.Clear(); |
303 } | 307 } |
304 | 308 |
305 void V8Debugger::stepIntoStatement() { | 309 void V8Debugger::stepIntoStatement() { |
306 DCHECK(isPaused()); | 310 DCHECK(isPaused()); |
307 DCHECK(!m_executionState.IsEmpty()); | 311 DCHECK(!m_executionState.IsEmpty()); |
308 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn); | 312 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepIn); |
309 continueProgram(); | 313 continueProgram(); |
310 } | 314 } |
311 | 315 |
312 void V8Debugger::stepOverStatement() { | 316 void V8Debugger::stepOverStatement() { |
313 DCHECK(isPaused()); | 317 DCHECK(isPaused()); |
314 DCHECK(!m_executionState.IsEmpty()); | 318 DCHECK(!m_executionState.IsEmpty()); |
315 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepNext); | 319 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepNext); |
316 continueProgram(); | 320 continueProgram(); |
317 } | 321 } |
318 | 322 |
319 void V8Debugger::stepOutOfFunction() { | 323 void V8Debugger::stepOutOfFunction() { |
320 DCHECK(isPaused()); | 324 DCHECK(isPaused()); |
321 DCHECK(!m_executionState.IsEmpty()); | 325 DCHECK(!m_executionState.IsEmpty()); |
322 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut); | 326 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepOut); |
323 continueProgram(); | 327 continueProgram(); |
324 } | 328 } |
325 | 329 |
326 void V8Debugger::clearStepping() { | 330 void V8Debugger::clearStepping() { |
327 DCHECK(enabled()); | 331 DCHECK(enabled()); |
328 v8::DebugInterface::ClearStepping(m_isolate); | 332 v8::debug::DebugInterface::ClearStepping(m_isolate); |
329 } | 333 } |
330 | 334 |
331 Response V8Debugger::setScriptSource( | 335 Response V8Debugger::setScriptSource( |
332 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, | 336 const String16& sourceID, v8::Local<v8::String> newSource, bool dryRun, |
333 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, | 337 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, |
334 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, | 338 JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged, |
335 bool* compileError) { | 339 bool* compileError) { |
336 class EnableLiveEditScope { | 340 class EnableLiveEditScope { |
337 public: | 341 public: |
338 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { | 342 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) { |
339 v8::DebugInterface::SetLiveEditEnabled(m_isolate, true); | 343 v8::debug::DebugInterface::SetLiveEditEnabled(m_isolate, true); |
340 inLiveEditScope = true; | 344 inLiveEditScope = true; |
341 } | 345 } |
342 ~EnableLiveEditScope() { | 346 ~EnableLiveEditScope() { |
343 v8::DebugInterface::SetLiveEditEnabled(m_isolate, false); | 347 v8::debug::DebugInterface::SetLiveEditEnabled(m_isolate, false); |
344 inLiveEditScope = false; | 348 inLiveEditScope = false; |
345 } | 349 } |
346 | 350 |
347 private: | 351 private: |
348 v8::Isolate* m_isolate; | 352 v8::Isolate* m_isolate; |
349 }; | 353 }; |
350 | 354 |
351 *compileError = false; | 355 *compileError = false; |
352 DCHECK(enabled()); | 356 DCHECK(enabled()); |
353 v8::HandleScope scope(m_isolate); | 357 v8::HandleScope scope(m_isolate); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { | 432 JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) { |
429 if (!m_isolate->InContext()) return JavaScriptCallFrames(); | 433 if (!m_isolate->InContext()) return JavaScriptCallFrames(); |
430 v8::Local<v8::Value> currentCallFramesV8; | 434 v8::Local<v8::Value> currentCallFramesV8; |
431 if (m_executionState.IsEmpty()) { | 435 if (m_executionState.IsEmpty()) { |
432 v8::Local<v8::Function> currentCallFramesFunction = | 436 v8::Local<v8::Function> currentCallFramesFunction = |
433 v8::Local<v8::Function>::Cast( | 437 v8::Local<v8::Function>::Cast( |
434 m_debuggerScript.Get(m_isolate) | 438 m_debuggerScript.Get(m_isolate) |
435 ->Get(debuggerContext(), | 439 ->Get(debuggerContext(), |
436 toV8StringInternalized(m_isolate, "currentCallFrames")) | 440 toV8StringInternalized(m_isolate, "currentCallFrames")) |
437 .ToLocalChecked()); | 441 .ToLocalChecked()); |
438 currentCallFramesV8 = | 442 currentCallFramesV8 = v8::debug::DebugInterface::Call( |
439 v8::DebugInterface::Call(debuggerContext(), currentCallFramesFunction, | 443 debuggerContext(), currentCallFramesFunction, |
440 v8::Integer::New(m_isolate, limit)) | 444 v8::Integer::New(m_isolate, limit)) |
441 .ToLocalChecked(); | 445 .ToLocalChecked(); |
442 } else { | 446 } else { |
443 v8::Local<v8::Value> argv[] = {m_executionState, | 447 v8::Local<v8::Value> argv[] = {m_executionState, |
444 v8::Integer::New(m_isolate, limit)}; | 448 v8::Integer::New(m_isolate, limit)}; |
445 currentCallFramesV8 = | 449 currentCallFramesV8 = |
446 callDebuggerMethod("currentCallFrames", arraysize(argv), argv) | 450 callDebuggerMethod("currentCallFrames", arraysize(argv), argv) |
447 .ToLocalChecked(); | 451 .ToLocalChecked(); |
448 } | 452 } |
449 DCHECK(!currentCallFramesV8.IsEmpty()); | 453 DCHECK(!currentCallFramesV8.IsEmpty()); |
450 if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames(); | 454 if (!currentCallFramesV8->IsArray()) return JavaScriptCallFrames(); |
451 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); | 455 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // The agent may have been removed in the nested loop. | 521 // The agent may have been removed in the nested loop. |
518 agent = | 522 agent = |
519 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); | 523 m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext)); |
520 if (agent) agent->didContinue(); | 524 if (agent) agent->didContinue(); |
521 m_runningNestedMessageLoop = false; | 525 m_runningNestedMessageLoop = false; |
522 } | 526 } |
523 m_pausedContext.Clear(); | 527 m_pausedContext.Clear(); |
524 m_executionState.Clear(); | 528 m_executionState.Clear(); |
525 | 529 |
526 if (result == V8DebuggerAgentImpl::RequestStepFrame) { | 530 if (result == V8DebuggerAgentImpl::RequestStepFrame) { |
527 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepFrame); | 531 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepFrame); |
528 } else if (result == V8DebuggerAgentImpl::RequestStepInto) { | 532 } else if (result == V8DebuggerAgentImpl::RequestStepInto) { |
529 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepIn); | 533 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepIn); |
530 } else if (result == V8DebuggerAgentImpl::RequestStepOut) { | 534 } else if (result == V8DebuggerAgentImpl::RequestStepOut) { |
531 v8::DebugInterface::PrepareStep(m_isolate, v8::DebugInterface::StepOut); | 535 v8::debug::DebugInterface::PrepareStep(m_isolate, v8::debug::StepOut); |
532 } | 536 } |
533 } | 537 } |
534 | 538 |
535 void V8Debugger::v8DebugEventCallback( | 539 void V8Debugger::v8DebugEventCallback( |
536 const v8::DebugInterface::EventDetails& eventDetails) { | 540 const v8::debug::EventDetails& eventDetails) { |
537 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); | 541 V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData()); |
538 thisPtr->handleV8DebugEvent(eventDetails); | 542 thisPtr->handleV8DebugEvent(eventDetails); |
539 } | 543 } |
540 | 544 |
541 v8::Local<v8::Value> V8Debugger::callInternalGetterFunction( | 545 v8::Local<v8::Value> V8Debugger::callInternalGetterFunction( |
542 v8::Local<v8::Object> object, const char* functionName) { | 546 v8::Local<v8::Object> object, const char* functionName) { |
543 v8::MicrotasksScope microtasks(m_isolate, | 547 v8::MicrotasksScope microtasks(m_isolate, |
544 v8::MicrotasksScope::kDoNotRunMicrotasks); | 548 v8::MicrotasksScope::kDoNotRunMicrotasks); |
545 v8::Local<v8::Value> getterValue = | 549 v8::Local<v8::Value> getterValue = |
546 object | 550 object |
547 ->Get(m_isolate->GetCurrentContext(), | 551 ->Get(m_isolate->GetCurrentContext(), |
548 toV8StringInternalized(m_isolate, functionName)) | 552 toV8StringInternalized(m_isolate, functionName)) |
549 .ToLocalChecked(); | 553 .ToLocalChecked(); |
550 DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction()); | 554 DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction()); |
551 return v8::Local<v8::Function>::Cast(getterValue) | 555 return v8::Local<v8::Function>::Cast(getterValue) |
552 ->Call(m_isolate->GetCurrentContext(), object, 0, nullptr) | 556 ->Call(m_isolate->GetCurrentContext(), object, 0, nullptr) |
553 .ToLocalChecked(); | 557 .ToLocalChecked(); |
554 } | 558 } |
555 | 559 |
556 void V8Debugger::handleV8DebugEvent( | 560 void V8Debugger::handleV8DebugEvent( |
557 const v8::DebugInterface::EventDetails& eventDetails) { | 561 const v8::debug::EventDetails& eventDetails) { |
558 if (!enabled()) return; | 562 if (!enabled()) return; |
559 v8::DebugEvent event = eventDetails.GetEvent(); | 563 v8::DebugEvent event = eventDetails.GetEvent(); |
560 if (event != v8::AsyncTaskEvent && event != v8::Break && | 564 if (event != v8::AsyncTaskEvent && event != v8::Break && |
561 event != v8::Exception && event != v8::AfterCompile && | 565 event != v8::Exception && event != v8::AfterCompile && |
562 event != v8::CompileError) | 566 event != v8::CompileError) |
563 return; | 567 return; |
564 | 568 |
565 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); | 569 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); |
566 DCHECK(!eventContext.IsEmpty()); | 570 DCHECK(!eventContext.IsEmpty()); |
567 | 571 |
(...skipping 11 matching lines...) Expand all Loading... |
579 v8::HandleScope scope(m_isolate); | 583 v8::HandleScope scope(m_isolate); |
580 if (event == v8::AfterCompile || event == v8::CompileError) { | 584 if (event == v8::AfterCompile || event == v8::CompileError) { |
581 v8::Context::Scope contextScope(debuggerContext()); | 585 v8::Context::Scope contextScope(debuggerContext()); |
582 // Determine if the script is a wasm script. | 586 // Determine if the script is a wasm script. |
583 v8::Local<v8::Value> scriptMirror = | 587 v8::Local<v8::Value> scriptMirror = |
584 callInternalGetterFunction(eventDetails.GetEventData(), "script"); | 588 callInternalGetterFunction(eventDetails.GetEventData(), "script"); |
585 DCHECK(scriptMirror->IsObject()); | 589 DCHECK(scriptMirror->IsObject()); |
586 v8::Local<v8::Value> scriptWrapper = | 590 v8::Local<v8::Value> scriptWrapper = |
587 callInternalGetterFunction(scriptMirror.As<v8::Object>(), "value"); | 591 callInternalGetterFunction(scriptMirror.As<v8::Object>(), "value"); |
588 DCHECK(scriptWrapper->IsObject()); | 592 DCHECK(scriptWrapper->IsObject()); |
589 v8::Local<v8::DebugInterface::Script> script; | 593 v8::Local<v8::debug::Script> script; |
590 if (!v8::DebugInterface::Script::Wrap(m_isolate, | 594 if (!v8::debug::Script::Wrap(m_isolate, scriptWrapper.As<v8::Object>()) |
591 scriptWrapper.As<v8::Object>()) | |
592 .ToLocal(&script)) { | 595 .ToLocal(&script)) { |
593 return; | 596 return; |
594 } | 597 } |
595 if (script->IsWasm()) { | 598 if (script->IsWasm()) { |
596 m_wasmTranslation.AddScript(scriptWrapper.As<v8::Object>()); | 599 m_wasmTranslation.AddScript(scriptWrapper.As<v8::Object>()); |
597 } else if (m_ignoreScriptParsedEventsCounter == 0) { | 600 } else if (m_ignoreScriptParsedEventsCounter == 0) { |
598 agent->didParseSource( | 601 agent->didParseSource( |
599 std::unique_ptr<V8DebuggerScript>( | 602 std::unique_ptr<V8DebuggerScript>( |
600 new V8DebuggerScript(m_isolate, script, inLiveEditScope)), | 603 new V8DebuggerScript(m_isolate, script, inLiveEditScope)), |
601 event == v8::AfterCompile); | 604 event == v8::AfterCompile); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 } | 735 } |
733 | 736 |
734 v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes( | 737 v8::MaybeLocal<v8::Value> V8Debugger::generatorScopes( |
735 v8::Local<v8::Context> context, v8::Local<v8::Value> generator) { | 738 v8::Local<v8::Context> context, v8::Local<v8::Value> generator) { |
736 return getTargetScopes(context, generator, GENERATOR); | 739 return getTargetScopes(context, generator, GENERATOR); |
737 } | 740 } |
738 | 741 |
739 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( | 742 v8::MaybeLocal<v8::Array> V8Debugger::internalProperties( |
740 v8::Local<v8::Context> context, v8::Local<v8::Value> value) { | 743 v8::Local<v8::Context> context, v8::Local<v8::Value> value) { |
741 v8::Local<v8::Array> properties; | 744 v8::Local<v8::Array> properties; |
742 if (!v8::DebugInterface::GetInternalProperties(m_isolate, value) | 745 if (!v8::debug::DebugInterface::GetInternalProperties(m_isolate, value) |
743 .ToLocal(&properties)) | 746 .ToLocal(&properties)) |
744 return v8::MaybeLocal<v8::Array>(); | 747 return v8::MaybeLocal<v8::Array>(); |
745 if (value->IsFunction()) { | 748 if (value->IsFunction()) { |
746 v8::Local<v8::Function> function = value.As<v8::Function>(); | 749 v8::Local<v8::Function> function = value.As<v8::Function>(); |
747 v8::Local<v8::Value> location = functionLocation(context, function); | 750 v8::Local<v8::Value> location = functionLocation(context, function); |
748 if (location->IsObject()) { | 751 if (location->IsObject()) { |
749 createDataProperty( | 752 createDataProperty( |
750 context, properties, properties->Length(), | 753 context, properties, properties->Length(), |
751 toV8StringInternalized(m_isolate, "[[FunctionLocation]]")); | 754 toV8StringInternalized(m_isolate, "[[FunctionLocation]]")); |
752 createDataProperty(context, properties, properties->Length(), location); | 755 createDataProperty(context, properties, properties->Length(), location); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 | 1013 |
1011 size_t stackSize = | 1014 size_t stackSize = |
1012 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 1015 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
1013 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 1016 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
1014 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 1017 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
1015 | 1018 |
1016 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1019 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
1017 } | 1020 } |
1018 | 1021 |
1019 } // namespace v8_inspector | 1022 } // namespace v8_inspector |
OLD | NEW |