Commit 028b8e54 authored by yurys@google.com's avatar yurys@google.com

1. When exception is thrown debugger will pause and show call stack.

2. Function actual parameters are not shown in the call stack panel because they are alredy displayed in the scopes panel.
Review URL: http://codereview.chromium.org/99185

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14935 0039d316-1c4b-4281-b951-d872f2087c98
parent 5d438dba
...@@ -38,6 +38,12 @@ devtools.DebuggerAgent = function() { ...@@ -38,6 +38,12 @@ devtools.DebuggerAgent = function() {
*/ */
this.currentCallFrame_ = null; this.currentCallFrame_ = null;
/**
* Whether to stop in the debugger on the exceptions.
* @type {boolean}
*/
this.pauseOnExceptions_ = true;
/** /**
* Mapping: request sequence number->callback. * Mapping: request sequence number->callback.
* @type {Object} * @type {Object}
...@@ -172,6 +178,25 @@ devtools.DebuggerAgent.prototype.resumeExecution = function() { ...@@ -172,6 +178,25 @@ devtools.DebuggerAgent.prototype.resumeExecution = function() {
}; };
/**
* @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. * Current stack top frame.
* @return {Object} * @return {Object}
...@@ -357,7 +382,28 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) { ...@@ -357,7 +382,28 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) {
var body = msg.getBody(); var body = msg.getBody();
debugPrint('Uncaught exception in ' + body.script.name + ':' + debugPrint('Uncaught exception in ' + body.script.name + ':' +
body.sourceLine + '\n' + body.sourceLineText); 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.formatCallFrame_ = function(stackFrame, script, msg) { ...@@ -526,13 +572,13 @@ devtools.DebuggerAgent.formatCallFrame_ = function(stackFrame, script, msg) {
*/ */
devtools.DebuggerAgent.formatFunctionCall_ = function(stackFrame, msg) { devtools.DebuggerAgent.formatFunctionCall_ = function(stackFrame, msg) {
var func = msg.lookup(stackFrame.func.ref); var func = msg.lookup(stackFrame.func.ref);
var argv = []; if (func.name) {
for (var j = 0; j < stackFrame.arguments.length; j++) { return func.name;
var arg = stackFrame.arguments[j]; } else {
var val = devtools.DebuggerAgent.formatObjectReference_(arg.value, msg); // TODO(yurys): support method name inference(F.m = function() {} should be
argv.push(arg.name + ' = ' + val); // a function with name 'm')
return '(anonymous function)';
} }
return func.name + '(' + argv.join(', ') + ')';
}; };
......
...@@ -288,13 +288,24 @@ devtools.InspectorController.prototype.pauseInDebugger = function() { ...@@ -288,13 +288,24 @@ devtools.InspectorController.prototype.pauseInDebugger = function() {
/** /**
* Tells backend to pause in the debugger on the exceptions. * @return {boolean} True iff the debugger will pause execution on the
* exceptions.
*/ */
devtools.InspectorController.prototype.pauseOnExceptions = function() { devtools.InspectorController.prototype.pauseOnExceptions = function() {
// Does nothing in stub. // Does nothing in stub.
return false;
}; };
/**
* 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.InspectorController.prototype.setPauseOnExceptions = function(value) {
};
/** /**
* Tells backend to resume execution. * Tells backend to resume execution.
*/ */
......
...@@ -123,4 +123,21 @@ devtools.InspectorControllerImpl.prototype.stepOverStatementInDebugger = ...@@ -123,4 +123,21 @@ devtools.InspectorControllerImpl.prototype.stepOverStatementInDebugger =
}; };
/**
* @override
*/
devtools.InspectorControllerImpl.prototype.pauseOnExceptions = function() {
return devtools.tools.getDebuggerAgent().pauseOnExceptions();
};
/**
* @override
*/
devtools.InspectorControllerImpl.prototype.setPauseOnExceptions = function(
value) {
return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value);
};
var InspectorController = new devtools.InspectorControllerImpl(); var InspectorController = new devtools.InspectorControllerImpl();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment