diff options
author | sgjesse@google.com <sgjesse@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-29 11:07:40 +0000 |
---|---|---|
committer | sgjesse@google.com <sgjesse@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-29 11:07:40 +0000 |
commit | 88010e083e2d9c235120b7f8702fe82d7620b2e9 (patch) | |
tree | 985f6248f736dd86d27ab7733768ad8d2300bb1a /chrome/renderer | |
parent | 466c8a51142090c6b475d72acd380ce72a10bfe9 (diff) | |
download | chromium_src-88010e083e2d9c235120b7f8702fe82d7620b2e9.zip chromium_src-88010e083e2d9c235120b7f8702fe82d7620b2e9.tar.gz chromium_src-88010e083e2d9c235120b7f8702fe82d7620b2e9.tar.bz2 |
Made changes to the JavaScript debugger in preparing for an upcoming
change in V8 where the implicit breaks currently issued when receiving
a command while running will be removed. To get in contact with the
V8 debugging interface and send messages V8 needs to be in the break
state. Getting V8 into the break state will be the responsebility of the
debugger using the V8 debugging interface.
Changed the messages between the renderer and the debugger. There are now
explicit messages for break and detach. Alse renamed the SendToDebugger
message to DebugCommand. There is now messages DebugAttach, DebugBreak,
DebugCommand and DebugDetach. The message DebugBreak has a force flag
to indicate whether the renderer should issue some JavaScript to help
the break along or whether it should just schedule a break to happen
whenever JavaScript executes.
Removed the artificial attach JSON response send by the renderer and
replaced that with an on debug attach call to the debugger shell. This
call is reouted to the on_attach function in the debugger JavScript code.
Changed the debugger to issue break requests whenever a suitable command,
e.g. setting a break point, is issued. In this case a flag is used to
track whether execution should be automatically resumed after the command
have been send to the V8 debugger interface. Changed the handling of the
plain break event to not force a break by executing additional JavaScript.
Thereby a plain break does not break JavaScript execution until code on
the tab beeing debugged is actually executed.
Set the command name explicitly on all commands.
Removed parseSimpleCommand as it was just used for the the continue command
for which an explicit parseContinueCommand has been added.
Removed the last_command field from DebugShell as it was not used.
Updated the debugger protocol test to reflect the removed attach event.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/debug_message_handler.cc | 54 | ||||
-rw-r--r-- | chrome/renderer/debug_message_handler.h | 5 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 2 |
3 files changed, 30 insertions, 31 deletions
diff --git a/chrome/renderer/debug_message_handler.cc b/chrome/renderer/debug_message_handler.cc index f153661..7faa430 100644 --- a/chrome/renderer/debug_message_handler.cc +++ b/chrome/renderer/debug_message_handler.cc @@ -30,42 +30,31 @@ void DebugMessageHandler::EvaluateScriptUrl(const std::wstring& url) { // all methods below called from the IO thread void DebugMessageHandler::DebuggerOutput(const std::wstring& out) { - DCHECK(MessageLoop::current() != view_loop_); - // When certain commands are sent to the debugger, but we're not paused, - // it's possible that no JS is running, so these commands can't be processed. - // In these cases, we force some trivial, no side-effect, JS to be executed - // so that V8 can process the commands. - if (((out == L"break set") || (out == L"request queued")) && view_loop_) { - if (view_loop_) { - view_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &DebugMessageHandler::EvaluateScriptUrl, - std::wstring(L"javascript:void(0)"))); - } - } else if (channel_) { - channel_->Send(new ViewHostMsg_DebuggerOutput(view_routing_id_, out)); + channel_->Send(new ViewHostMsg_DebuggerOutput(view_routing_id_, out)); +} + +void DebugMessageHandler::OnBreak(bool force) { + debugger_->Break(force); + if (force && view_loop_) { + view_loop_->PostTask(FROM_HERE, NewRunnableMethod( + this, &DebugMessageHandler::EvaluateScriptUrl, + std::wstring(L"javascript:void(0)"))); } } void DebugMessageHandler::OnAttach() { - DebuggerOutput(L"{'type':'event', 'event':'attach'}"); + if (!debugger_) { + debugger_ = new Debugger(this); + } debugger_->Attach(); } -void DebugMessageHandler::OnSendToDebugger(const std::wstring& cmd) { +void DebugMessageHandler::OnCommand(const std::wstring& cmd) { if (!debugger_) { - debugger_ = new Debugger(this); - if (cmd == L"" || cmd == L"attach") { - OnAttach(); - } else { - NOTREACHED(); - std::wstring msg = - StringPrintf(L"before attach, ignored command (%S)", cmd.c_str()); - DebuggerOutput(msg); - } - } else if (cmd == L"attach") { - OnAttach(); - } else if (cmd == L"quit" || cmd == L"detach") { - OnDetach(); + NOTREACHED(); + std::wstring msg = + StringPrintf(L"before attach, ignored command (%S)", cmd.c_str()); + DebuggerOutput(msg); } else { debugger_->Command(cmd); } @@ -103,7 +92,14 @@ bool DebugMessageHandler::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(DebugMessageHandler, message) - IPC_MESSAGE_HANDLER(ViewMsg_SendToDebugger, OnSendToDebugger); + IPC_MESSAGE_HANDLER_GENERIC(ViewMsg_DebugAttach, + OnAttach(); + handled = false;) + IPC_MESSAGE_HANDLER(ViewMsg_DebugBreak, OnBreak) + IPC_MESSAGE_HANDLER(ViewMsg_DebugCommand, OnCommand) + IPC_MESSAGE_HANDLER_GENERIC(ViewMsg_DebugDetach, + OnDetach(); + handled = false;) // If the debugger is active, then it's possible that the renderer thread // is suspended handling a breakpoint. In that case, the renderer will // hang forever and never exit. To avoid this, we look for close messages diff --git a/chrome/renderer/debug_message_handler.h b/chrome/renderer/debug_message_handler.h index ac8a7f1..d7724d0 100644 --- a/chrome/renderer/debug_message_handler.h +++ b/chrome/renderer/debug_message_handler.h @@ -27,8 +27,11 @@ class DebugMessageHandler : public IPC::ChannelProxy::MessageFilter, // Debugger::Delegate callback method to handle debugger output. void DebuggerOutput(const std::wstring& out); + // Schedule a debugger break. + void OnBreak(bool force); + // Sends a command to the debugger. - void OnSendToDebugger(const std::wstring& cmd); + void OnCommand(const std::wstring& cmd); // Sends an attach event to the debugger front-end. void OnAttach(); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 8d91e58..450b1623 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -297,6 +297,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) IPC_MESSAGE_HANDLER(ViewMsg_DebugAttach, OnDebugAttach) + IPC_MESSAGE_HANDLER(ViewMsg_DebugDetach, OnDebugDetach) IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) IPC_MESSAGE_HANDLER(ViewMsg_UploadFile, OnUploadFileRequest) IPC_MESSAGE_HANDLER(ViewMsg_FormFill, OnFormFill) @@ -2238,7 +2239,6 @@ void RenderView::OnAddMessageToConsole(const std::wstring& frame_xpath, } void RenderView::OnDebugAttach() { - EvaluateScriptUrl(L"", L"javascript:void(0)"); Send(new ViewHostMsg_DidDebugAttach(routing_id_)); // Tell the plugin host to stop accepting messages in order to avoid // hangs while the renderer is paused. |