Commit 974734be authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Reverting 1811.

Review URL: http://codereview.chromium.org/99175

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1812 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 95288e91
...@@ -91,55 +91,6 @@ class EXPORT Debug { ...@@ -91,55 +91,6 @@ class EXPORT Debug {
}; };
/**
* A message object passed to the debug message handler.
*/
class Message {
public:
/**
* Check type of message.
*/
virtual bool IsEvent() const = 0;
virtual bool IsResponse() const = 0;
virtual DebugEvent GetEvent() const = 0;
/**
* Indicate whether this is a response to a continue command which will
* start the VM running after this is processed.
*/
virtual bool WillStartRunning() const = 0;
/**
* Access to execution state and event data. Don't store these cross
* callbacks as their content becomes invalid. These objects are from the
* debugger event that started the debug message loop.
*/
virtual Handle<Object> GetExecutionState() const = 0;
virtual Handle<Object> GetEventData() const = 0;
/**
* Get the debugger protocol JSON.
*/
virtual Handle<String> GetJSON() const = 0;
/**
* Get the context active when the debug event happened. Note this is not
* the current active context as the JavaScript part of the debugger is
* running in it's own context which is entered at this point.
*/
virtual Handle<Context> GetEventContext() const = 0;
/**
* Client data passed with the corresponding request if any. This is the
* client_data data value passed into Debug::SendCommand along with the
* request that led to the message or NULL if the message is an event. The
* debugger takes ownership of the data and will delete it even if there is
* no message handler.
*/
virtual ClientData* GetClientData() const = 0;
};
/** /**
* Debug event callback function. * Debug event callback function.
* *
...@@ -150,22 +101,26 @@ class EXPORT Debug { ...@@ -150,22 +101,26 @@ class EXPORT Debug {
* \param data value passed by the user to SetDebugEventListener * \param data value passed by the user to SetDebugEventListener
*/ */
typedef void (*EventCallback)(DebugEvent event, typedef void (*EventCallback)(DebugEvent event,
Handle<Object> exec_state, Handle<Object> exec_state,
Handle<Object> event_data, Handle<Object> event_data,
Handle<Value> data); Handle<Value> data);
/** /**
* Debug message callback function. * Debug message callback function.
* *
* \param message the debug message handler message object * \param message the debug message
* \param length length of the message * \param length length of the message
* \param data the data value passed when registering the message handler * \param data the data value passed when registering the message handler
* \param client_data the data value passed into Debug::SendCommand along
* with the request that led to the message or NULL if the message is an
* asynchronous event. The debugger takes ownership of the data and will
* delete it before dying even if there is no message handler.
* A MessageHandler does not take posession of the message string, * A MessageHandler does not take posession of the message string,
* and must not rely on the data persisting after the handler returns. * and must not rely on the data persisting after the handler returns.
*/ */
typedef void (*MessageHandler)(const Message& message); typedef void (*MessageHandler)(const uint16_t* message, int length,
ClientData* client_data);
/** /**
* Debug host dispatch callback function. * Debug host dispatch callback function.
......
...@@ -34,8 +34,9 @@ namespace v8 { namespace internal { ...@@ -34,8 +34,9 @@ namespace v8 { namespace internal {
// Public V8 debugger API message handler function. This function just delegates // Public V8 debugger API message handler function. This function just delegates
// to the debugger agent through it's data parameter. // to the debugger agent through it's data parameter.
void DebuggerAgentMessageHandler(const v8::Debug::Message& message) { void DebuggerAgentMessageHandler(const uint16_t* message, int length,
DebuggerAgent::instance_->DebuggerMessage(message); v8::Debug::ClientData* client_data) {
DebuggerAgent::instance_->DebuggerMessage(message, length);
} }
// static // static
...@@ -124,14 +125,13 @@ void DebuggerAgent::CloseSession() { ...@@ -124,14 +125,13 @@ void DebuggerAgent::CloseSession() {
} }
void DebuggerAgent::DebuggerMessage(const v8::Debug::Message& message) { void DebuggerAgent::DebuggerMessage(const uint16_t* message, int length) {
ScopedLock with(session_access_); ScopedLock with(session_access_);
// Forward the message handling to the session. // Forward the message handling to the session.
if (session_ != NULL) { if (session_ != NULL) {
v8::String::Value val(message.GetJSON()); session_->DebuggerMessage(Vector<uint16_t>(const_cast<uint16_t*>(message),
session_->DebuggerMessage(Vector<uint16_t>(const_cast<uint16_t*>(*val), length));
val.length()));
} }
} }
......
...@@ -60,7 +60,7 @@ class DebuggerAgent: public Thread { ...@@ -60,7 +60,7 @@ class DebuggerAgent: public Thread {
private: private:
void Run(); void Run();
void CreateSession(Socket* socket); void CreateSession(Socket* socket);
void DebuggerMessage(const v8::Debug::Message& message); void DebuggerMessage(const uint16_t* message, int length);
void CloseSession(); void CloseSession();
void OnSessionClosed(DebuggerAgentSession* session); void OnSessionClosed(DebuggerAgentSession* session);
...@@ -75,7 +75,8 @@ class DebuggerAgent: public Thread { ...@@ -75,7 +75,8 @@ class DebuggerAgent: public Thread {
static DebuggerAgent* instance_; static DebuggerAgent* instance_;
friend class DebuggerAgentSession; friend class DebuggerAgentSession;
friend void DebuggerAgentMessageHandler(const v8::Debug::Message& message); friend void DebuggerAgentMessageHandler(const uint16_t* message, int length,
v8::Debug::ClientData* client_data);
DISALLOW_COPY_AND_ASSIGN(DebuggerAgent); DISALLOW_COPY_AND_ASSIGN(DebuggerAgent);
}; };
......
This diff is collapsed.
...@@ -401,54 +401,6 @@ class Debug { ...@@ -401,54 +401,6 @@ class Debug {
}; };
// Message delivered to the message handler callback. This is either a debugger
// event or the response to a command.
class MessageImpl: public v8::Debug::Message {
public:
// Create a message object for a debug event.
static MessageImpl NewEvent(DebugEvent event,
bool running,
Handle<JSObject> exec_state,
Handle<JSObject> event_data);
// Create a message object for the response to a debug command.
static MessageImpl NewResponse(DebugEvent event,
bool running,
Handle<JSObject> exec_state,
Handle<JSObject> event_data,
Handle<String> response_json,
v8::Debug::ClientData* client_data);
// Implementation of interface v8::Debug::Message.
virtual bool IsEvent() const;
virtual bool IsResponse() const;
virtual DebugEvent GetEvent() const;
virtual bool WillStartRunning() const;
virtual v8::Handle<v8::Object> GetExecutionState() const;
virtual v8::Handle<v8::Object> GetEventData() const;
virtual v8::Handle<v8::String> GetJSON() const;
virtual v8::Handle<v8::Context> GetEventContext() const;
virtual v8::Debug::ClientData* GetClientData() const;
private:
MessageImpl(bool is_event,
DebugEvent event,
bool running,
Handle<JSObject> exec_state,
Handle<JSObject> event_data,
Handle<String> response_json,
v8::Debug::ClientData* client_data);
bool is_event_; // Does this message represent a debug event?
DebugEvent event_; // Debug event causing the break.
bool running_; // Will the VM start running after this event?
Handle<JSObject> exec_state_; // Current execution state.
Handle<JSObject> event_data_; // Data associated with the event.
Handle<String> response_json_; // Response JSON if message holds a response.
v8::Debug::ClientData* client_data_; // Client data passed with the request.
};
// Message send by user to v8 debugger or debugger output message. // Message send by user to v8 debugger or debugger output message.
// In addition to command text it may contain a pointer to some user data // In addition to command text it may contain a pointer to some user data
// which are expected to be passed along with the command reponse to message // which are expected to be passed along with the command reponse to message
...@@ -539,11 +491,11 @@ class Debugger { ...@@ -539,11 +491,11 @@ class Debugger {
Handle<JSFunction> fun); Handle<JSFunction> fun);
static void OnNewFunction(Handle<JSFunction> fun); static void OnNewFunction(Handle<JSFunction> fun);
static void ProcessDebugEvent(v8::DebugEvent event, static void ProcessDebugEvent(v8::DebugEvent event,
Handle<JSObject> event_data, Handle<Object> event_data,
bool auto_continue); bool auto_continue);
static void NotifyMessageHandler(v8::DebugEvent event, static void NotifyMessageHandler(v8::DebugEvent event,
Handle<JSObject> exec_state, Handle<Object> exec_state,
Handle<JSObject> event_data, Handle<Object> event_data,
bool auto_continue); bool auto_continue);
static void SetEventListener(Handle<Object> callback, Handle<Object> data); static void SetEventListener(Handle<Object> callback, Handle<Object> data);
static void SetMessageHandler(v8::Debug::MessageHandler handler); static void SetMessageHandler(v8::Debug::MessageHandler handler);
...@@ -551,7 +503,11 @@ class Debugger { ...@@ -551,7 +503,11 @@ class Debugger {
int period); int period);
// Invoke the message handler function. // Invoke the message handler function.
static void InvokeMessageHandler(MessageImpl message); static void InvokeMessageHandler(v8::Handle<v8::String> output,
v8::Debug::ClientData* data);
// Send the JSON message for a debug event.
static bool InvokeMessageHandlerWithEvent(Handle<Object> event_data);
// Add a debugger command to the command queue. // Add a debugger command to the command queue.
static void ProcessCommand(Vector<const uint16_t> command, static void ProcessCommand(Vector<const uint16_t> command,
......
...@@ -3427,10 +3427,10 @@ class MessageQueueDebuggerThread : public v8::internal::Thread { ...@@ -3427,10 +3427,10 @@ class MessageQueueDebuggerThread : public v8::internal::Thread {
void Run(); void Run();
}; };
static void MessageHandler(const v8::Debug::Message& message) { static void MessageHandler(const uint16_t* message, int length,
v8::Debug::ClientData* client_data) {
static char print_buffer[1000]; static char print_buffer[1000];
v8::String::Value json(message.GetJSON()); Utf16ToAscii(message, length, print_buffer);
Utf16ToAscii(*json, json.length(), print_buffer);
if (IsBreakEventMessage(print_buffer)) { if (IsBreakEventMessage(print_buffer)) {
// Lets test script wait until break occurs to send commands. // Lets test script wait until break occurs to send commands.
// Signals when a break is reported. // Signals when a break is reported.
...@@ -3612,8 +3612,10 @@ TEST(MessageQueueExpandAndDestroy) { ...@@ -3612,8 +3612,10 @@ TEST(MessageQueueExpandAndDestroy) {
static int handled_client_data_instances_count = 0; static int handled_client_data_instances_count = 0;
static void MessageHandlerCountingClientData( static void MessageHandlerCountingClientData(
const v8::Debug::Message& message) { const uint16_t* message,
if (message.GetClientData() != NULL) { int length,
v8::Debug::ClientData* client_data) {
if (client_data) {
handled_client_data_instances_count++; handled_client_data_instances_count++;
} }
} }
...@@ -3689,10 +3691,10 @@ static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) { ...@@ -3689,10 +3691,10 @@ static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) {
} }
static void ThreadedMessageHandler(const v8::Debug::Message& message) { static void ThreadedMessageHandler(const uint16_t* message, int length,
v8::Debug::ClientData* client_data) {
static char print_buffer[1000]; static char print_buffer[1000];
v8::String::Value json(message.GetJSON()); Utf16ToAscii(message, length, print_buffer);
Utf16ToAscii(*json, json.length(), print_buffer);
if (IsBreakEventMessage(print_buffer)) { if (IsBreakEventMessage(print_buffer)) {
threaded_debugging_barriers.barrier_2.Wait(); threaded_debugging_barriers.barrier_2.Wait();
} }
...@@ -3786,10 +3788,11 @@ class BreakpointsDebuggerThread : public v8::internal::Thread { ...@@ -3786,10 +3788,11 @@ class BreakpointsDebuggerThread : public v8::internal::Thread {
Barriers* breakpoints_barriers; Barriers* breakpoints_barriers;
static void BreakpointsMessageHandler(const v8::Debug::Message& message) { static void BreakpointsMessageHandler(const uint16_t* message,
int length,
v8::Debug::ClientData* client_data) {
static char print_buffer[1000]; static char print_buffer[1000];
v8::String::Value json(message.GetJSON()); Utf16ToAscii(message, length, print_buffer);
Utf16ToAscii(*json, json.length(), print_buffer);
printf("%s\n", print_buffer); printf("%s\n", print_buffer);
fflush(stdout); fflush(stdout);
...@@ -3932,7 +3935,9 @@ TEST(SetDebugEventListenerOnUninitializedVM) { ...@@ -3932,7 +3935,9 @@ TEST(SetDebugEventListenerOnUninitializedVM) {
} }
static void DummyMessageHandler(const v8::Debug::Message& message) { static void DummyMessageHandler(const uint16_t* message,
int length,
v8::Debug::ClientData* client_data) {
} }
...@@ -4157,7 +4162,9 @@ TEST(DebuggerUnload) { ...@@ -4157,7 +4162,9 @@ TEST(DebuggerUnload) {
// Debugger message handler which counts the number of times it is called. // Debugger message handler which counts the number of times it is called.
static int message_handler_hit_count = 0; static int message_handler_hit_count = 0;
static void MessageHandlerHitCount(const v8::Debug::Message& message) { static void MessageHandlerHitCount(const uint16_t* message,
int length,
v8::Debug::ClientData* client_data) {
message_handler_hit_count++; message_handler_hit_count++;
const int kBufferSize = 1000; const int kBufferSize = 1000;
...@@ -4206,7 +4213,9 @@ TEST(DebuggerClearMessageHandler) { ...@@ -4206,7 +4213,9 @@ TEST(DebuggerClearMessageHandler) {
// Debugger message handler which clears the message handler while active. // Debugger message handler which clears the message handler while active.
static void MessageHandlerClearingMessageHandler( static void MessageHandlerClearingMessageHandler(
const v8::Debug::Message& message) { const uint16_t* message,
int length,
v8::Debug::ClientData* client_data) {
message_handler_hit_count++; message_handler_hit_count++;
// Clear debug message handler. // Clear debug message handler.
...@@ -4253,10 +4262,11 @@ class HostDispatchDebuggerThread : public v8::internal::Thread { ...@@ -4253,10 +4262,11 @@ class HostDispatchDebuggerThread : public v8::internal::Thread {
Barriers* host_dispatch_barriers; Barriers* host_dispatch_barriers;
static void HostDispatchMessageHandler(const v8::Debug::Message& message) { static void HostDispatchMessageHandler(const uint16_t* message,
int length,
v8::Debug::ClientData* client_data) {
static char print_buffer[1000]; static char print_buffer[1000];
v8::String::Value json(message.GetJSON()); Utf16ToAscii(message, length, print_buffer);
Utf16ToAscii(*json, json.length(), print_buffer);
printf("%s\n", print_buffer); printf("%s\n", print_buffer);
fflush(stdout); fflush(stdout);
} }
......
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