diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-28 13:38:24 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-28 13:38:24 +0000 |
commit | db8f19e60abab284b781d92e6167be07826263b5 (patch) | |
tree | 1ca63d462b7f27dc692497a24c18b935ddda9b32 /webkit/glue | |
parent | 48fef2b52117dc42552949fc48db64a94a532020 (diff) | |
download | chromium_src-db8f19e60abab284b781d92e6167be07826263b5.zip chromium_src-db8f19e60abab284b781d92e6167be07826263b5.tar.gz chromium_src-db8f19e60abab284b781d92e6167be07826263b5.tar.bz2 |
1. Debugger front-end scripts are now updated from 'afterCompile' events.
2. V8 debugger message handlers are temporary removed when a new debugger agent is attaching to avoid failing on compile events.
Review URL: http://codereview.chromium.org/100042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.cc | 8 | ||||
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.h | 1 | ||||
-rw-r--r-- | webkit/glue/devtools/js/debugger_agent.js | 129 |
3 files changed, 86 insertions, 52 deletions
diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc index 0eaa4cc..378acb6 100644 --- a/webkit/glue/devtools/debugger_agent_manager.cc +++ b/webkit/glue/devtools/debugger_agent_manager.cc @@ -24,6 +24,9 @@ WebDevToolsAgent::MessageLoopDispatchHandler DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; +// static +bool DebuggerAgentManager::in_host_dispatch_handler_ = false; + namespace { class CallerIdWrapper : public v8::Debug::ClientData { @@ -56,12 +59,17 @@ void DebuggerAgentManager::V8DebugMessageHandler(const uint16_t* message, } void DebuggerAgentManager::V8DebugHostDispatchHandler() { + if (in_host_dispatch_handler_) { + return; + } + in_host_dispatch_handler_ = true; if (DebuggerAgentManager::message_loop_dispatch_handler_ && attached_agents_) { DebuggerAgentImpl::RunWithDeferredMessages( *attached_agents_, message_loop_dispatch_handler_); } + in_host_dispatch_handler_ = false; } // static diff --git a/webkit/glue/devtools/debugger_agent_manager.h b/webkit/glue/devtools/debugger_agent_manager.h index 8eb458c..2b37993 100644 --- a/webkit/glue/devtools/debugger_agent_manager.h +++ b/webkit/glue/devtools/debugger_agent_manager.h @@ -64,6 +64,7 @@ class DebuggerAgentManager { static WebDevToolsAgent::MessageLoopDispatchHandler message_loop_dispatch_handler_; + static bool in_host_dispatch_handler_; DISALLOW_COPY_AND_ASSIGN(DebuggerAgentManager); }; diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js index 650f126..1e48050 100644 --- a/webkit/glue/devtools/js/debugger_agent.js +++ b/webkit/glue/devtools/js/debugger_agent.js @@ -37,11 +37,11 @@ devtools.DebuggerAgent = function() { * @type {?Object} */ this.currentCallFrame_ = null; -
- /**
- * Mapping: request sequence number->callback.
- * @type {Object}
- */
+ + /** + * Mapping: request sequence number->callback. + * @type {Object} + */ this.requestSeqToCallback_ = null; }; @@ -67,7 +67,7 @@ devtools.DebuggerAgent.prototype.requestScripts = function() { }); devtools.DebuggerAgent.sendCommand_(cmd); // Force v8 execution so that it gets to processing the requested command. - devtools.tools.evaluateJavaScript('javascript:void(0)');
+ devtools.tools.evaluateJavaScript('javascript:void(0)'); }; @@ -276,18 +276,18 @@ devtools.DebuggerAgent.prototype.stepCommand_ = function(action) { }; -/**
- * Sends 'lookup' request to v8.
- * @param {number} handle Handle to the object to lookup.
- */
-devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback) {
- var cmd = new devtools.DebugCommand('lookup', {
- 'handles': handles
- });
- devtools.DebuggerAgent.sendCommand_(cmd);
- this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback;
-};
-
+/** + * Sends 'lookup' request to v8. + * @param {number} handle Handle to the object to lookup. + */ +devtools.DebuggerAgent.prototype.requestLookup_ = function(handles, callback) { + var cmd = new devtools.DebugCommand('lookup', { + 'handles': handles + }); + devtools.DebuggerAgent.sendCommand_(cmd); + this.requestSeqToCallback_[cmd.getSequenceNumber()] = callback; +}; + /** * Handles output sent by v8 debugger. The output is either asynchronous event @@ -304,11 +304,14 @@ devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) { throw e; } + if (msg.getType() == 'event') { if (msg.getEvent() == 'break') { this.handleBreakEvent_(msg); - } else if (msg.getEvent() == 'exception') {
- this.handleExceptionEvent_(msg);
+ } else if (msg.getEvent() == 'exception') { + this.handleExceptionEvent_(msg); + } else if (msg.getEvent() == 'afterCompile') { + this.handleAfterCompileEvent_(msg); } } else if (msg.getType() == 'response') { if (msg.getCommand() == 'scripts') { @@ -319,9 +322,9 @@ devtools.DebuggerAgent.prototype.handleDebuggerOutput_ = function(output) { this.handleClearBreakpointResponse_(msg); } else if (msg.getCommand() == 'backtrace') { this.handleBacktraceResponse_(msg); - } else if (msg.getCommand() == 'lookup') {
+ } else if (msg.getCommand() == 'lookup') { this.invokeCallbackForResponse_(msg); - } else if (msg.getCommand() == 'evaluate') {
+ } else if (msg.getCommand() == 'evaluate') { this.invokeCallbackForResponse_(msg); } } @@ -350,11 +353,11 @@ devtools.DebuggerAgent.prototype.handleBreakEvent_ = function(msg) { /** * @param {devtools.DebuggerMessage} msg */ -devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) {
- var body = msg.getBody();
- debugPrint('Uncaught exception in ' + body.script.name + ':' +
- body.sourceLine + '\n' + body.sourceLineText);
- this.resumeExecution();
+devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) { + var body = msg.getBody(); + debugPrint('Uncaught exception in ' + body.script.name + ':' + + body.sourceLine + '\n' + body.sourceLineText); + this.resumeExecution(); }; @@ -366,11 +369,11 @@ devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) { for (var i = 0; i < scripts.length; i++) { var script = scripts[i]; - this.parsedScripts_[script.id] = new devtools.ScriptInfo( - script.id, script.lineOffset); - - WebInspector.parsedScriptSource( - script.id, script.name, script.source, script.lineOffset); + // We may already have received the info in an afterCompile event. + if (script.id in this.parsedScripts_) { + continue; + } + this.addScriptInfo_(script); } }; @@ -402,6 +405,28 @@ devtools.DebuggerAgent.prototype.handleSetBreakpointResponse_ = function(msg) { /** * @param {devtools.DebuggerMessage} msg */ +devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) { + var script = msg.getBody().script; + this.addScriptInfo_(script); +}; + + +/** + * Adds the script info to the local cache. This method assumes that the script + * is not in the cache yet. + * @param {Object} script Script json object from the debugger message. + */ +devtools.DebuggerAgent.prototype.addScriptInfo_ = function(script) { + this.parsedScripts_[script.id] = new devtools.ScriptInfo( + script.id, script.lineOffset); + WebInspector.parsedScriptSource( + script.id, script.name, script.source, script.lineOffset); +}; + + +/** + * @param {devtools.DebuggerMessage} msg + */ devtools.DebuggerAgent.prototype.handleClearBreakpointResponse_ = function( msg) { // Do nothing. @@ -435,19 +460,19 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) { }; -/**
- * Handles response to a command by invoking its callback (if any).
- * @param {devtools.DebuggerMessage} msg
- */
-devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) {
- var callback = this.requestSeqToCallback_[msg.getRequestSeq()];
- if (!callback) {
- // It may happend if reset was called.
- return;
- }
- delete this.requestSeqToCallback_[msg.getRequestSeq()];
- callback(msg);
-};
+/** + * Handles response to a command by invoking its callback (if any). + * @param {devtools.DebuggerMessage} msg + */ +devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) { + var callback = this.requestSeqToCallback_[msg.getRequestSeq()]; + if (!callback) { + // It may happend if reset was called. + return; + } + delete this.requestSeqToCallback_[msg.getRequestSeq()]; + callback(msg); +}; /** @@ -458,13 +483,13 @@ devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) { * the format expected by ScriptsPanel and its panes. */ devtools.DebuggerAgent.formatCallFrame_ = function(stackFrame, script, msg) { - var sourceId = script.id;
- var func = msg.lookup(stackFrame.func.ref);
- var funcScript = msg.lookup(func.script.ref);
- if (funcScript && 'id' in funcScript) {
- sourceId = funcScript.id;
- }
-
+ var sourceId = script.id; + var func = msg.lookup(stackFrame.func.ref); + var funcScript = msg.lookup(func.script.ref); + if (funcScript && 'id' in funcScript) { + sourceId = funcScript.id; + } + var funcName = devtools.DebuggerAgent.formatFunctionCall_(stackFrame, msg); var scope = {}; |