stack trace includes callees as well
This commit is contained in:
parent
a3a1368ea4
commit
79e92ccd0c
|
@ -410,60 +410,7 @@ EOF
|
||||||
</head>
|
</head>
|
||||||
<script src="~a"></script>
|
<script src="~a"></script>
|
||||||
<script>
|
<script>
|
||||||
var invokeMainModule = function() {
|
~a
|
||||||
var MACHINE = plt.runtime.currentMachine;
|
|
||||||
invoke(MACHINE,
|
|
||||||
function() {
|
|
||||||
var startTime = new Date().valueOf();
|
|
||||||
plt.runtime.invokeMains(
|
|
||||||
MACHINE,
|
|
||||||
function() {
|
|
||||||
// On main module invokation success:
|
|
||||||
var stopTime = new Date().valueOf();
|
|
||||||
if (window.console && window.console.log) {
|
|
||||||
window.console.log('evaluation took ' + (stopTime - startTime) + ' milliseconds');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(MACHINE, e) {
|
|
||||||
var contMarkSet, appNames, i, appName;
|
|
||||||
// On main module invokation failure
|
|
||||||
if (window.console && window.console.log) {
|
|
||||||
window.console.log(e.stack || e);
|
|
||||||
}
|
|
||||||
|
|
||||||
MACHINE.params.currentErrorDisplayer(
|
|
||||||
MACHINE, $(plt.baselib.format.toDomNode(e.stack || e)).css('color', 'red'));
|
|
||||||
|
|
||||||
if (e.hasOwnProperty('racketError') &&
|
|
||||||
plt.baselib.exceptions.isExn(e.racketError)) {
|
|
||||||
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
|
|
||||||
if (contMarkSet) {
|
|
||||||
appNames = contMarkSet.ref(plt.runtime.getTracedAppKey(MACHINE));
|
|
||||||
while (plt.baselib.lists.isPair(appNames)) {
|
|
||||||
appName = appNames.first;
|
|
||||||
MACHINE.params.currentErrorDisplayer(
|
|
||||||
MACHINE,
|
|
||||||
$('<div/>').text(' at ' + appName.elts[0] +
|
|
||||||
', line ' + appName.elts[2] +
|
|
||||||
', column ' + appName.elts[3])
|
|
||||||
.addClass('stacktrace')
|
|
||||||
.css('margin-left', '10px')
|
|
||||||
.css('whitespace', 'pre')
|
|
||||||
.css('color', 'red'));
|
|
||||||
appNames = appNames.rest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})},
|
|
||||||
function() {
|
|
||||||
// On module loading failure
|
|
||||||
if (window.console && window.console.log) {
|
|
||||||
window.console.log(e.stack || e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{});
|
|
||||||
};
|
|
||||||
$(document).ready(invokeMainModule);
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -472,6 +419,7 @@ var invokeMainModule = function() {
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
js
|
js
|
||||||
|
invoke-main-module-code
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
@ -522,7 +470,7 @@ var invokeMainModule = function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(MACHINE, e) {
|
function(MACHINE, e) {
|
||||||
var contMarkSet, appNames, i, appName;
|
var contMarkSet, context, i, appName;
|
||||||
// On main module invokation failure
|
// On main module invokation failure
|
||||||
if (window.console && window.console.log) {
|
if (window.console && window.console.log) {
|
||||||
window.console.log(e.stack || e);
|
window.console.log(e.stack || e);
|
||||||
|
@ -535,19 +483,27 @@ var invokeMainModule = function() {
|
||||||
plt.baselib.exceptions.isExn(e.racketError)) {
|
plt.baselib.exceptions.isExn(e.racketError)) {
|
||||||
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
|
contMarkSet = plt.baselib.exceptions.exnContMarks(e.racketError);
|
||||||
if (contMarkSet) {
|
if (contMarkSet) {
|
||||||
appNames = contMarkSet.ref(plt.runtime.getTracedAppKey(MACHINE));
|
context = contMarkSet.getContext(MACHINE);
|
||||||
while (plt.baselib.lists.isPair(appNames)) {
|
for (i = 0; i < context.length; i++) {
|
||||||
appName = appNames.first;
|
if (plt.runtime.isVector(context[i])) {
|
||||||
MACHINE.params.currentErrorDisplayer(
|
MACHINE.params.currentErrorDisplayer(
|
||||||
MACHINE,
|
MACHINE,
|
||||||
$('<div/>').text(' at ' + appName.elts[0] +
|
$('<div/>').text(' at ' + context[i].elts[0] +
|
||||||
', line ' + appName.elts[2] +
|
', line ' + context[i].elts[2] +
|
||||||
', column ' + appName.elts[3])
|
', column ' + context[i].elts[3])
|
||||||
.addClass('stacktrace')
|
.addClass('stacktrace')
|
||||||
.css('margin-left', '10px')
|
.css('margin-left', '10px')
|
||||||
.css('whitespace', 'pre')
|
.css('whitespace', 'pre')
|
||||||
.css('color', 'red'));
|
.css('color', 'red'));
|
||||||
appNames = appNames.rest;
|
} else if (plt.runtime.isProcedure(context[i])) {
|
||||||
|
MACHINE.params.currentErrorDisplayer(
|
||||||
|
MACHINE,
|
||||||
|
$('<div/>').text(' in ' + context[i].displayName)
|
||||||
|
.addClass('stacktrace')
|
||||||
|
.css('margin-left', '10px')
|
||||||
|
.css('whitespace', 'pre')
|
||||||
|
.css('color', 'red'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*global plt*/
|
||||||
/*jslint browser: true, unparam: true, vars: true, white: true, maxerr: 50, indent: 4 */
|
/*jslint browser: true, unparam: true, vars: true, white: true, maxerr: 50, indent: 4 */
|
||||||
|
|
||||||
// Continuation marks
|
// Continuation marks
|
||||||
|
@ -42,6 +43,37 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Returns an approximate stack trace.
|
||||||
|
// getContext: MACHINE -> (arrayof (U Procedure (Vector source line column position span)))
|
||||||
|
ContinuationMarkSet.prototype.getContext = function(MACHINE) {
|
||||||
|
var i, j;
|
||||||
|
var result = [];
|
||||||
|
var kvlist;
|
||||||
|
|
||||||
|
var tracedAppKey = plt.runtime.getTracedAppKey(MACHINE);
|
||||||
|
var tracedCalleeKey = plt.runtime.getTracedCalleeKey(MACHINE);
|
||||||
|
var proc, locationVector;
|
||||||
|
|
||||||
|
for (i = 0; i < this.kvlists.length; i++) {
|
||||||
|
kvlist = this.kvlists[i];
|
||||||
|
for (j = 0; j < kvlist.length; j++) {
|
||||||
|
if (kvlist[j][0] === tracedAppKey) {
|
||||||
|
locationVector = kvlist[j][1];
|
||||||
|
result.push(locationVector);
|
||||||
|
} else if (kvlist[j][0] === tracedCalleeKey) {
|
||||||
|
proc = kvlist[j][1];
|
||||||
|
if (proc !== null) {
|
||||||
|
result.push(proc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// A continuation prompt tag labels a prompt frame.
|
// A continuation prompt tag labels a prompt frame.
|
||||||
var ContinuationPromptTag = function(name) {
|
var ContinuationPromptTag = function(name) {
|
||||||
|
|
|
@ -184,7 +184,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
MACHINE.control.push(
|
MACHINE.control.push(
|
||||||
new baselib.frames.CallFrame(afterGoodInvoke, null));
|
new baselib.frames.CallFrame(afterGoodInvoke, v));
|
||||||
MACHINE.argcount = arguments.length - 2;
|
MACHINE.argcount = arguments.length - 2;
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < arguments.length - 2; i++) {
|
for (i = 0; i < arguments.length - 2; i++) {
|
||||||
|
@ -281,7 +281,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
MACHINE.control.push(
|
MACHINE.control.push(
|
||||||
new baselib.frames.CallFrame(afterGoodInvoke, null));
|
new baselib.frames.CallFrame(afterGoodInvoke, proc));
|
||||||
MACHINE.argcount = arguments.length - 4;
|
MACHINE.argcount = arguments.length - 4;
|
||||||
for (i = 0; i < arguments.length - 4; i++) {
|
for (i = 0; i < arguments.length - 4; i++) {
|
||||||
MACHINE.env.push(arguments[arguments.length - 1 - i]);
|
MACHINE.env.push(arguments[arguments.length - 1 - i]);
|
||||||
|
|
|
@ -270,6 +270,22 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Try to get the continuation mark key used for procedure application tracing.
|
||||||
|
var getTracedAppKey = function(MACHINE) {
|
||||||
|
if (MACHINE.modules['whalesong/lang/private/traced-app.rkt']) {
|
||||||
|
return MACHINE.modules['whalesong/lang/private/traced-app.rkt'].namespace['traced-app-key'];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
var getTracedCalleeKey = function(MACHINE) {
|
||||||
|
if (MACHINE.modules['whalesong/lang/private/traced-app.rkt']) {
|
||||||
|
return MACHINE.modules['whalesong/lang/private/traced-app.rkt'].namespace['traced-callee-key'];
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// captureControl implements the continuation-capturing part of
|
// captureControl implements the continuation-capturing part of
|
||||||
// call/cc. It grabs the control frames up to (but not including) the
|
// call/cc. It grabs the control frames up to (but not including) the
|
||||||
|
@ -360,10 +376,17 @@
|
||||||
var kvLists = [];
|
var kvLists = [];
|
||||||
var i;
|
var i;
|
||||||
var control = this.control;
|
var control = this.control;
|
||||||
|
var tracedCalleeKey = getTracedCalleeKey(this);
|
||||||
for (i = control.length-1; i >= 0; i--) {
|
for (i = control.length-1; i >= 0; i--) {
|
||||||
if (control[i].marks.length !== 0) {
|
if (control[i].marks.length !== 0) {
|
||||||
kvLists.push(control[i].marks);
|
kvLists.push(control[i].marks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tracedCalleeKey !== null &&
|
||||||
|
control[i] instanceof CallFrame &&
|
||||||
|
control[i].proc !== null) {
|
||||||
|
kvLists.push([[tracedCalleeKey, control[i].proc]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new baselib.contmarks.ContinuationMarkSet(kvLists);
|
return new baselib.contmarks.ContinuationMarkSet(kvLists);
|
||||||
};
|
};
|
||||||
|
@ -424,7 +447,6 @@
|
||||||
var MACHINE = this;
|
var MACHINE = this;
|
||||||
var thunk = initialJump;
|
var thunk = initialJump;
|
||||||
var startTime = (new Date()).valueOf();
|
var startTime = (new Date()).valueOf();
|
||||||
var contMarks;
|
|
||||||
MACHINE.callsBeforeTrampoline = STACK_LIMIT_ESTIMATE;
|
MACHINE.callsBeforeTrampoline = STACK_LIMIT_ESTIMATE;
|
||||||
MACHINE.params.numBouncesBeforeYield =
|
MACHINE.params.numBouncesBeforeYield =
|
||||||
MACHINE.params.maxNumBouncesBeforeYield;
|
MACHINE.params.maxNumBouncesBeforeYield;
|
||||||
|
@ -509,13 +531,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Try to get the continuation mark key used for procedure application tracing.
|
|
||||||
var getTracedAppKey = function(MACHINE) {
|
|
||||||
if (MACHINE.modules['whalesong/lang/private/traced-app.rkt']) {
|
|
||||||
return MACHINE.modules['whalesong/lang/private/traced-app.rkt'].namespace['traced-app-key'];
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -732,6 +749,7 @@
|
||||||
exports['isNumber'] = isNumber;
|
exports['isNumber'] = isNumber;
|
||||||
exports['isNatural'] = isNatural;
|
exports['isNatural'] = isNatural;
|
||||||
exports['isReal'] = isReal;
|
exports['isReal'] = isReal;
|
||||||
|
exports['isProcedure'] = plt.baselib.functions.isProcedure;
|
||||||
exports['equals'] = equals;
|
exports['equals'] = equals;
|
||||||
|
|
||||||
exports['toDomNode'] = toDomNode;
|
exports['toDomNode'] = toDomNode;
|
||||||
|
@ -755,5 +773,6 @@
|
||||||
exports['StructType'] = StructType;
|
exports['StructType'] = StructType;
|
||||||
|
|
||||||
exports['getTracedAppKey'] = getTracedAppKey;
|
exports['getTracedAppKey'] = getTracedAppKey;
|
||||||
|
exports['getTracedCalleeKey'] = getTracedCalleeKey;
|
||||||
|
|
||||||
}(this.plt, this.plt.baselib));
|
}(this.plt, this.plt.baselib));
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
(require (for-syntax racket/base))
|
(require (for-syntax racket/base))
|
||||||
|
|
||||||
(provide traced-app traced-app-key)
|
(provide traced-app traced-app-key traced-callee-key)
|
||||||
|
|
||||||
(define traced-app-key (gensym 'traced-app-key))
|
(define traced-app-key (gensym 'traced-app-key))
|
||||||
|
(define traced-callee-key (gensym 'traced-callee-key))
|
||||||
|
|
||||||
|
|
||||||
(define-syntax-parameter traced-app
|
(define-syntax-parameter traced-app
|
||||||
|
|
Loading…
Reference in New Issue
Block a user