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

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

Issue 99185: Pause and show call stack on exceptions (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 | « no previous file | webkit/glue/devtools/js/inspector_controller.js » ('j') | 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 14822)
+++ webkit/glue/devtools/js/debugger_agent.js (working copy)
@@ -39,6 +39,12 @@
this.currentCallFrame_ = null;
/**
+ * Whether to stop in the debugger on the exceptions.
+ * @type {boolean}
+ */
+ this.pauseOnExceptions_ = true;
+
+ /**
* Mapping: request sequence number->callback.
* @type {Object}
*/
@@ -173,6 +179,25 @@
/**
+ * @return {boolean} True iff the debugger will pause execution on the
+ * exceptions.
+ */
+devtools.DebuggerAgent.prototype.pauseOnExceptions = function() {
+ return this.pauseOnExceptions_;
+};
+
+
+/**
+ * Tells whether to pause in the debugger on the exceptions or not.
+ * @param {boolean} value True iff execution should be stopped in the debugger
+ * on the exceptions.
+ */
+devtools.DebuggerAgent.prototype.setPauseOnExceptions = function(value) {
+ this.pauseOnExceptions_ = value;
+};
+
+
+/**
* Current stack top frame.
* @return {Object}
*/
@@ -357,7 +382,28 @@
var body = msg.getBody();
debugPrint('Uncaught exception in ' + body.script.name + ':' +
body.sourceLine + '\n' + body.sourceLineText);
- this.resumeExecution();
+ if (this.pauseOnExceptions_) {
+ var body = msg.getBody();
+
+ var sourceId = -1;
+ // The exception may happen in native code in which case there is no script.
+ if (body.script) {
+ sourceId = body.script.id;
+ }
+
+ var line = devtools.DebuggerAgent.v8ToWwebkitLineNumber_(body.sourceLine);
+
+ this.currentCallFrame_ = {
+ 'sourceID': sourceId,
+ 'line': line,
+ 'script': body.script,
+ 'scopeChain': [],
+ 'thisObject': {}
+ };
+ this.requestBacktrace_();
+ } else {
+ this.resumeExecution();
+ }
};
@@ -526,13 +572,13 @@
*/
devtools.DebuggerAgent.formatFunctionCall_ = function(stackFrame, msg) {
var func = msg.lookup(stackFrame.func.ref);
- var argv = [];
- for (var j = 0; j < stackFrame.arguments.length; j++) {
- var arg = stackFrame.arguments[j];
- var val = devtools.DebuggerAgent.formatObjectReference_(arg.value, msg);
- argv.push(arg.name + ' = ' + val);
+ if (func.name) {
+ return func.name;
+ } else {
+ // TODO(yurys): support method name inference(F.m = function() {} should be
+ // a function with name 'm')
+ return '(anonymous function)';
}
- return func.name + '(' + argv.join(', ') + ')';
};
« no previous file with comments | « no previous file | webkit/glue/devtools/js/inspector_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698