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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 "bindings/core/v8/V8JavaScriptCallFrame.h" | 34 #include "bindings/core/v8/V8JavaScriptCallFrame.h" |
35 #include "bindings/v8/ScopedPersistent.h" | 35 #include "bindings/v8/ScopedPersistent.h" |
| 36 #include "bindings/v8/ScriptCallStackFactory.h" |
36 #include "bindings/v8/ScriptController.h" | 37 #include "bindings/v8/ScriptController.h" |
37 #include "bindings/v8/ScriptSourceCode.h" | 38 #include "bindings/v8/ScriptSourceCode.h" |
38 #include "bindings/v8/ScriptValue.h" | 39 #include "bindings/v8/ScriptValue.h" |
39 #include "bindings/v8/V8Binding.h" | 40 #include "bindings/v8/V8Binding.h" |
40 #include "bindings/v8/V8ScriptRunner.h" | 41 #include "bindings/v8/V8ScriptRunner.h" |
41 #include "core/DebuggerScriptSource.h" | 42 #include "core/DebuggerScriptSource.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" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 }; | 562 }; |
562 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 563 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
563 } | 564 } |
564 | 565 |
565 | 566 |
566 bool ScriptDebugServer::isPaused() | 567 bool ScriptDebugServer::isPaused() |
567 { | 568 { |
568 return m_pausedScriptState; | 569 return m_pausedScriptState; |
569 } | 570 } |
570 | 571 |
571 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex
pression, const String& sourceURL, String* scriptId, String* exceptionMessage) | 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 { | 573 { |
573 if (scriptState->contextIsEmpty()) | 574 if (scriptState->contextIsEmpty()) |
574 return; | 575 return; |
575 ScriptState::Scope scope(scriptState); | 576 ScriptState::Scope scope(scriptState); |
576 | 577 |
577 v8::Handle<v8::String> source = v8String(m_isolate, expression); | 578 v8::Handle<v8::String> source = v8String(m_isolate, expression); |
578 v8::TryCatch tryCatch; | 579 v8::TryCatch tryCatch; |
579 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); |
580 if (tryCatch.HasCaught()) { | 581 if (tryCatch.HasCaught()) { |
581 v8::Local<v8::Message> message = tryCatch.Message(); | 582 v8::Local<v8::Message> message = tryCatch.Message(); |
582 if (!message.IsEmpty()) | 583 if (!message.IsEmpty()) { |
583 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); | 584 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
| 585 *lineNumber = message->GetLineNumber(); |
| 586 *columnNumber = message->GetStartColumn(); |
| 587 *stackTrace = createScriptCallStack(message->GetStackTrace(), messag
e->GetStackTrace()->GetFrameCount(), m_isolate); |
| 588 } |
584 return; | 589 return; |
585 } | 590 } |
586 if (script.IsEmpty()) | 591 if (script.IsEmpty()) |
587 return; | 592 return; |
588 | 593 |
589 *scriptId = String::number(script->GetUnboundScript()->GetId()); | 594 *scriptId = String::number(script->GetUnboundScript()->GetId()); |
590 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))); |
591 } | 596 } |
592 | 597 |
593 void ScriptDebugServer::clearCompiledScripts() | 598 void ScriptDebugServer::clearCompiledScripts() |
594 { | 599 { |
595 m_compiledScripts.clear(); | 600 m_compiledScripts.clear(); |
596 } | 601 } |
597 | 602 |
598 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionMessage) | 603 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script
Id, ScriptValue* result, bool* wasThrown, String* exceptionDetailsText, int* lin
eNumber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace) |
599 { | 604 { |
600 if (!m_compiledScripts.contains(scriptId)) | 605 if (!m_compiledScripts.contains(scriptId)) |
601 return; | 606 return; |
602 v8::HandleScope handleScope(m_isolate); | 607 v8::HandleScope handleScope(m_isolate); |
603 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; | 608 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId)
; |
604 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); | 609 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); |
605 m_compiledScripts.remove(scriptId); | 610 m_compiledScripts.remove(scriptId); |
606 if (script.IsEmpty()) | 611 if (script.IsEmpty()) |
607 return; | 612 return; |
608 | 613 |
609 if (scriptState->contextIsEmpty()) | 614 if (scriptState->contextIsEmpty()) |
610 return; | 615 return; |
611 ScriptState::Scope scope(scriptState); | 616 ScriptState::Scope scope(scriptState); |
612 v8::TryCatch tryCatch; | 617 v8::TryCatch tryCatch; |
613 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip
tState->executionContext(), m_isolate); | 618 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip
tState->executionContext(), m_isolate); |
614 *wasThrown = false; | 619 *wasThrown = false; |
615 if (tryCatch.HasCaught()) { | 620 if (tryCatch.HasCaught()) { |
616 *wasThrown = true; | 621 *wasThrown = true; |
617 *result = ScriptValue(scriptState, tryCatch.Exception()); | 622 *result = ScriptValue(scriptState, tryCatch.Exception()); |
618 v8::Local<v8::Message> message = tryCatch.Message(); | 623 v8::Local<v8::Message> message = tryCatch.Message(); |
619 if (!message.IsEmpty()) | 624 if (!message.IsEmpty()) { |
620 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge
t()); | 625 *exceptionDetailsText = toCoreStringWithUndefinedOrNullCheck(message
->Get()); |
| 626 *lineNumber = message->GetLineNumber(); |
| 627 *columnNumber = message->GetStartColumn(); |
| 628 *stackTrace = createScriptCallStack(message->GetStackTrace(), messag
e->GetStackTrace()->GetFrameCount(), m_isolate); |
| 629 } |
621 } else { | 630 } else { |
622 *result = ScriptValue(scriptState, value); | 631 *result = ScriptValue(scriptState, value); |
623 } | 632 } |
624 } | 633 } |
625 | 634 |
626 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc
riptSourceCode&) | 635 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc
riptSourceCode&) |
627 { | 636 { |
628 return PassOwnPtr<ScriptSourceCode>(); | 637 return PassOwnPtr<ScriptSourceCode>(); |
629 } | 638 } |
630 | 639 |
631 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) |
632 { | 641 { |
633 return source; | 642 return source; |
634 } | 643 } |
635 | 644 |
636 } // namespace WebCore | 645 } // namespace WebCore |
OLD | NEW |