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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 { | 318 { |
319 ASSERT(isPaused()); | 319 ASSERT(isPaused()); |
320 ASSERT(!m_executionState.IsEmpty()); | 320 ASSERT(!m_executionState.IsEmpty()); |
321 v8::Handle<v8::Value> argv[] = { m_executionState }; | 321 v8::Handle<v8::Value> argv[] = { m_executionState }; |
322 v8::Handle<v8::Value> result = callDebuggerMethod("frameCount", WTF_ARRAY_LE
NGTH(argv), argv); | 322 v8::Handle<v8::Value> result = callDebuggerMethod("frameCount", WTF_ARRAY_LE
NGTH(argv), argv); |
323 if (result->IsInt32()) | 323 if (result->IsInt32()) |
324 return result->Int32Value(); | 324 return result->Int32Value(); |
325 return 0; | 325 return 0; |
326 } | 326 } |
327 | 327 |
328 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::wrapCallFrames(int maximumLim
it, ScopeInfoDetails scopeDetails) | 328 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> ScriptDebugServer::wrapCallFrames(in
t maximumLimit, ScopeInfoDetails scopeDetails) |
329 { | 329 { |
330 const int scopeBits = 2; | 330 const int scopeBits = 2; |
331 COMPILE_ASSERT(NoScopes < (1 << scopeBits), not_enough_bits_to_encode_ScopeI
nfoDetails); | 331 COMPILE_ASSERT(NoScopes < (1 << scopeBits), not_enough_bits_to_encode_ScopeI
nfoDetails); |
332 | 332 |
333 ASSERT(maximumLimit >= 0); | 333 ASSERT(maximumLimit >= 0); |
334 int data = (maximumLimit << scopeBits) | scopeDetails; | 334 int data = (maximumLimit << scopeBits) | scopeDetails; |
335 v8::Handle<v8::Value> currentCallFrameV8; | 335 v8::Handle<v8::Value> currentCallFrameV8; |
336 if (m_executionState.IsEmpty()) { | 336 if (m_executionState.IsEmpty()) { |
337 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Functi
on>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "c
urrentCallFrame"))); | 337 v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Functi
on>::Cast(m_debuggerScript.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "c
urrentCallFrame"))); |
338 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, data)); | 338 currentCallFrameV8 = v8::Debug::Call(currentCallFrameFunction, v8::Integ
er::New(m_isolate, data)); |
339 } else { | 339 } else { |
340 v8::Handle<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_is
olate, data) }; | 340 v8::Handle<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_is
olate, data) }; |
341 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE
NGTH(argv), argv); | 341 currentCallFrameV8 = callDebuggerMethod("currentCallFrame", WTF_ARRAY_LE
NGTH(argv), argv); |
342 } | 342 } |
343 ASSERT(!currentCallFrameV8.IsEmpty()); | 343 ASSERT(!currentCallFrameV8.IsEmpty()); |
344 if (!currentCallFrameV8->IsObject()) | 344 if (!currentCallFrameV8->IsObject()) |
345 return PassRefPtr<JavaScriptCallFrame>(); | 345 return nullptr; |
346 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<
v8::Object>::Cast(currentCallFrameV8)); | 346 return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<
v8::Object>::Cast(currentCallFrameV8)); |
347 } | 347 } |
348 | 348 |
349 ScriptValue ScriptDebugServer::currentCallFramesInner(ScopeInfoDetails scopeDeta
ils) | 349 ScriptValue ScriptDebugServer::currentCallFramesInner(ScopeInfoDetails scopeDeta
ils) |
350 { | 350 { |
351 if (!m_isolate->InContext()) | 351 if (!m_isolate->InContext()) |
352 return ScriptValue(); | 352 return ScriptValue(); |
353 v8::HandleScope handleScope(m_isolate); | 353 v8::HandleScope handleScope(m_isolate); |
354 | 354 |
355 RefPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0, scopeDetail
s); | 355 RefPtrWillBeRawPtr<JavaScriptCallFrame> currentCallFrame = wrapCallFrames(0,
scopeDetails); |
356 if (!currentCallFrame) | 356 if (!currentCallFrame) |
357 return ScriptValue(); | 357 return ScriptValue(); |
358 | 358 |
359 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() :
ScriptState::current(m_isolate); | 359 ScriptState* scriptState = m_pausedScriptState ? m_pausedScriptState.get() :
ScriptState::current(m_isolate); |
360 ScriptState::Scope scope(scriptState); | 360 ScriptState::Scope scope(scriptState); |
361 return ScriptValue(scriptState, toV8(currentCallFrame.release(), scriptState
->context()->Global(), m_isolate)); | 361 return ScriptValue(scriptState, toV8(currentCallFrame.release(), scriptState
->context()->Global(), m_isolate)); |
362 } | 362 } |
363 | 363 |
364 ScriptValue ScriptDebugServer::currentCallFrames() | 364 ScriptValue ScriptDebugServer::currentCallFrames() |
365 { | 365 { |
366 return currentCallFramesInner(AllScopes); | 366 return currentCallFramesInner(AllScopes); |
367 } | 367 } |
368 | 368 |
369 ScriptValue ScriptDebugServer::currentCallFramesForAsyncStack() | 369 ScriptValue ScriptDebugServer::currentCallFramesForAsyncStack() |
370 { | 370 { |
371 return currentCallFramesInner(FastAsyncScopes); | 371 return currentCallFramesInner(FastAsyncScopes); |
372 } | 372 } |
373 | 373 |
374 PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::topCallFrameNoScopes() | 374 PassRefPtrWillBeRawPtr<JavaScriptCallFrame> ScriptDebugServer::topCallFrameNoSco
pes() |
375 { | 375 { |
376 return wrapCallFrames(1, NoScopes); | 376 return wrapCallFrames(1, NoScopes); |
377 } | 377 } |
378 | 378 |
379 void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task, v8::Isolate* isol
ate) | 379 void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task, v8::Isolate* isol
ate) |
380 { | 380 { |
381 v8::Debug::DebugBreakForCommand(isolate, new ClientDataImpl(task)); | 381 v8::Debug::DebugBreakForCommand(isolate, new ClientDataImpl(task)); |
382 } | 382 } |
383 | 383 |
384 void ScriptDebugServer::runPendingTasks() | 384 void ScriptDebugServer::runPendingTasks() |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 }; | 562 }; |
563 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 563 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 bool ScriptDebugServer::isPaused() | 567 bool ScriptDebugServer::isPaused() |
568 { | 568 { |
569 return m_pausedScriptState; | 569 return m_pausedScriptState; |
570 } | 570 } |
571 | 571 |
572 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex
pression, const String& sourceURL, String* scriptId, String* exceptionDetailsTex
t, int* lineNumber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) | 572 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex
pression, const String& sourceURL, String* scriptId, String* exceptionDetailsTex
t, int* lineNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stac
kTrace) |
573 { | 573 { |
574 if (scriptState->contextIsEmpty()) | 574 if (scriptState->contextIsEmpty()) |
575 return; | 575 return; |
576 ScriptState::Scope scope(scriptState); | 576 ScriptState::Scope scope(scriptState); |
577 | 577 |
578 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 578 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
579 v8::TryCatch tryCatch; | 579 v8::TryCatch tryCatch; |
580 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); | 580 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); |
581 if (tryCatch.HasCaught()) { | 581 if (tryCatch.HasCaught()) { |
582 v8::Local<v8::Message> message = tryCatch.Message(); | 582 v8::Local<v8::Message> message = tryCatch.Message(); |
(...skipping 10 matching lines...) Expand all Loading... |
593 | 593 |
594 *scriptId = String::number(script->GetUnboundScript()->GetId()); | 594 *scriptId = String::number(script->GetUnboundScript()->GetId()); |
595 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); | 595 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); |
596 } | 596 } |
597 | 597 |
598 void ScriptDebugServer::clearCompiledScripts() | 598 void ScriptDebugServer::clearCompiledScripts() |
599 { | 599 { |
600 m_compiledScripts.clear(); | 600 m_compiledScripts.clear(); |
601 } | 601 } |
602 | 602 |
603 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) | 603 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace) |
604 { | 604 { |
605 if (!m_compiledScripts.contains(scriptId)) | 605 if (!m_compiledScripts.contains(scriptId)) |
606 return; | 606 return; |
607 v8::HandleScope handleScope(m_isolate); | 607 v8::HandleScope handleScope(m_isolate); |
608 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; | 608 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; |
609 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); | 609 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); |
610 m_compiledScripts.remove(scriptId); | 610 m_compiledScripts.remove(scriptId); |
611 if (script.IsEmpty()) | 611 if (script.IsEmpty()) |
612 return; | 612 return; |
613 | 613 |
(...skipping 22 matching lines...) Expand all Loading... |
636 { | 636 { |
637 return PassOwnPtr<ScriptSourceCode>(); | 637 return PassOwnPtr<ScriptSourceCode>(); |
638 } | 638 } |
639 | 639 |
640 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) | 640 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) |
641 { | 641 { |
642 return source; | 642 return source; |
643 } | 643 } |
644 | 644 |
645 } // namespace WebCore | 645 } // namespace WebCore |
OLD | NEW |