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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 2001893002: DevTools: expose raw pointers in protocol collections, s/ASSERT/DCHECK/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 } 59 }
60 60
61 static bool inLiveEditScope = false; 61 static bool inLiveEditScope = false;
62 62
63 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio nName, int argc, v8::Local<v8::Value> argv[]) 63 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio nName, int argc, v8::Local<v8::Value> argv[])
64 { 64 {
65 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); 65 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks);
66 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); 66 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
67 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(v8InternalizedString(functionName))); 67 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(v8InternalizedString(functionName)));
68 ASSERT(m_isolate->InContext()); 68 DCHECK(m_isolate->InContext());
69 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv); 69 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv);
70 } 70 }
71 71
72 PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient * client) 72 PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient * client)
73 { 73 {
74 return adoptPtr(new V8DebuggerImpl(isolate, client)); 74 return adoptPtr(new V8DebuggerImpl(isolate, client));
75 } 75 }
76 76
77 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) 77 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client)
78 : m_isolate(isolate) 78 : m_isolate(isolate)
79 , m_client(client) 79 , m_client(client)
80 , m_enabledAgentsCount(0) 80 , m_enabledAgentsCount(0)
81 , m_breakpointsActivated(true) 81 , m_breakpointsActivated(true)
82 , m_runningNestedMessageLoop(false) 82 , m_runningNestedMessageLoop(false)
83 { 83 {
84 } 84 }
85 85
86 V8DebuggerImpl::~V8DebuggerImpl() 86 V8DebuggerImpl::~V8DebuggerImpl()
87 { 87 {
88 } 88 }
89 89
90 void V8DebuggerImpl::enable() 90 void V8DebuggerImpl::enable()
91 { 91 {
92 ASSERT(!enabled()); 92 DCHECK(!enabled());
93 v8::HandleScope scope(m_isolate); 93 v8::HandleScope scope(m_isolate);
94 v8::Debug::SetDebugEventListener(m_isolate, &V8DebuggerImpl::v8DebugEventCal lback, v8::External::New(m_isolate, this)); 94 v8::Debug::SetDebugEventListener(m_isolate, &V8DebuggerImpl::v8DebugEventCal lback, v8::External::New(m_isolate, this));
95 m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext(m_isolate)); 95 m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext(m_isolate));
96 compileDebuggerScript(); 96 compileDebuggerScript();
97 } 97 }
98 98
99 void V8DebuggerImpl::disable() 99 void V8DebuggerImpl::disable()
100 { 100 {
101 ASSERT(enabled()); 101 DCHECK(enabled());
102 clearBreakpoints(); 102 clearBreakpoints();
103 m_debuggerScript.Reset(); 103 m_debuggerScript.Reset();
104 m_debuggerContext.Reset(); 104 m_debuggerContext.Reset();
105 v8::Debug::SetDebugEventListener(m_isolate, nullptr); 105 v8::Debug::SetDebugEventListener(m_isolate, nullptr);
106 } 106 }
107 107
108 bool V8DebuggerImpl::enabled() const 108 bool V8DebuggerImpl::enabled() const
109 { 109 {
110 return !m_debuggerScript.IsEmpty(); 110 return !m_debuggerScript.IsEmpty();
111 } 111 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local<v8::Cont ext> context) 166 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local<v8::Cont ext> context)
167 { 167 {
168 return findEnabledDebuggerAgent(getGroupId(context)); 168 return findEnabledDebuggerAgent(getGroupId(context));
169 } 169 }
170 170
171 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D ebuggerParsedScript>& result) 171 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D ebuggerParsedScript>& result)
172 { 172 {
173 v8::HandleScope scope(m_isolate); 173 v8::HandleScope scope(m_isolate);
174 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); 174 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks);
175 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); 175 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
176 ASSERT(!debuggerScript->IsUndefined()); 176 DCHECK(!debuggerScript->IsUndefined());
177 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(v8InternalizedString("getScripts"))); 177 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(v8InternalizedString("getScripts")));
178 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) }; 178 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) };
179 v8::Local<v8::Value> value; 179 v8::Local<v8::Value> value;
180 if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, WTF_ARRAY_L ENGTH(argv), argv).ToLocal(&value)) 180 if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, WTF_ARRAY_L ENGTH(argv), argv).ToLocal(&value))
181 return; 181 return;
182 ASSERT(value->IsArray()); 182 DCHECK(value->IsArray());
183 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); 183 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value);
184 result.resize(scriptsArray->Length()); 184 result.resize(scriptsArray->Length());
185 for (unsigned i = 0; i < scriptsArray->Length(); ++i) 185 for (unsigned i = 0; i < scriptsArray->Length(); ++i)
186 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray- >Get(v8::Integer::New(m_isolate, i))), true); 186 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray- >Get(v8::Integer::New(m_isolate, i))), true);
187 } 187 }
188 188
189 String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBre akpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation) 189 String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBre akpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation)
190 { 190 {
191 v8::HandleScope scope(m_isolate); 191 v8::HandleScope scope(m_isolate);
192 v8::Context::Scope contextScope(debuggerContext()); 192 v8::Context::Scope contextScope(debuggerContext());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 v8::HandleScope scope(m_isolate); 224 v8::HandleScope scope(m_isolate);
225 v8::Context::Scope contextScope(debuggerContext()); 225 v8::Context::Scope contextScope(debuggerContext());
226 226
227 v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_d ebuggerScript.Get(m_isolate)->Get(v8InternalizedString("clearBreakpoints"))); 227 v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_d ebuggerScript.Get(m_isolate)->Get(v8InternalizedString("clearBreakpoints")));
228 v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked(); 228 v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked();
229 } 229 }
230 230
231 void V8DebuggerImpl::setBreakpointsActivated(bool activated) 231 void V8DebuggerImpl::setBreakpointsActivated(bool activated)
232 { 232 {
233 if (!enabled()) { 233 if (!enabled()) {
234 ASSERT_NOT_REACHED(); 234 NOTREACHED();
235 return; 235 return;
236 } 236 }
237 v8::HandleScope scope(m_isolate); 237 v8::HandleScope scope(m_isolate);
238 v8::Context::Scope contextScope(debuggerContext()); 238 v8::Context::Scope contextScope(debuggerContext());
239 239
240 v8::Local<v8::Object> info = v8::Object::New(m_isolate); 240 v8::Local<v8::Object> info = v8::Object::New(m_isolate);
241 info->Set(v8InternalizedString("enabled"), v8::Boolean::New(m_isolate, activ ated)); 241 info->Set(v8InternalizedString("enabled"), v8::Boolean::New(m_isolate, activ ated));
242 v8::Local<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::C ast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpointsAct ivated"))); 242 v8::Local<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::C ast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpointsAct ivated")));
243 v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info).ToLocalChe cked(); 243 v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info).ToLocalChe cked();
244 244
245 m_breakpointsActivated = activated; 245 m_breakpointsActivated = activated;
246 } 246 }
247 247
248 V8DebuggerImpl::PauseOnExceptionsState V8DebuggerImpl::getPauseOnExceptionsState () 248 V8DebuggerImpl::PauseOnExceptionsState V8DebuggerImpl::getPauseOnExceptionsState ()
249 { 249 {
250 ASSERT(enabled()); 250 DCHECK(enabled());
251 v8::HandleScope scope(m_isolate); 251 v8::HandleScope scope(m_isolate);
252 v8::Context::Scope contextScope(debuggerContext()); 252 v8::Context::Scope contextScope(debuggerContext());
253 253
254 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; 254 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) };
255 v8::Local<v8::Value> result = callDebuggerMethod("pauseOnExceptionsState", 0 , argv).ToLocalChecked(); 255 v8::Local<v8::Value> result = callDebuggerMethod("pauseOnExceptionsState", 0 , argv).ToLocalChecked();
256 return static_cast<V8DebuggerImpl::PauseOnExceptionsState>(result->Int32Valu e()); 256 return static_cast<V8DebuggerImpl::PauseOnExceptionsState>(result->Int32Valu e());
257 } 257 }
258 258
259 void V8DebuggerImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExc eptionsState) 259 void V8DebuggerImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExc eptionsState)
260 { 260 {
261 ASSERT(enabled()); 261 DCHECK(enabled());
262 v8::HandleScope scope(m_isolate); 262 v8::HandleScope scope(m_isolate);
263 v8::Context::Scope contextScope(debuggerContext()); 263 v8::Context::Scope contextScope(debuggerContext());
264 264
265 v8::Local<v8::Value> argv[] = { v8::Int32::New(m_isolate, pauseOnExceptionsS tate) }; 265 v8::Local<v8::Value> argv[] = { v8::Int32::New(m_isolate, pauseOnExceptionsS tate) };
266 callDebuggerMethod("setPauseOnExceptionsState", 1, argv); 266 callDebuggerMethod("setPauseOnExceptionsState", 1, argv);
267 } 267 }
268 268
269 void V8DebuggerImpl::setPauseOnNextStatement(bool pause) 269 void V8DebuggerImpl::setPauseOnNextStatement(bool pause)
270 { 270 {
271 if (m_runningNestedMessageLoop) 271 if (m_runningNestedMessageLoop)
272 return; 272 return;
273 if (pause) 273 if (pause)
274 v8::Debug::DebugBreak(m_isolate); 274 v8::Debug::DebugBreak(m_isolate);
275 else 275 else
276 v8::Debug::CancelDebugBreak(m_isolate); 276 v8::Debug::CancelDebugBreak(m_isolate);
277 } 277 }
278 278
279 bool V8DebuggerImpl::canBreakProgram() 279 bool V8DebuggerImpl::canBreakProgram()
280 { 280 {
281 if (!m_breakpointsActivated) 281 if (!m_breakpointsActivated)
282 return false; 282 return false;
283 return m_isolate->InContext(); 283 return m_isolate->InContext();
284 } 284 }
285 285
286 void V8DebuggerImpl::breakProgram() 286 void V8DebuggerImpl::breakProgram()
287 { 287 {
288 if (isPaused()) { 288 if (isPaused()) {
289 ASSERT(!m_runningNestedMessageLoop); 289 DCHECK(!m_runningNestedMessageLoop);
290 v8::Local<v8::Value> exception; 290 v8::Local<v8::Value> exception;
291 v8::Local<v8::Array> hitBreakpoints; 291 v8::Local<v8::Array> hitBreakpoints;
292 handleProgramBreak(m_pausedContext, m_executionState, exception, hitBrea kpoints); 292 handleProgramBreak(m_pausedContext, m_executionState, exception, hitBrea kpoints);
293 return; 293 return;
294 } 294 }
295 295
296 if (!canBreakProgram()) 296 if (!canBreakProgram())
297 return; 297 return;
298 298
299 v8::HandleScope scope(m_isolate); 299 v8::HandleScope scope(m_isolate);
300 v8::Local<v8::Function> breakFunction; 300 v8::Local<v8::Function> breakFunction;
301 if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::brea kProgramCallback, v8::External::New(m_isolate, this)).ToLocal(&breakFunction)) 301 if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8DebuggerImpl::brea kProgramCallback, v8::External::New(m_isolate, this)).ToLocal(&breakFunction))
302 return; 302 return;
303 v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked(); 303 v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked();
304 } 304 }
305 305
306 void V8DebuggerImpl::continueProgram() 306 void V8DebuggerImpl::continueProgram()
307 { 307 {
308 if (isPaused()) 308 if (isPaused())
309 m_client->quitMessageLoopOnPause(); 309 m_client->quitMessageLoopOnPause();
310 m_pausedContext.Clear(); 310 m_pausedContext.Clear();
311 m_executionState.Clear(); 311 m_executionState.Clear();
312 } 312 }
313 313
314 void V8DebuggerImpl::stepIntoStatement() 314 void V8DebuggerImpl::stepIntoStatement()
315 { 315 {
316 ASSERT(isPaused()); 316 DCHECK(isPaused());
317 ASSERT(!m_executionState.IsEmpty()); 317 DCHECK(!m_executionState.IsEmpty());
318 v8::HandleScope handleScope(m_isolate); 318 v8::HandleScope handleScope(m_isolate);
319 v8::Local<v8::Value> argv[] = { m_executionState }; 319 v8::Local<v8::Value> argv[] = { m_executionState };
320 callDebuggerMethod(stepIntoV8MethodName, 1, argv); 320 callDebuggerMethod(stepIntoV8MethodName, 1, argv);
321 continueProgram(); 321 continueProgram();
322 } 322 }
323 323
324 void V8DebuggerImpl::stepOverStatement() 324 void V8DebuggerImpl::stepOverStatement()
325 { 325 {
326 ASSERT(isPaused()); 326 DCHECK(isPaused());
327 ASSERT(!m_executionState.IsEmpty()); 327 DCHECK(!m_executionState.IsEmpty());
328 v8::HandleScope handleScope(m_isolate); 328 v8::HandleScope handleScope(m_isolate);
329 v8::Local<v8::Value> argv[] = { m_executionState }; 329 v8::Local<v8::Value> argv[] = { m_executionState };
330 callDebuggerMethod("stepOverStatement", 1, argv); 330 callDebuggerMethod("stepOverStatement", 1, argv);
331 continueProgram(); 331 continueProgram();
332 } 332 }
333 333
334 void V8DebuggerImpl::stepOutOfFunction() 334 void V8DebuggerImpl::stepOutOfFunction()
335 { 335 {
336 ASSERT(isPaused()); 336 DCHECK(isPaused());
337 ASSERT(!m_executionState.IsEmpty()); 337 DCHECK(!m_executionState.IsEmpty());
338 v8::HandleScope handleScope(m_isolate); 338 v8::HandleScope handleScope(m_isolate);
339 v8::Local<v8::Value> argv[] = { m_executionState }; 339 v8::Local<v8::Value> argv[] = { m_executionState };
340 callDebuggerMethod(stepOutV8MethodName, 1, argv); 340 callDebuggerMethod(stepOutV8MethodName, 1, argv);
341 continueProgram(); 341 continueProgram();
342 } 342 }
343 343
344 void V8DebuggerImpl::clearStepping() 344 void V8DebuggerImpl::clearStepping()
345 { 345 {
346 ASSERT(enabled()); 346 DCHECK(enabled());
347 v8::HandleScope scope(m_isolate); 347 v8::HandleScope scope(m_isolate);
348 v8::Context::Scope contextScope(debuggerContext()); 348 v8::Context::Scope contextScope(debuggerContext());
349 349
350 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; 350 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) };
351 callDebuggerMethod("clearStepping", 0, argv); 351 callDebuggerMethod("clearStepping", 0, argv);
352 } 352 }
353 353
354 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript SourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stack Changed) 354 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript SourceError>* errorData, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stack Changed)
355 { 355 {
356 class EnableLiveEditScope { 356 class EnableLiveEditScope {
357 public: 357 public:
358 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) 358 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate)
359 { 359 {
360 v8::Debug::SetLiveEditEnabled(m_isolate, true); 360 v8::Debug::SetLiveEditEnabled(m_isolate, true);
361 inLiveEditScope = true; 361 inLiveEditScope = true;
362 } 362 }
363 ~EnableLiveEditScope() 363 ~EnableLiveEditScope()
364 { 364 {
365 v8::Debug::SetLiveEditEnabled(m_isolate, false); 365 v8::Debug::SetLiveEditEnabled(m_isolate, false);
366 inLiveEditScope = false; 366 inLiveEditScope = false;
367 } 367 }
368 private: 368 private:
369 v8::Isolate* m_isolate; 369 v8::Isolate* m_isolate;
370 }; 370 };
371 371
372 ASSERT(enabled()); 372 DCHECK(enabled());
373 v8::HandleScope scope(m_isolate); 373 v8::HandleScope scope(m_isolate);
374 374
375 OwnPtr<v8::Context::Scope> contextScope; 375 OwnPtr<v8::Context::Scope> contextScope;
376 if (!isPaused()) 376 if (!isPaused())
377 contextScope = adoptPtr(new v8::Context::Scope(debuggerContext())); 377 contextScope = adoptPtr(new v8::Context::Scope(debuggerContext()));
378 378
379 v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), toV8String( m_isolate, newContent), v8Boolean(preview, m_isolate) }; 379 v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), toV8String( m_isolate, newContent), v8Boolean(preview, m_isolate) };
380 380
381 v8::Local<v8::Value> v8result; 381 v8::Local<v8::Value> v8result;
382 { 382 {
383 EnableLiveEditScope enableLiveEditScope(m_isolate); 383 EnableLiveEditScope enableLiveEditScope(m_isolate);
384 v8::TryCatch tryCatch(m_isolate); 384 v8::TryCatch tryCatch(m_isolate);
385 tryCatch.SetVerbose(false); 385 tryCatch.SetVerbose(false);
386 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri ptSource", 3, argv); 386 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri ptSource", 3, argv);
387 if (tryCatch.HasCaught()) { 387 if (tryCatch.HasCaught()) {
388 v8::Local<v8::Message> message = tryCatch.Message(); 388 v8::Local<v8::Message> message = tryCatch.Message();
389 if (!message.IsEmpty()) 389 if (!message.IsEmpty())
390 *error = toProtocolStringWithTypeCheck(message->Get()); 390 *error = toProtocolStringWithTypeCheck(message->Get());
391 else 391 else
392 *error = "Unknown error."; 392 *error = "Unknown error.";
393 return false; 393 return false;
394 } 394 }
395 v8result = maybeResult.ToLocalChecked(); 395 v8result = maybeResult.ToLocalChecked();
396 } 396 }
397 ASSERT(!v8result.IsEmpty()); 397 DCHECK(!v8result.IsEmpty());
398 v8::Local<v8::Object> resultTuple = v8result->ToObject(m_isolate); 398 v8::Local<v8::Object> resultTuple = v8result->ToObject(m_isolate);
399 int code = static_cast<int>(resultTuple->Get(0)->ToInteger(m_isolate)->Value ()); 399 int code = static_cast<int>(resultTuple->Get(0)->ToInteger(m_isolate)->Value ());
400 switch (code) { 400 switch (code) {
401 case 0: 401 case 0:
402 { 402 {
403 *stackChanged = resultTuple->Get(1)->BooleanValue(); 403 *stackChanged = resultTuple->Get(1)->BooleanValue();
404 // Call stack may have changed after if the edited function was on t he stack. 404 // Call stack may have changed after if the edited function was on t he stack.
405 if (!preview && isPaused()) 405 if (!preview && isPaused())
406 newCallFrames->swap(currentCallFrames()); 406 newCallFrames->swap(currentCallFrames());
407 return true; 407 return true;
(...skipping 17 matching lines...) Expand all
425 if (!m_isolate->InContext()) 425 if (!m_isolate->InContext())
426 return JavaScriptCallFrames(); 426 return JavaScriptCallFrames();
427 v8::Local<v8::Value> currentCallFramesV8; 427 v8::Local<v8::Value> currentCallFramesV8;
428 if (m_executionState.IsEmpty()) { 428 if (m_executionState.IsEmpty()) {
429 v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Functi on>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCall Frames"))); 429 v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Functi on>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCall Frames")));
430 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked(); 430 currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFram esFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked();
431 } else { 431 } else {
432 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso late, limit) }; 432 v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_iso late, limit) };
433 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", WTF_ARRAY_ LENGTH(argv), argv).ToLocalChecked(); 433 currentCallFramesV8 = callDebuggerMethod("currentCallFrames", WTF_ARRAY_ LENGTH(argv), argv).ToLocalChecked();
434 } 434 }
435 ASSERT(!currentCallFramesV8.IsEmpty()); 435 DCHECK(!currentCallFramesV8.IsEmpty());
436 if (!currentCallFramesV8->IsArray()) 436 if (!currentCallFramesV8->IsArray())
437 return JavaScriptCallFrames(); 437 return JavaScriptCallFrames();
438 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>(); 438 v8::Local<v8::Array> callFramesArray = currentCallFramesV8.As<v8::Array>();
439 JavaScriptCallFrames callFrames; 439 JavaScriptCallFrames callFrames;
440 for (size_t i = 0; i < callFramesArray->Length(); ++i) { 440 for (size_t i = 0; i < callFramesArray->Length(); ++i) {
441 v8::Local<v8::Value> callFrameValue; 441 v8::Local<v8::Value> callFrameValue;
442 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue) ) 442 if (!callFramesArray->Get(debuggerContext(), i).ToLocal(&callFrameValue) )
443 return JavaScriptCallFrames(); 443 return JavaScriptCallFrames();
444 if (!callFrameValue->IsObject()) 444 if (!callFrameValue->IsObject())
445 return JavaScriptCallFrames(); 445 return JavaScriptCallFrames();
446 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>(); 446 v8::Local<v8::Object> callFrameObject = callFrameValue.As<v8::Object>();
447 callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Loc al<v8::Object>::Cast(callFrameObject))); 447 callFrames.append(JavaScriptCallFrame::create(debuggerContext(), v8::Loc al<v8::Object>::Cast(callFrameObject)));
448 } 448 }
449 return callFrames; 449 return callFrames;
450 } 450 }
451 451
452 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data) 452 static V8DebuggerImpl* toV8DebuggerImpl(v8::Local<v8::Value> data)
453 { 453 {
454 void* p = v8::Local<v8::External>::Cast(data)->Value(); 454 void* p = v8::Local<v8::External>::Cast(data)->Value();
455 return static_cast<V8DebuggerImpl*>(p); 455 return static_cast<V8DebuggerImpl*>(p);
456 } 456 }
457 457
458 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info) 458 void V8DebuggerImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Val ue>& info)
459 { 459 {
460 ASSERT(2 == info.Length()); 460 DCHECK_EQ(info.Length(), 2);
461 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(info.Data()); 461 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(info.Data());
462 v8::Local<v8::Context> pausedContext = thisPtr->m_isolate->GetCurrentContext (); 462 v8::Local<v8::Context> pausedContext = thisPtr->m_isolate->GetCurrentContext ();
463 v8::Local<v8::Value> exception; 463 v8::Local<v8::Value> exception;
464 v8::Local<v8::Array> hitBreakpoints; 464 v8::Local<v8::Array> hitBreakpoints;
465 thisPtr->handleProgramBreak(pausedContext, v8::Local<v8::Object>::Cast(info[ 0]), exception, hitBreakpoints); 465 thisPtr->handleProgramBreak(pausedContext, v8::Local<v8::Object>::Cast(info[ 0]), exception, hitBreakpoints);
466 } 466 }
467 467
468 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8 ::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8 ::Array> hitBreakpointNumbers, bool isPromiseRejection) 468 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8 ::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8 ::Array> hitBreakpointNumbers, bool isPromiseRejection)
469 { 469 {
470 // Don't allow nested breaks. 470 // Don't allow nested breaks.
471 if (m_runningNestedMessageLoop) 471 if (m_runningNestedMessageLoop)
472 return; 472 return;
473 473
474 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(pausedContext); 474 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(pausedContext);
475 if (!agent) 475 if (!agent)
476 return; 476 return;
477 477
478 protocol::Vector<String16> breakpointIds; 478 protocol::Vector<String16> breakpointIds;
479 if (!hitBreakpointNumbers.IsEmpty()) { 479 if (!hitBreakpointNumbers.IsEmpty()) {
480 breakpointIds.resize(hitBreakpointNumbers->Length()); 480 breakpointIds.resize(hitBreakpointNumbers->Length());
481 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 481 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
482 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i); 482 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i);
483 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2()); 483 DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2());
484 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( )); 484 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value( ));
485 } 485 }
486 } 486 }
487 487
488 m_pausedContext = pausedContext; 488 m_pausedContext = pausedContext;
489 m_executionState = executionState; 489 m_executionState = executionState;
490 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection); 490 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection);
491 if (result == V8DebuggerAgentImpl::RequestNoSkip) { 491 if (result == V8DebuggerAgentImpl::RequestNoSkip) {
492 m_runningNestedMessageLoop = true; 492 m_runningNestedMessageLoop = true;
493 int groupId = getGroupId(pausedContext); 493 int groupId = getGroupId(pausedContext);
494 ASSERT(groupId); 494 DCHECK(groupId);
495 m_client->runMessageLoopOnPause(groupId); 495 m_client->runMessageLoopOnPause(groupId);
496 // The agent may have been removed in the nested loop. 496 // The agent may have been removed in the nested loop.
497 agent = findEnabledDebuggerAgent(pausedContext); 497 agent = findEnabledDebuggerAgent(pausedContext);
498 if (agent) 498 if (agent)
499 agent->didContinue(); 499 agent->didContinue();
500 m_runningNestedMessageLoop = false; 500 m_runningNestedMessageLoop = false;
501 } 501 }
502 m_pausedContext.Clear(); 502 m_pausedContext.Clear();
503 m_executionState.Clear(); 503 m_executionState.Clear();
504 504
(...skipping 12 matching lines...) Expand all
517 void V8DebuggerImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDe tails) 517 void V8DebuggerImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDe tails)
518 { 518 {
519 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(eventDetails.GetCallbackData()); 519 V8DebuggerImpl* thisPtr = toV8DebuggerImpl(eventDetails.GetCallbackData());
520 thisPtr->handleV8DebugEvent(eventDetails); 520 thisPtr->handleV8DebugEvent(eventDetails);
521 } 521 }
522 522
523 v8::Local<v8::Value> V8DebuggerImpl::callInternalGetterFunction(v8::Local<v8::Ob ject> object, const char* functionName) 523 v8::Local<v8::Value> V8DebuggerImpl::callInternalGetterFunction(v8::Local<v8::Ob ject> object, const char* functionName)
524 { 524 {
525 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); 525 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks);
526 v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(function Name)); 526 v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(function Name));
527 ASSERT(!getterValue.IsEmpty() && getterValue->IsFunction()); 527 DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction());
528 return v8::Local<v8::Function>::Cast(getterValue)->Call(m_isolate->GetCurren tContext(), object, 0, 0).ToLocalChecked(); 528 return v8::Local<v8::Function>::Cast(getterValue)->Call(m_isolate->GetCurren tContext(), object, 0, 0).ToLocalChecked();
529 } 529 }
530 530
531 void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta ils) 531 void V8DebuggerImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDeta ils)
532 { 532 {
533 if (!enabled()) 533 if (!enabled())
534 return; 534 return;
535 v8::DebugEvent event = eventDetails.GetEvent(); 535 v8::DebugEvent event = eventDetails.GetEvent();
536 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError) 536 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError)
537 return; 537 return;
538 538
539 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); 539 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext();
540 ASSERT(!eventContext.IsEmpty()); 540 DCHECK(!eventContext.IsEmpty());
541 541
542 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext); 542 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext);
543 if (agent) { 543 if (agent) {
544 v8::HandleScope scope(m_isolate); 544 v8::HandleScope scope(m_isolate);
545 if (event == v8::AfterCompile || event == v8::CompileError) { 545 if (event == v8::AfterCompile || event == v8::CompileError) {
546 v8::Context::Scope contextScope(debuggerContext()); 546 v8::Context::Scope contextScope(debuggerContext());
547 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; 547 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() };
548 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked(); 548 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked();
549 ASSERT(value->IsObject()); 549 DCHECK(value->IsObject());
550 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 550 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
551 agent->didParseSource(createParsedScript(object, event == v8::AfterC ompile)); 551 agent->didParseSource(createParsedScript(object, event == v8::AfterC ompile));
552 } else if (event == v8::Exception) { 552 } else if (event == v8::Exception) {
553 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); 553 v8::Local<v8::Object> eventData = eventDetails.GetEventData();
554 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat a, "exception"); 554 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat a, "exception");
555 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData, "promise"); 555 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData, "promise");
556 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject(); 556 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject();
557 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), e xception, v8::Local<v8::Array>(), isPromiseRejection); 557 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), e xception, v8::Local<v8::Array>(), isPromiseRejection);
558 } else if (event == v8::Break) { 558 } else if (event == v8::Break) {
559 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; 559 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() };
560 v8::Local<v8::Value> hitBreakpoints = callDebuggerMethod("getBreakpo intNumbers", 1, argv).ToLocalChecked(); 560 v8::Local<v8::Value> hitBreakpoints = callDebuggerMethod("getBreakpo intNumbers", 1, argv).ToLocalChecked();
561 ASSERT(hitBreakpoints->IsArray()); 561 DCHECK(hitBreakpoints->IsArray());
562 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), v 8::Local<v8::Value>(), hitBreakpoints.As<v8::Array>()); 562 handleProgramBreak(eventContext, eventDetails.GetExecutionState(), v 8::Local<v8::Value>(), hitBreakpoints.As<v8::Array>());
563 } else if (event == v8::AsyncTaskEvent) { 563 } else if (event == v8::AsyncTaskEvent) {
564 if (agent->v8AsyncTaskEventsEnabled()) 564 if (agent->v8AsyncTaskEventsEnabled())
565 handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExec utionState(), eventDetails.GetEventData()); 565 handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExec utionState(), eventDetails.GetEventData());
566 } 566 }
567 } 567 }
568 } 568 }
569 569
570 void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Loca l<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Obje ct> eventData) 570 void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Loca l<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Obje ct> eventData)
571 { 571 {
572 String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve ntData, "type")); 572 String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve ntData, "type"));
573 String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve ntData, "name")); 573 String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve ntData, "name"));
574 int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)-> Value(); 574 int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)-> Value();
575 575
576 m_pausedContext = context; 576 m_pausedContext = context;
577 m_executionState = executionState; 577 m_executionState = executionState;
578 agent->didReceiveV8AsyncTaskEvent(context, type, name, id); 578 agent->didReceiveV8AsyncTaskEvent(context, type, name, id);
579 m_pausedContext.Clear(); 579 m_pausedContext.Clear();
580 m_executionState.Clear(); 580 m_executionState.Clear();
581 } 581 }
582 582
583 V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object> object, bool success) 583 V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object> object, bool success)
584 { 584 {
585 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); 585 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id"));
586 ASSERT(!id.IsEmpty() && id->IsInt32()); 586 DCHECK(!id.IsEmpty() && id->IsInt32());
587 587
588 V8DebuggerParsedScript parsedScript; 588 V8DebuggerParsedScript parsedScript;
589 parsedScript.scriptId = String16::number(id->Int32Value()); 589 parsedScript.scriptId = String16::number(id->Int32Value());
590 parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8Inter nalizedString("name")))) 590 parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8Inter nalizedString("name"))))
591 .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedSt ring("sourceURL")))) 591 .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedSt ring("sourceURL"))))
592 .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8Interna lizedString("sourceMappingURL")))) 592 .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8Interna lizedString("sourceMappingURL"))))
593 .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedStrin g("source")))) 593 .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedStrin g("source"))))
594 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger( m_isolate)->Value()) 594 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger( m_isolate)->Value())
595 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte ger(m_isolate)->Value()) 595 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte ger(m_isolate)->Value())
596 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is olate)->Value()) 596 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is olate)->Value())
597 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger( m_isolate)->Value()) 597 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger( m_isolate)->Value())
598 .setIsContentScript(object->Get(v8InternalizedString("isContentScript")) ->ToBoolean(m_isolate)->Value()) 598 .setIsContentScript(object->Get(v8InternalizedString("isContentScript")) ->ToBoolean(m_isolate)->Value())
599 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript" ))->ToBoolean(m_isolate)->Value()) 599 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript" ))->ToBoolean(m_isolate)->Value())
600 .setExecutionContextId(object->Get(v8InternalizedString("executionContex tId"))->ToInteger(m_isolate)->Value()) 600 .setExecutionContextId(object->Get(v8InternalizedString("executionContex tId"))->ToInteger(m_isolate)->Value())
601 .setIsLiveEdit(inLiveEditScope); 601 .setIsLiveEdit(inLiveEditScope);
602 parsedScript.success = success; 602 parsedScript.success = success;
603 return parsedScript; 603 return parsedScript;
604 } 604 }
605 605
606 void V8DebuggerImpl::compileDebuggerScript() 606 void V8DebuggerImpl::compileDebuggerScript()
607 { 607 {
608 if (!m_debuggerScript.IsEmpty()) { 608 if (!m_debuggerScript.IsEmpty()) {
609 ASSERT_NOT_REACHED(); 609 NOTREACHED();
610 return; 610 return;
611 } 611 }
612 612
613 v8::HandleScope scope(m_isolate); 613 v8::HandleScope scope(m_isolate);
614 v8::Context::Scope contextScope(debuggerContext()); 614 v8::Context::Scope contextScope(debuggerContext());
615 615
616 v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, Debug gerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLoc alChecked(); 616 v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, Debug gerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLoc alChecked();
617 v8::Local<v8::Value> value; 617 v8::Local<v8::Value> value;
618 if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&va lue)) 618 if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&va lue))
619 return; 619 return;
620 ASSERT(value->IsObject()); 620 DCHECK(value->IsObject());
621 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>()); 621 m_debuggerScript.Reset(m_isolate, value.As<v8::Object>());
622 } 622 }
623 623
624 v8::Local<v8::Context> V8DebuggerImpl::debuggerContext() const 624 v8::Local<v8::Context> V8DebuggerImpl::debuggerContext() const
625 { 625 {
626 ASSERT(!m_debuggerContext.IsEmpty()); 626 DCHECK(!m_debuggerContext.IsEmpty());
627 return m_debuggerContext.Get(m_isolate); 627 return m_debuggerContext.Get(m_isolate);
628 } 628 }
629 629
630 v8::Local<v8::String> V8DebuggerImpl::v8InternalizedString(const char* str) cons t 630 v8::Local<v8::String> V8DebuggerImpl::v8InternalizedString(const char* str) cons t
631 { 631 {
632 return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternali zed).ToLocalChecked(); 632 return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternali zed).ToLocalChecked();
633 } 633 }
634 634
635 v8::MaybeLocal<v8::Value> V8DebuggerImpl::functionScopes(v8::Local<v8::Function> function) 635 v8::MaybeLocal<v8::Value> V8DebuggerImpl::functionScopes(v8::Local<v8::Function> function)
636 { 636 {
637 if (!enabled()) { 637 if (!enabled()) {
638 ASSERT_NOT_REACHED(); 638 NOTREACHED();
639 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); 639 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
640 } 640 }
641 v8::Local<v8::Value> argv[] = { function }; 641 v8::Local<v8::Value> argv[] = { function };
642 return callDebuggerMethod("getFunctionScopes", 1, argv); 642 return callDebuggerMethod("getFunctionScopes", 1, argv);
643 } 643 }
644 644
645 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectDetails(v8::Local<v8::Object >& object) 645 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectDetails(v8::Local<v8::Object >& object)
646 { 646 {
647 if (!enabled()) { 647 if (!enabled()) {
648 ASSERT_NOT_REACHED(); 648 NOTREACHED();
649 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); 649 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
650 } 650 }
651 v8::Local<v8::Value> argv[] = { object }; 651 v8::Local<v8::Value> argv[] = { object };
652 return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalCheck ed(); 652 return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalCheck ed();
653 } 653 }
654 654
655 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Object>& ob ject) 655 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Object>& ob ject)
656 { 656 {
657 if (!enabled()) { 657 if (!enabled()) {
658 ASSERT_NOT_REACHED(); 658 NOTREACHED();
659 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); 659 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
660 } 660 }
661 v8::Local<v8::Value> argv[] = { object }; 661 v8::Local<v8::Value> argv[] = { object };
662 return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); 662 return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked();
663 } 663 }
664 664
665 bool V8DebuggerImpl::isPaused() 665 bool V8DebuggerImpl::isPaused()
666 { 666 {
667 return !m_pausedContext.IsEmpty(); 667 return !m_pausedContext.IsEmpty();
668 } 668 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 731 }
732 732
733 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra ce> stackTrace, size_t maxStackSize) 733 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra ce> stackTrace, size_t maxStackSize)
734 { 734 {
735 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC ontext()); 735 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC ontext());
736 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); 736 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize);
737 } 737 }
738 738
739 PassOwnPtr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId) 739 PassOwnPtr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId)
740 { 740 {
741 ASSERT(!m_sessions.contains(contextGroupId)); 741 DCHECK(!m_sessions.contains(contextGroupId));
742 OwnPtr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(this , contextGroupId); 742 OwnPtr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(this , contextGroupId);
743 m_sessions.set(contextGroupId, session.get()); 743 m_sessions.set(contextGroupId, session.get());
744 return std::move(session); 744 return std::move(session);
745 } 745 }
746 746
747 void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session) 747 void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session)
748 { 748 {
749 ASSERT(m_sessions.contains(session->contextGroupId())); 749 DCHECK(m_sessions.contains(session->contextGroupId()));
750 m_sessions.remove(session->contextGroupId()); 750 m_sessions.remove(session->contextGroupId());
751 } 751 }
752 752
753 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) 753 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info)
754 { 754 {
755 ASSERT(info.context->GetIsolate() == m_isolate); 755 DCHECK(info.context->GetIsolate() == m_isolate);
756 // TODO(dgozman): make s_lastContextId non-static. 756 // TODO(dgozman): make s_lastContextId non-static.
757 int contextId = atomicIncrement(&s_lastContextId); 757 int contextId = atomicIncrement(&s_lastContextId);
758 String16 debugData = String16::number(info.contextGroupId) + "," + String16: :number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); 758 String16 debugData = String16::number(info.contextGroupId) + "," + String16: :number(contextId) + "," + (info.isDefault ? "default" : "nondefault");
759 v8::HandleScope scope(m_isolate); 759 v8::HandleScope scope(m_isolate);
760 v8::Context::Scope contextScope(info.context); 760 v8::Context::Scope contextScope(info.context);
761 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); 761 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData));
762 762
763 if (!m_contexts.contains(info.contextGroupId)) 763 if (!m_contexts.contains(info.contextGroupId))
764 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); 764 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap()));
765 ASSERT(!m_contexts.get(info.contextGroupId)->contains(contextId)); 765 DCHECK(!m_contexts.get(info.contextGroupId)->contains(contextId));
766 766
767 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this, info, contextId)); 767 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this, info, contextId));
768 InspectedContext* inspectedContext = contextOwner.get(); 768 InspectedContext* inspectedContext = contextOwner.get();
769 m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner)) ; 769 m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner)) ;
770 770
771 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) 771 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId))
772 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont ext); 772 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont ext);
773 } 773 }
774 774
775 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) 775 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 return nullptr; 845 return nullptr;
846 return m_contexts.get(contextGroupId); 846 return m_contexts.get(contextGroupId);
847 } 847 }
848 848
849 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 849 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
850 { 850 {
851 return contextGroupId ? m_sessions.get(contextGroupId) : nullptr; 851 return contextGroupId ? m_sessions.get(contextGroupId) : nullptr;
852 } 852 }
853 853
854 } // namespace blink 854 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698