From: sgjesse@gmail.com Date: Fri, 29 Aug 2008 12:04:25 +0000 (+0000) Subject: Removed the implicit call to DebugBreak when receiving debugger commands X-Git-Tag: upstream/4.7.83~25503 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d4d692ec7342344d20805f67028a27e90763d4c;p=platform%2Fupstream%2Fv8.git Removed the implicit call to DebugBreak when receiving debugger commands while V8 is running. A debugger using the V8 message based interface now needs to control the call to DebugBreak in order for the messages send to be processed. Commands can still be send when V8 is not in a break, but they will not be processed until there is a break. The response "request queued" when queuing up messages have been removed. This gets rid of a non JSON message being used. Modified the threaded debugger tests to call DebugBreak instead of relying on it occouring automatically. This change will not be committed until the outstanding Chrome change http://chrome-reviews.prom.corp.google.com/2072 (which updates Chrome to control the DebugBreak call) have been reviewed and committed. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@47 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/debug-delay.js b/src/debug-delay.js index e68dafa..19461df 100644 --- a/src/debug-delay.js +++ b/src/debug-delay.js @@ -366,24 +366,6 @@ function ProcessDebugRequest(exec_state, request, stopping) { } -// Helper function to check whether the JSON request is a plain break request. -// This is used form the runtime handling of pending debug requests. If one of -// the pending requests is a plain break execution should be broken after -// processing the pending break requests. -function IsPlainBreakRequest(json_request) { - try { - // Convert the JSON string to an object. - request = %CompileString('(' + json_request + ')', false)(); - - // Check for break command without arguments. - return request.command && request.command == "break" && !request.arguments; - } catch (e) { - // If there is a exception parsing the JSON request just return false. - return false; - } -} - - Debug.addListener = function(listener, opt_data) { if (!IS_FUNCTION(listener)) throw new Error('Parameters have wrong types.'); %AddDebugEventListener(listener, opt_data); diff --git a/src/debug.cc b/src/debug.cc index 45cf7b7..8ba4490 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1423,28 +1423,6 @@ Handle Debugger::ProcessRequest(Handle exec_state, } -bool Debugger::IsPlainBreakRequest(Handle request) { - // Get the function IsPlainBreakRequest (defined in debug.js). - Handle process_debug_request = - Handle(JSFunction::cast( - Debug::debug_context()->global()->GetProperty( - *Factory::LookupAsciiSymbol("IsPlainBreakRequest")))); - - // Call ProcessDebugRequest expect String result. - bool caught_exception; - const int argc = 1; - Object** argv[argc] = { request.location() }; - Handle result = Execution::TryCall(process_debug_request, - Factory::undefined_value(), - argc, argv, - &caught_exception); - if (caught_exception) { - return false; - } - return *result == Heap::true_value(); -} - - void Debugger::OnException(Handle exception, bool uncaught) { HandleScope scope; @@ -1785,21 +1763,6 @@ void DebugMessageThread::SetEventJSONFromEvent(Handle event_data) { } -// Compare a two byte string to an null terminated ASCII string. -bool DebugMessageThread::TwoByteEqualsAscii(Vector two_byte, - const char* ascii) { - for (int i = 0; i < two_byte.length(); i++) { - if (ascii[i] == '\0') { - return false; - } - if (two_byte[i] != static_cast(ascii[i])) { - return false; - } - } - return ascii[two_byte.length()] == '\0'; -} - - void DebugMessageThread::Run() { // Sends debug events to an installed debugger message callback. while (true) { @@ -1858,60 +1821,6 @@ void DebugMessageThread::DebugEvent(v8::DebugEvent event, return; } - // First process all pending commands in the queue. During this processing - // each message is checked to see if it is a plain break command. If there is - // a plain break request in the queue or if the queue is empty a break event - // is sent to the debugger. - bool plain_break = false; - if (command_queue_.IsEmpty()) { - plain_break = true; - } else { - // Drain queue. - while (!command_queue_.IsEmpty()) { - command_received_->Wait(); - Logger::DebugTag("Get command from command_queue, in drain queue loop."); - Vector command = command_queue_.Get(); - // Support for sending a break command as just "break" instead of an - // actual JSON break command. - // If break is made into a separate API call, function - // TwoByteEqualsASCII can be removed. - if (TwoByteEqualsAscii(command, "break")) { - plain_break = true; - continue; - } - - // Get the command as a string object. - Handle command_string; - if (!command.is_empty()) { - command_string = Factory::NewStringFromTwoByte( - Vector( - reinterpret_cast( - command.start()), - command.length())); - } else { - command_string = Handle(); - } - - // Process the request. - Handle message_string = Debugger::ProcessRequest(exec_state, - command_string, - false); - // Convert text result to UTF-16 string and send it. - v8::String::Value val(Utils::ToLocal(message_string)); - Vector message(reinterpret_cast(*val), - message_string->length()); - SendMessage(message); - - // Check whether one of the commands is a plain break request. - if (!plain_break) { - plain_break = Debugger::IsPlainBreakRequest(message_string); - } - } - } - - // If this break event is not to go to the debugger just return. - if (!plain_break) return; - // Notify the debugger that a debug event has occoured. host_running_ = false; SetEventJSONFromEvent(event_data); @@ -1998,13 +1907,6 @@ void DebugMessageThread::ProcessCommand(Vector command) { Vector command_copy = command.Clone(); Logger::DebugTag("Put command on command_queue."); command_queue_.Put(command_copy); - // If not in a break schedule a break and send the "request queued" response. - if (host_running_) { - v8::Debug::DebugBreak(); - uint16_t buffer[14] = {'r', 'e', 'q', 'u', 'e', 's', 't', ' ', - 'q', 'u', 'e', 'u', 'e', 'd'}; - SendMessage(Vector(buffer, 14)); - } command_received_->Signal(); } diff --git a/src/debug.h b/src/debug.h index 42c8435..951acd5 100644 --- a/src/debug.h +++ b/src/debug.h @@ -346,8 +346,6 @@ class Debugger { static Handle ProcessRequest(Handle exec_state, Handle request, bool stopped); - static bool IsPlainBreakRequest(Handle request); - static void OnDebugBreak(Handle break_points_hit); static void OnException(Handle exception, bool uncaught); static void OnBeforeCompile(Handle