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