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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "bindings/v8/ScriptDebugServer.h" | 32 #include "bindings/v8/ScriptDebugServer.h" |
33 | 33 |
34 #include "DebuggerScriptSource.h" | 34 #include "DebuggerScriptSource.h" |
35 #include "V8JavaScriptCallFrame.h" | 35 #include "V8JavaScriptCallFrame.h" |
36 #include "bindings/v8/ScopedPersistent.h" | 36 #include "bindings/v8/ScopedPersistent.h" |
| 37 #include "bindings/v8/ScriptCallStackFactory.h" |
37 #include "bindings/v8/ScriptController.h" | 38 #include "bindings/v8/ScriptController.h" |
38 #include "bindings/v8/ScriptObject.h" | 39 #include "bindings/v8/ScriptObject.h" |
39 #include "bindings/v8/ScriptSourceCode.h" | 40 #include "bindings/v8/ScriptSourceCode.h" |
40 #include "bindings/v8/V8Binding.h" | 41 #include "bindings/v8/V8Binding.h" |
41 #include "bindings/v8/V8ScriptRunner.h" | 42 #include "bindings/v8/V8ScriptRunner.h" |
42 #include "core/inspector/JavaScriptCallFrame.h" | 43 #include "core/inspector/JavaScriptCallFrame.h" |
43 #include "core/inspector/ScriptDebugListener.h" | 44 #include "core/inspector/ScriptDebugListener.h" |
44 #include "platform/JSONValues.h" | 45 #include "platform/JSONValues.h" |
45 #include "wtf/StdLibExtras.h" | 46 #include "wtf/StdLibExtras.h" |
46 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 }; | 594 }; |
594 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 595 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
595 } | 596 } |
596 | 597 |
597 | 598 |
598 bool ScriptDebugServer::isPaused() | 599 bool ScriptDebugServer::isPaused() |
599 { | 600 { |
600 return !m_executionState.isEmpty(); | 601 return !m_executionState.isEmpty(); |
601 } | 602 } |
602 | 603 |
603 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex
pression, const String& sourceURL, String* scriptId, String* exceptionMessage, i
nt* lineNumber, int* columnNumber) | 604 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex
pression, const String& sourceURL, String* scriptId, String* exceptionDetailsTex
t, int* lineNumber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) |
604 { | 605 { |
605 if (scriptState->contextIsEmpty()) | 606 if (scriptState->contextIsEmpty()) |
606 return; | 607 return; |
607 ScriptState::Scope scope(scriptState); | 608 ScriptState::Scope scope(scriptState); |
608 | 609 |
609 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 610 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
610 v8::TryCatch tryCatch; | 611 v8::TryCatch tryCatch; |
611 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); | 612 v8::Local<v8::Script> script = V8ScriptRunner::compileScript(source, sourceU
RL, TextPosition(), 0, m_isolate); |
612 if (tryCatch.HasCaught()) { | 613 if (tryCatch.HasCaught()) { |
613 v8::Local<v8::Message> message = tryCatch.Message(); | 614 v8::Local<v8::Message> message = tryCatch.Message(); |
614 if (!message.IsEmpty()) { | 615 if (!message.IsEmpty()) { |
615 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); | 616 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
616 if (lineNumber) | 617 *lineNumber = message->GetLineNumber(); |
617 *lineNumber = message->GetLineNumber(); | 618 *columnNumber = message->GetStartColumn(); |
618 if (columnNumber) | 619 *stackTrace = createScriptCallStack(message->GetStackTrace(), Script
CallStack::maxCallStackSizeToCapture, m_isolate); |
619 *columnNumber = message->GetStartColumn(); | |
620 } | 620 } |
621 return; | 621 return; |
622 } | 622 } |
623 if (script.IsEmpty()) | 623 if (script.IsEmpty()) |
624 return; | 624 return; |
625 | 625 |
626 *scriptId = String::number(script->GetId()); | 626 *scriptId = String::number(script->GetId()); |
627 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); | 627 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m
_isolate, script))); |
628 } | 628 } |
629 | 629 |
630 void ScriptDebugServer::clearCompiledScripts() | 630 void ScriptDebugServer::clearCompiledScripts() |
631 { | 631 { |
632 m_compiledScripts.clear(); | 632 m_compiledScripts.clear(); |
633 } | 633 } |
634 | 634 |
635 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionMessage, int* lineNum
ber, int* columnNumber) | 635 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) |
636 { | 636 { |
637 if (!m_compiledScripts.contains(scriptId)) | 637 if (!m_compiledScripts.contains(scriptId)) |
638 return; | 638 return; |
639 v8::HandleScope handleScope(m_isolate); | 639 v8::HandleScope handleScope(m_isolate); |
640 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; | 640 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; |
641 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); | 641 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); |
642 m_compiledScripts.remove(scriptId); | 642 m_compiledScripts.remove(scriptId); |
643 if (script.IsEmpty()) | 643 if (script.IsEmpty()) |
644 return; | 644 return; |
645 | 645 |
646 if (scriptState->contextIsEmpty()) | 646 if (scriptState->contextIsEmpty()) |
647 return; | 647 return; |
648 ScriptState::Scope scope(scriptState); | 648 ScriptState::Scope scope(scriptState); |
649 v8::TryCatch tryCatch; | 649 v8::TryCatch tryCatch; |
650 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip
tState->executionContext(), m_isolate); | 650 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip
tState->executionContext(), m_isolate); |
651 *wasThrown = false; | 651 *wasThrown = false; |
652 if (tryCatch.HasCaught()) { | 652 if (tryCatch.HasCaught()) { |
653 *wasThrown = true; | 653 *wasThrown = true; |
654 *result = ScriptValue(scriptState, tryCatch.Exception()); | 654 *result = ScriptValue(scriptState, tryCatch.Exception()); |
655 v8::Local<v8::Message> message = tryCatch.Message(); | 655 v8::Local<v8::Message> message = tryCatch.Message(); |
656 if (!message.IsEmpty()) { | 656 if (!message.IsEmpty()) { |
657 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); | 657 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
658 if (lineNumber) | 658 *lineNumber = message->GetLineNumber(); |
659 *lineNumber = message->GetLineNumber(); | 659 *columnNumber = message->GetStartColumn(); |
660 if (columnNumber) | 660 *stackTrace = createScriptCallStack(message->GetStackTrace(), Script
CallStack::maxCallStackSizeToCapture, m_isolate); |
661 *columnNumber = message->GetStartColumn(); | |
662 } | 661 } |
663 } else { | 662 } else { |
664 *result = ScriptValue(scriptState, value); | 663 *result = ScriptValue(scriptState, value); |
665 } | 664 } |
666 } | 665 } |
667 | 666 |
668 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc
riptSourceCode&) | 667 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc
riptSourceCode&) |
669 { | 668 { |
670 return PassOwnPtr<ScriptSourceCode>(); | 669 return PassOwnPtr<ScriptSourceCode>(); |
671 } | 670 } |
672 | 671 |
673 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) | 672 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) |
674 { | 673 { |
675 return source; | 674 return source; |
676 } | 675 } |
677 | 676 |
678 } // namespace WebCore | 677 } // namespace WebCore |
OLD | NEW |