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

Side by Side Diff: Source/bindings/v8/ScriptDebugServer.cpp

Issue 290633009: DevTools: Show detailed information for exceptions during snippet execution. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 16 matching lines...) Expand all
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
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) 604 void ScriptDebugServer::compileScript(ScriptState* scriptState, const String& ex pression, const String& sourceURL, String* scriptId, String* exceptionMessage, i nt* 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 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge t());
617 if (lineNumber)
vsevik 2014/05/19 12:40:23 This won't be needed once default parameters are r
618 *lineNumber = message->GetLineNumber();
vsevik 2014/05/19 12:40:23 extra space
619 if (columnNumber)
620 *columnNumber = message->GetStartColumn();
621 if (stackTrace)
622 *stackTrace = createScriptCallStack(message->GetStackTrace(), Sc riptCallStack::maxCallStackSizeToCapture, m_isolate);
623 }
616 return; 624 return;
617 } 625 }
618 if (script.IsEmpty()) 626 if (script.IsEmpty())
619 return; 627 return;
620 628
621 *scriptId = String::number(script->GetId()); 629 *scriptId = String::number(script->GetId());
622 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m _isolate, script))); 630 m_compiledScripts.set(*scriptId, adoptPtr(new ScopedPersistent<v8::Script>(m _isolate, script)));
623 } 631 }
624 632
625 void ScriptDebugServer::clearCompiledScripts() 633 void ScriptDebugServer::clearCompiledScripts()
626 { 634 {
627 m_compiledScripts.clear(); 635 m_compiledScripts.clear();
628 } 636 }
629 637
630 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script Id, ScriptValue* result, bool* wasThrown, String* exceptionMessage) 638 void ScriptDebugServer::runScript(ScriptState* scriptState, const String& script Id, ScriptValue* result, bool* wasThrown, String* exceptionMessage, int* lineNum ber, int* columnNumber, RefPtr<ScriptCallStack>* stackTrace)
631 { 639 {
632 if (!m_compiledScripts.contains(scriptId)) 640 if (!m_compiledScripts.contains(scriptId))
633 return; 641 return;
634 v8::HandleScope handleScope(m_isolate); 642 v8::HandleScope handleScope(m_isolate);
635 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId) ; 643 ScopedPersistent<v8::Script>* scriptHandle = m_compiledScripts.get(scriptId) ;
636 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate); 644 v8::Local<v8::Script> script = scriptHandle->newLocal(m_isolate);
637 m_compiledScripts.remove(scriptId); 645 m_compiledScripts.remove(scriptId);
638 if (script.IsEmpty()) 646 if (script.IsEmpty())
639 return; 647 return;
640 648
641 if (scriptState->contextIsEmpty()) 649 if (scriptState->contextIsEmpty())
642 return; 650 return;
643 ScriptState::Scope scope(scriptState); 651 ScriptState::Scope scope(scriptState);
644 v8::TryCatch tryCatch; 652 v8::TryCatch tryCatch;
645 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip tState->executionContext(), m_isolate); 653 v8::Local<v8::Value> value = V8ScriptRunner::runCompiledScript(script, scrip tState->executionContext(), m_isolate);
646 *wasThrown = false; 654 *wasThrown = false;
647 if (tryCatch.HasCaught()) { 655 if (tryCatch.HasCaught()) {
648 *wasThrown = true; 656 *wasThrown = true;
649 *result = ScriptValue(scriptState, tryCatch.Exception()); 657 *result = ScriptValue(scriptState, tryCatch.Exception());
650 v8::Local<v8::Message> message = tryCatch.Message(); 658 v8::Local<v8::Message> message = tryCatch.Message();
651 if (!message.IsEmpty()) 659 if (!message.IsEmpty()) {
652 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge t()); 660 *exceptionMessage = toCoreStringWithUndefinedOrNullCheck(message->Ge t());
661 if (lineNumber)
662 *lineNumber = message->GetLineNumber();
vsevik 2014/05/19 12:40:23 ditto
663 if (columnNumber)
664 *columnNumber = message->GetStartColumn();
665 if (stackTrace)
666 *stackTrace = createScriptCallStack(message->GetStackTrace(), Sc riptCallStack::maxCallStackSizeToCapture, m_isolate);
667 }
653 } else { 668 } else {
654 *result = ScriptValue(scriptState, value); 669 *result = ScriptValue(scriptState, value);
655 } 670 }
656 } 671 }
657 672
658 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc riptSourceCode&) 673 PassOwnPtr<ScriptSourceCode> ScriptDebugServer::preprocess(LocalFrame*, const Sc riptSourceCode&)
659 { 674 {
660 return PassOwnPtr<ScriptSourceCode>(); 675 return PassOwnPtr<ScriptSourceCode>();
661 } 676 }
662 677
663 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName) 678 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName)
664 { 679 {
665 return source; 680 return source;
666 } 681 }
667 682
668 } // namespace WebCore 683 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698