Changeset 58402 in webkit


Ignore:
Timestamp:
Apr 28, 2010 4:39:03 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-28 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Support pause on exceptions in v8 implementation of ScriptDebugServer.

https://bugs.webkit.org/show_bug.cgi?id=38205

  • bindings/v8/ScriptDebugServer.cpp: (WebCore::ScriptDebugServer::addListener): (WebCore::ScriptDebugServer::pauseOnExceptionsState): (WebCore::ScriptDebugServer::setPauseOnExceptionsState): (WebCore::ScriptDebugServer::currentCallFrame): (WebCore::ScriptDebugServer::handleV8DebugMessage): (WebCore::ScriptDebugServer::dispatchDidParseSource):
  • bindings/v8/ScriptDebugServer.h:

2010-04-28 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Support pause on exceptions in v8 implementation of ScriptDebugServer.

https://bugs.webkit.org/show_bug.cgi?id=38205

  • src/js/DebuggerScript.js: (debuggerScriptConstructor.DebuggerScript.getScripts): (debuggerScriptConstructor.DebuggerScript.pauseOnExceptionsState): (debuggerScriptConstructor.DebuggerScript.setPauseOnExceptionsState): (debuggerScriptConstructor.DebuggerScript._v8ToWebkitLineNumber): (debuggerScriptConstructor):
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58400 r58402  
     12010-04-28  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Support pause on exceptions in v8 implementation of ScriptDebugServer.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=38205       
     8
     9        * bindings/v8/ScriptDebugServer.cpp:
     10        (WebCore::ScriptDebugServer::addListener):
     11        (WebCore::ScriptDebugServer::pauseOnExceptionsState):
     12        (WebCore::ScriptDebugServer::setPauseOnExceptionsState):
     13        (WebCore::ScriptDebugServer::currentCallFrame):
     14        (WebCore::ScriptDebugServer::handleV8DebugMessage):
     15        (WebCore::ScriptDebugServer::dispatchDidParseSource):
     16        * bindings/v8/ScriptDebugServer.h:
     17
    1182010-04-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    219
  • trunk/WebCore/bindings/v8/ScriptDebugServer.cpp

    r57812 r58402  
    8282    V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame());
    8383    v8::Local<v8::Context> context = proxy->mainWorldContext();
    84     String contextData = toWebCoreStringWithNullCheck(context->GetData());
    85     m_contextDataMap.set(listener, contextData);
    8684
    8785    v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts")));
    88     v8::Handle<v8::Value> value = v8::Debug::Call(getScriptsFunction);
     86    v8::Handle<v8::Value> argv[] = { context->GetData() };
     87    v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv);
    8988    if (value.IsEmpty())
    9089        return;
     
    176175}
    177176
     177ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState()
     178{
     179#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
     180    ensureDebuggerScriptCompiled();
     181    v8::HandleScope scope;
     182    v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
     183
     184    v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("pauseOnExceptionsState")));
     185    v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() };
     186    v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 0, argv);
     187    return static_cast<ScriptDebugServer::PauseOnExceptionsState>(result->Int32Value());
     188#else
     189    return DontPauseOnExceptions;
     190#endif
     191}
     192
     193void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
     194{
     195#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
     196    ensureDebuggerScriptCompiled();
     197    v8::HandleScope scope;
     198    v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
     199
     200    v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setPauseOnExceptionsState")));
     201    v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) };
     202    currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
     203#endif
     204}
     205
    178206void ScriptDebugServer::continueProgram()
    179207{
     
    217245}
    218246
    219 v8::Handle<v8::Value> ScriptDebugServer::currentCallFrameV8()
    220 {
    221 #if ENABLE(V8_SCRIPT_DEBUG_SERVER)
    222     if (!m_currentCallFrame.get().IsEmpty())
    223         return m_currentCallFrame.get();
    224 
    225     // Check on a bp.
    226     v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));
    227     v8::Handle<v8::Value> argv[] = { m_executionState.get() };
    228     v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
    229     m_currentCallFrame.set(result);
    230     return result;
    231 #else
    232     return v8::Handle<v8::Value>();
    233 #endif
    234 }
    235 
    236247PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame()
    237248{
    238     return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8()));
     249    if (!m_currentCallFrame) {
     250        v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));
     251        v8::Handle<v8::Value> argv[] = { m_executionState.get() };
     252        v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
     253        m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8));
     254    }
     255    return m_currentCallFrame;
    239256}
    240257
     
    269286
    270287    // Ignore unsupported event types.
    271     if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break)
     288    if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception)
    272289        return;
    273290
     
    287304        return;
    288305
     306    bool handled = false;
    289307    Frame* frame = V8Proxy::retrieveFrame(context);
    290308    if (frame) {
     
    292310        if (listener) {
    293311            if (message.GetEvent() == v8::AfterCompile) {
     312                handled = true;
    294313                v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
    295314                v8::Local<v8::Object> args = v8::Object::New();
     
    301320                v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
    302321                dispatchDidParseSource(listener, object);
    303             } else if (message.GetEvent() == v8::Break) {
     322            } else if (message.GetEvent() == v8::Break || message.GetEvent() == v8::Exception) {
     323                handled = true;
    304324                m_executionState.set(message.GetExecutionState());
    305325                m_currentCallFrameState = mainWorldScriptState(frame);
     
    309329        }
    310330    }
     331
     332    if (!handled && !message.WillStartRunning())
     333        continueProgram();
    311334}
    312335
    313336void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object)
    314337{
    315     String contextData = toWebCoreStringWithNullCheck(object->Get(v8::String::New("contextData")));
    316     if (contextData != m_contextDataMap.get(listener))
    317         return;
    318 
    319338    listener->didParseSource(
    320339        toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))),
  • trunk/WebCore/bindings/v8/ScriptDebugServer.h

    r57812 r58402  
    3434#if ENABLE(JAVASCRIPT_DEBUGGER)
    3535
    36 #include "OwnHandle.h"
     36#include "JavaScriptCallFrame.h"
    3737#include "PlatformString.h"
    3838#include "ScriptBreakpoint.h"
     
    4646namespace WebCore {
    4747
    48 class JavaScriptCallFrame;
    4948class Page;
    5049class ScriptDebugListener;
     
    7675        PauseOnUncaughtExceptions
    7776    };
    78     PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; }
    79     void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) { m_pauseOnExceptionsState = pauseOnExceptionsState; }
     77    PauseOnExceptionsState pauseOnExceptionsState();
     78    void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState);
    8079
    8180    void pauseProgram() { }
     
    9897    static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler messageLoopDispatchHandler) { s_messageLoopDispatchHandler = messageLoopDispatchHandler; }
    9998
    100     v8::Handle<v8::Value> currentCallFrameV8();
    10199    PassRefPtr<JavaScriptCallFrame> currentCallFrame();
    102100
     
    131129    typedef HashMap<Page*, ScriptDebugListener*> ListenersMap;
    132130    ListenersMap m_listenersMap;
    133     typedef HashMap<ScriptDebugListener*, String> ContextDataMap;
    134     ContextDataMap m_contextDataMap;
    135131    String m_debuggerScriptSource;
    136132    PauseOnExceptionsState m_pauseOnExceptionsState;
    137133    OwnHandle<v8::Object> m_debuggerScript;
    138134    ScriptState* m_currentCallFrameState;
    139     OwnHandle<v8::Value> m_currentCallFrame;
     135    RefPtr<JavaScriptCallFrame> m_currentCallFrame;
    140136    OwnHandle<v8::Object> m_executionState;
    141137
  • trunk/WebKit/chromium/ChangeLog

    r58382 r58402  
     12010-04-28  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Support pause on exceptions in v8 implementation of ScriptDebugServer.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=38205       
     8
     9        * src/js/DebuggerScript.js:
     10        (debuggerScriptConstructor.DebuggerScript.getScripts):
     11        (debuggerScriptConstructor.DebuggerScript.pauseOnExceptionsState):
     12        (debuggerScriptConstructor.DebuggerScript.setPauseOnExceptionsState):
     13        (debuggerScriptConstructor.DebuggerScript._v8ToWebkitLineNumber):
     14        (debuggerScriptConstructor):
     15
    1162010-04-27  Jens Alfke  <snej@chromium.org>
    217
  • trunk/WebKit/chromium/src/js/DebuggerScript.js

    r57812 r58402  
    3434DebuggerScript._breakpoints = {};
    3535
     36DebuggerScript.PauseOnExceptionsState = {
     37    DontPauseOnExceptions : 0,
     38    PauseOnAllExceptions : 1,
     39    PauseOnUncaughtExceptions: 2
     40};
     41
     42DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
     43Debug.clearBreakOnException();
     44Debug.clearBreakOnUncaughtException();
    3645
    3746DebuggerScript.getAfterCompileScript = function(execState, args)
     
    4049}
    4150
    42 DebuggerScript.getScripts = function(execState, args)
     51DebuggerScript.getScripts = function(contextData)
    4352{
    4453    var scripts = Debug.scripts();
    4554    var result = [];
    4655    for (var i = 0; i < scripts.length; ++i) {
    47         result.push(DebuggerScript._formatScript(scripts[i]));
     56        var script = scripts[i];
     57        if (contextData === script.context_data)
     58            result.push(DebuggerScript._formatScript(script));
    4859    }
    4960    return result;
     
    93104}
    94105
     106DebuggerScript.pauseOnExceptionsState = function()
     107{
     108    return DebuggerScript._pauseOnExceptionsState;
     109}
     110
     111DebuggerScript.setPauseOnExceptionsState = function(newState)
     112{
     113    DebuggerScript._pauseOnExceptionsState = newState;
     114
     115    if (DebuggerScript.PauseOnExceptionsState.PauseOnAllExceptions === newState)
     116        Debug.setBreakOnException();
     117    else
     118        Debug.clearBreakOnException();
     119
     120    if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newState)
     121        Debug.setBreakOnUncaughtException();
     122    else
     123        Debug.clearBreakOnUncaughtException();
     124}
     125
    95126DebuggerScript.currentCallFrame = function(execState, args)
    96127{
     
    161192   
    162193    // Get line number.
    163     var line = DebuggerScript._v8ToWwebkitLineNumber(frameMirror.sourceLine());
     194    var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine());
    164195   
    165196    // Get this object.
     
    202233};
    203234
    204 DebuggerScript._v8ToWwebkitLineNumber = function(line)
     235DebuggerScript._v8ToWebkitLineNumber = function(line)
    205236{
    206237    return line + 1;
Note: See TracChangeset for help on using the changeset viewer.