Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: webkit/glue/devtools/js/debugger_agent.js

Issue 100042: Handle 'afterCompile' debugger events (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/devtools/debugger_agent_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/debugger_agent.js
===================================================================
--- webkit/glue/devtools/js/debugger_agent.js (revision 14725)
+++ webkit/glue/devtools/js/debugger_agent.js (working copy)
@@ -37,11 +37,11 @@
* @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.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,19 +276,19 @@
};
-/**
- * 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
* or response to a previously sent request. See protocol definitioun for more
@@ -304,11 +304,14 @@
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 @@
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 @@
/**
* @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 @@
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 @@
/**
* @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 @@
};
-/**
- * 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 @@
* 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 = {};
« no previous file with comments | « webkit/glue/devtools/debugger_agent_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698