ScriptDebugServer.h [plain text]
#ifndef ScriptDebugServer_h
#define ScriptDebugServer_h
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "OwnHandle.h"
#include "PlatformString.h"
#include "ScriptBreakpoint.h"
#include "Timer.h"
#include <v8-debug.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class ScriptDebugListener;
class ScriptValue;
class ScriptDebugServer {
WTF_MAKE_NONCOPYABLE(ScriptDebugServer);
public:
String setBreakpoint(const String& sourceID, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber);
void removeBreakpoint(const String& breakpointId);
void clearBreakpoints();
void setBreakpointsActivated(bool activated);
void activateBreakpoints() { setBreakpointsActivated(true); }
void deactivateBreakpoints() { setBreakpointsActivated(false); }
enum PauseOnExceptionsState {
DontPauseOnExceptions,
PauseOnAllExceptions,
PauseOnUncaughtExceptions
};
PauseOnExceptionsState pauseOnExceptionsState();
void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState);
void setPauseOnNextStatement(bool pause);
void breakProgram();
void continueProgram();
void stepIntoStatement();
void stepOverStatement();
void stepOutOfFunction();
bool editScriptSource(const String& sourceID, const String& newContent, String* error, ScriptValue* newCallFrames);
void recompileAllJSFunctionsSoon() { }
void recompileAllJSFunctions(Timer<ScriptDebugServer>* = 0) { }
class Task {
public:
virtual ~Task() { }
virtual void run() = 0;
};
static void interruptAndRun(PassOwnPtr<Task>);
void runPendingTasks();
protected:
ScriptDebugServer();
~ScriptDebugServer() { }
ScriptValue currentCallFrame();
virtual ScriptDebugListener* getDebugListenerForContext(v8::Handle<v8::Context>) = 0;
virtual void runMessageLoopOnPause(v8::Handle<v8::Context>) = 0;
virtual void quitMessageLoopOnPause() = 0;
static v8::Handle<v8::Value> breakProgramCallback(const v8::Arguments& args);
void breakProgram(v8::Handle<v8::Object> executionState, v8::Handle<v8::Value> exception);
static void v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails);
void handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails);
void dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> sourceObject);
void ensureDebuggerScriptCompiled();
bool isPaused();
PauseOnExceptionsState m_pauseOnExceptionsState;
OwnHandle<v8::Object> m_debuggerScript;
OwnHandle<v8::Object> m_executionState;
v8::Local<v8::Context> m_pausedContext;
bool m_breakpointsActivated;
OwnHandle<v8::FunctionTemplate> m_breakProgramCallbackTemplate;
};
}
#endif // ENABLE(JAVASCRIPT_DEBUGGER)
#endif // ScriptDebugServer_h