OLD | NEW |
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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 { | 371 { |
372 ASSERT(isPaused()); | 372 ASSERT(isPaused()); |
373 ASSERT(!m_executionState.IsEmpty()); | 373 ASSERT(!m_executionState.IsEmpty()); |
374 v8::Local<v8::Value> argv[] = { m_executionState }; | 374 v8::Local<v8::Value> argv[] = { m_executionState }; |
375 v8::Local<v8::Value> result = callDebuggerMethod("frameCount", WTF_ARRAY_LEN
GTH(argv), argv).ToLocalChecked(); | 375 v8::Local<v8::Value> result = callDebuggerMethod("frameCount", WTF_ARRAY_LEN
GTH(argv), argv).ToLocalChecked(); |
376 if (result->IsInt32()) | 376 if (result->IsInt32()) |
377 return result->Int32Value(); | 377 return result->Int32Value(); |
378 return 0; | 378 return 0; |
379 } | 379 } |
380 | 380 |
381 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::toJavaScriptCallFrameUns
afe(const ScriptValue& value) | 381 PassRefPtr<JavaScriptCallFrame> V8Debugger::toJavaScriptCallFrameUnsafe(const Sc
riptValue& value) |
382 { | 382 { |
383 if (value.isEmpty()) | 383 if (value.isEmpty()) |
384 return nullptr; | 384 return nullptr; |
385 ScriptState* scriptState = value.scriptState(); | 385 ScriptState* scriptState = value.scriptState(); |
386 if (!scriptState || !scriptState->contextIsValid()) | 386 if (!scriptState || !scriptState->contextIsValid()) |
387 return nullptr; | 387 return nullptr; |
388 ScriptState::Scope scope(scriptState); | 388 ScriptState::Scope scope(scriptState); |
389 ASSERT(value.isObject()); | 389 ASSERT(value.isObject()); |
390 return V8JavaScriptCallFrame::unwrap(v8::Local<v8::Object>::Cast(value.v8Val
ueUnsafe())); | 390 return V8JavaScriptCallFrame::unwrap(v8::Local<v8::Object>::Cast(value.v8Val
ueUnsafe())); |
391 } | 391 } |
392 | 392 |
393 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::wrapCallFrames(int maxim
umLimit, ScopeInfoDetails scopeDetails) | 393 PassRefPtr<JavaScriptCallFrame> V8Debugger::wrapCallFrames(int maximumLimit, Sco
peInfoDetails scopeDetails) |
394 { | 394 { |
395 const int scopeBits = 2; | 395 const int scopeBits = 2; |
396 static_assert(NoScopes < (1 << scopeBits), "there must be enough bits to enc
ode ScopeInfoDetails"); | 396 static_assert(NoScopes < (1 << scopeBits), "there must be enough bits to enc
ode ScopeInfoDetails"); |
397 | 397 |
398 ASSERT(maximumLimit >= 0); | 398 ASSERT(maximumLimit >= 0); |
399 int data = (maximumLimit << scopeBits) | scopeDetails; | 399 int data = (maximumLimit << scopeBits) | scopeDetails; |
400 v8::Local<v8::Value> currentCallFrameV8; | 400 v8::Local<v8::Value> currentCallFrameV8; |
401 if (m_executionState.IsEmpty()) { | 401 if (m_executionState.IsEmpty()) { |
402 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(debuggerScriptLocal()->Get(v8InternalizedString("currentCallFrame"))); | 402 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(debuggerScriptLocal()->Get(v8InternalizedString("currentCallFrame"))); |
403 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, data)); | 403 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, data)); |
(...skipping 11 matching lines...) Expand all Loading... |
415 { | 415 { |
416 if (!m_isolate->InContext()) | 416 if (!m_isolate->InContext()) |
417 return ScriptValue(); | 417 return ScriptValue(); |
418 v8::HandleScope handleScope(m_isolate); | 418 v8::HandleScope handleScope(m_isolate); |
419 | 419 |
420 // Filter out stack traces entirely consisting of V8's internal scripts. | 420 // Filter out stack traces entirely consisting of V8's internal scripts. |
421 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i
solate, 1); | 421 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_i
solate, 1); |
422 if (!stackTrace->GetFrameCount()) | 422 if (!stackTrace->GetFrameCount()) |
423 return ScriptValue(); | 423 return ScriptValue(); |
424 | 424 |
425 RefPtrWillBeRawPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0,
scopeDetails); | 425 RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0, scopeDetail
s); |
426 if (!currentCallFrame) | 426 if (!currentCallFrame) |
427 return ScriptValue(); | 427 return ScriptValue(); |
428 | 428 |
429 v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemp
late>::New(m_isolate, m_callFrameWrapperTemplate); | 429 v8::Local<v8::FunctionTemplate> wrapperTemplate = v8::Local<v8::FunctionTemp
late>::New(m_isolate, m_callFrameWrapperTemplate); |
430 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() :
ScriptState::current(m_isolate); | 430 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() :
ScriptState::current(m_isolate); |
431 ScriptState::Scope scope(scriptState); | 431 ScriptState::Scope scope(scriptState); |
432 v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(wrapperTemplate,
scriptState->context(), currentCallFrame.release()); | 432 v8::Local<v8::Object> wrapper = V8JavaScriptCallFrame::wrap(wrapperTemplate,
scriptState->context(), currentCallFrame.release()); |
433 return ScriptValue(scriptState, wrapper); | 433 return ScriptValue(scriptState, wrapper); |
434 } | 434 } |
435 | 435 |
436 ScriptValue V8Debugger::currentCallFrames() | 436 ScriptValue V8Debugger::currentCallFrames() |
437 { | 437 { |
438 return currentCallFramesInner(AllScopes); | 438 return currentCallFramesInner(AllScopes); |
439 } | 439 } |
440 | 440 |
441 ScriptValue V8Debugger::currentCallFramesForAsyncStack() | 441 ScriptValue V8Debugger::currentCallFramesForAsyncStack() |
442 { | 442 { |
443 return currentCallFramesInner(FastAsyncScopes); | 443 return currentCallFramesInner(FastAsyncScopes); |
444 } | 444 } |
445 | 445 |
446 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> V8Debugger::callFrameNoScopes(int in
dex) | 446 PassRefPtr<JavaScriptCallFrame> V8Debugger::callFrameNoScopes(int index) |
447 { | 447 { |
448 if (!m_isolate->InContext()) | 448 if (!m_isolate->InContext()) |
449 return nullptr; | 449 return nullptr; |
450 v8::HandleScope handleScope(m_isolate); | 450 v8::HandleScope handleScope(m_isolate); |
451 | 451 |
452 v8::Local<v8::Value> currentCallFrameV8; | 452 v8::Local<v8::Value> currentCallFrameV8; |
453 if (m_executionState.IsEmpty()) { | 453 if (m_executionState.IsEmpty()) { |
454 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(debuggerScriptLocal()->Get(v8InternalizedString("currentCallFrameByInde
x"))); | 454 v8::Local<v8::Function> currentCallFrameFunction = v8::Local<v8::Functio
n>::Cast(debuggerScriptLocal()->Get(v8InternalizedString("currentCallFrameByInde
x"))); |
455 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, index)); | 455 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, index)); |
456 } else { | 456 } else { |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 705 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 bool V8Debugger::isPaused() | 709 bool V8Debugger::isPaused() |
710 { | 710 { |
711 return m_pausedScriptState; | 711 return m_pausedScriptState; |
712 } | 712 } |
713 | 713 |
714 } // namespace blink | 714 } // namespace blink |
OLD | NEW |