Commit 00f16c11 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58402 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4a831099
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 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r58313.
......@@ -81,11 +81,10 @@ void ScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
m_listenersMap.set(page, listener);
V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame());
v8::Local<v8::Context> context = proxy->mainWorldContext();
String contextData = toWebCoreStringWithNullCheck(context->GetData());
m_contextDataMap.set(listener, contextData);
v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts")));
v8::Handle<v8::Value> value = v8::Debug::Call(getScriptsFunction);
v8::Handle<v8::Value> argv[] = { context->GetData() };
v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv);
if (value.IsEmpty())
return;
ASSERT(!value->IsUndefined() && value->IsArray());
......@@ -175,6 +174,35 @@ void ScriptDebugServer::setBreakpointsActivated(bool enabled)
#endif
}
ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState()
{
#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
ensureDebuggerScriptCompiled();
v8::HandleScope scope;
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("pauseOnExceptionsState")));
v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() };
v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 0, argv);
return static_cast<ScriptDebugServer::PauseOnExceptionsState>(result->Int32Value());
#else
return DontPauseOnExceptions;
#endif
}
void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
{
#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
ensureDebuggerScriptCompiled();
v8::HandleScope scope;
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setPauseOnExceptionsState")));
v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) };
currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
#endif
}
void ScriptDebugServer::continueProgram()
{
#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
......@@ -216,26 +244,15 @@ ScriptState* ScriptDebugServer::currentCallFrameState()
return m_currentCallFrameState;
}
v8::Handle<v8::Value> ScriptDebugServer::currentCallFrameV8()
{
#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
if (!m_currentCallFrame.get().IsEmpty())
return m_currentCallFrame.get();
// Check on a bp.
v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));
v8::Handle<v8::Value> argv[] = { m_executionState.get() };
v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
m_currentCallFrame.set(result);
return result;
#else
return v8::Handle<v8::Value>();
#endif
}
PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame()
{
return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8()));
if (!m_currentCallFrame) {
v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));
v8::Handle<v8::Value> argv[] = { m_executionState.get() };
v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8));
}
return m_currentCallFrame;
}
void ScriptDebugServer::onV8DebugMessage(const v8::Debug::Message& message)
......@@ -268,7 +285,7 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message)
return;
// Ignore unsupported event types.
if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break)
if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception)
return;
v8::Handle<v8::Context> context = message.GetEventContext();
......@@ -286,11 +303,13 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message)
if (global.IsEmpty())
return;
bool handled = false;
Frame* frame = V8Proxy::retrieveFrame(context);
if (frame) {
ScriptDebugListener* listener = m_listenersMap.get(frame->page());
if (listener) {
if (message.GetEvent() == v8::AfterCompile) {
handled = true;
v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
v8::Local<v8::Object> args = v8::Object::New();
args->Set(v8::String::New("eventData"), message.GetEventData());
......@@ -300,7 +319,8 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message)
ASSERT(value->IsObject());
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
dispatchDidParseSource(listener, object);
} else if (message.GetEvent() == v8::Break) {
} else if (message.GetEvent() == v8::Break || message.GetEvent() == v8::Exception) {
handled = true;
m_executionState.set(message.GetExecutionState());
m_currentCallFrameState = mainWorldScriptState(frame);
listener->didPause();
......@@ -308,14 +328,13 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message)
}
}
}
if (!handled && !message.WillStartRunning())
continueProgram();
}
void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object)
{
String contextData = toWebCoreStringWithNullCheck(object->Get(v8::String::New("contextData")));
if (contextData != m_contextDataMap.get(listener))
return;
listener->didParseSource(
toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))),
toWebCoreStringWithNullCheck(object->Get(v8::String::New("name"))),
......
......@@ -33,7 +33,7 @@
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "OwnHandle.h"
#include "JavaScriptCallFrame.h"
#include "PlatformString.h"
#include "ScriptBreakpoint.h"
#include "ScriptState.h"
......@@ -45,7 +45,6 @@
namespace WebCore {
class JavaScriptCallFrame;
class Page;
class ScriptDebugListener;
......@@ -75,8 +74,8 @@ public:
PauseOnAllExceptions,
PauseOnUncaughtExceptions
};
PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; }
void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) { m_pauseOnExceptionsState = pauseOnExceptionsState; }
PauseOnExceptionsState pauseOnExceptionsState();
void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState);
void pauseProgram() { }
void continueProgram();
......@@ -97,7 +96,6 @@ public:
typedef void (*MessageLoopDispatchHandler)(const Vector<WebCore::Page*>&);
static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler messageLoopDispatchHandler) { s_messageLoopDispatchHandler = messageLoopDispatchHandler; }
v8::Handle<v8::Value> currentCallFrameV8();
PassRefPtr<JavaScriptCallFrame> currentCallFrame();
private:
......@@ -130,13 +128,11 @@ private:
typedef HashMap<Page*, ScriptDebugListener*> ListenersMap;
ListenersMap m_listenersMap;
typedef HashMap<ScriptDebugListener*, String> ContextDataMap;
ContextDataMap m_contextDataMap;
String m_debuggerScriptSource;
PauseOnExceptionsState m_pauseOnExceptionsState;
OwnHandle<v8::Object> m_debuggerScript;
ScriptState* m_currentCallFrameState;
OwnHandle<v8::Value> m_currentCallFrame;
RefPtr<JavaScriptCallFrame> m_currentCallFrame;
OwnHandle<v8::Object> m_executionState;
static MessageLoopDispatchHandler s_messageLoopDispatchHandler;
......
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):
2010-04-27 Jens Alfke <snej@chromium.org>
Reviewed by Eric Seidel.
......
......@@ -33,18 +33,29 @@ function debuggerScriptConstructor() {
var DebuggerScript = {};
DebuggerScript._breakpoints = {};
DebuggerScript.PauseOnExceptionsState = {
DontPauseOnExceptions : 0,
PauseOnAllExceptions : 1,
PauseOnUncaughtExceptions: 2
};
DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
Debug.clearBreakOnException();
Debug.clearBreakOnUncaughtException();
DebuggerScript.getAfterCompileScript = function(execState, args)
{
return DebuggerScript._formatScript(args.eventData.script_.script_);
}
DebuggerScript.getScripts = function(execState, args)
DebuggerScript.getScripts = function(contextData)
{
var scripts = Debug.scripts();
var result = [];
for (var i = 0; i < scripts.length; ++i) {
result.push(DebuggerScript._formatScript(scripts[i]));
var script = scripts[i];
if (contextData === script.context_data)
result.push(DebuggerScript._formatScript(script));
}
return result;
}
......@@ -92,6 +103,26 @@ DebuggerScript.removeBreakpoint = function(execState, args)
delete DebuggerScript._breakpoints[key];
}
DebuggerScript.pauseOnExceptionsState = function()
{
return DebuggerScript._pauseOnExceptionsState;
}
DebuggerScript.setPauseOnExceptionsState = function(newState)
{
DebuggerScript._pauseOnExceptionsState = newState;
if (DebuggerScript.PauseOnExceptionsState.PauseOnAllExceptions === newState)
Debug.setBreakOnException();
else
Debug.clearBreakOnException();
if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newState)
Debug.setBreakOnUncaughtException();
else
Debug.clearBreakOnUncaughtException();
}
DebuggerScript.currentCallFrame = function(execState, args)
{
var frameCount = execState.frameCount();
......@@ -160,7 +191,7 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
var sourceID = script && script.id();
// Get line number.
var line = DebuggerScript._v8ToWwebkitLineNumber(frameMirror.sourceLine());
var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine());
// Get this object.
var thisObject = frameMirror.details_.receiver();
......@@ -201,7 +232,7 @@ DebuggerScript._webkitToV8LineNumber = function(line)
return line - 1;
};
DebuggerScript._v8ToWwebkitLineNumber = function(line)
DebuggerScript._v8ToWebkitLineNumber = function(line)
{
return line + 1;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment