Sorry for the late reply.
We indeed changed the behavior of stack trace capturing when creating
an Error object at r10618 (February 7th), but I don't see anything
that would interfere with the stack trace API.
I tested your code sample and it seems to work fine for me. Maybe I'm
missing something or misunderstood the problem?
///////////////////////////////// start code
snippet /////////////////////////////////
Array.prototype.each = function (callback) {
for (var i = 0; i < this.length; i++) {
callback(this[i]);
}
}
Error.stackTraceLimit = 50;
Error.prepareStackTrace = function (error, structuredStackTrace) {
var stack = [];
structuredStackTrace.each(function (item) {
stack.push({
scriptName: item.getScriptNameOrSourceURL(),
typeName: item.getTypeName(),
functionName: item.getFunctionName(),
methodName: item.getMethodName(),
fileName: item.getFileName(),
lineNumber: item.getLineNumber(),
columnNumer: item.getColumnNumber(),
evalOrgin: item.getEvalOrigin(),
isTopLevel: item.isToplevel(),
isEval: item.isEval(),
isNative: item.isNative(),
isConstructor: item.isConstructor()
});
});
return stack;
}
function f(l) {
if (l > 0) return f(l-1);
try {
throw new Error();
} catch (e) {
e.stack.each(function (item) {
print(item.functionName + "\t(" + item.lineNumber + ")");
});
}
}
function g() {
f(3);
}
g();
///////////////////////////////// end code
snippet /////////////////////////////////
The result looks like this:
f (33)
f (31)
f (31)
f (31)
g (42)
(45)
Also, please file an issue on the V8 issues tracker, preferably with a
full repro. Thanks!
Yang
On Mar 20, 2:01 pm, mschwartz <[email protected]> wrote:
> Sorry to bump this, but an answer would be appreciated.
>
>
>
>
>
>
>
> On Monday, March 19, 2012 2:16:32 PM UTC-7, mschwartz wrote:
>
> >http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
>
> > I have this code that's been working until recently:
>
> > Error.stackTraceLimit = 50;
>
> > Error.prepareStackTrace = function(error, structuredStackTrace) {
> > var stack = [];
> > structuredStackTrace.each(function(item) {
> > stack.push({
> > scriptName: item.getScriptNameOrSourceURL(),
> > typeName: item.getTypeName(),
> > functionName: item.getFunctionName(),
> > methodName: item.getMethodName(),
> > fileName: item.getFileName(),
> > lineNumber: item.getLineNumber(),
> > columnNumer: item.getColumnNumber(),
> > evalOrgin: item.getEvalOrigin(),
> > isTopLevel: item.isToplevel(),
> > isEval: item.isEval(),
> > isNative: item.isNative(),
> > isConstructor: item.isConstructor()
> > });
> > });
> > return stack;
> > }
>
> > Now when this code is called, I'm getting an exception thrown (in my
> > exception handler):
>
> > Exceptions.js:8: TypeError: Cannot read property 'constructor' of undefined
> > typeName: item.getTypeName(),
>
> > If I dump the contents of item in the loop, I get this output:
>
> > 10316 (object) :
> > [receiver] : (undefined) undefined
> > [fun] : function() { ... }
> > [pos] : (number) 2610
>
> > builtin/Exceptions.js:9: TypeError: Cannot read property 'constructor' of
> > undefined
> > typeName: item.getTypeName(),
> > ^
> > 10316 (object) :
> > [receiver] : (object) :
> > [receiver] : (undefined) undefined
> > [fun] : function() { ... }
> > [pos] : (number) 2610
> > [fun] : function CallSiteGetTypeName() { [native code] }
> > [pos] : (number) 16159
>
> > no stack trace available
> > Invoking service ModulesService.getModule
> > 10319 exceptionHandler
> > (object) :
> > [message] : (string) No such schema AnnouncementsModule
>
> > 10319 (object) :
> > [receiver] : (undefined) undefined
> > [fun] : function() { ... }
> > [pos] : (number) 2610
>
> > builtin/Exceptions.js:9: TypeError: Cannot read property 'constructor' of
> > undefined
> > typeName: item.getTypeName(),
> > ^
> > 10319 (object) :
> > [receiver] : (object) :
> > [receiver] : (undefined) undefined
> > [fun] : function() { ... }
> > [pos] : (number) 2610
> > [fun] : function CallSiteGetTypeName() { [native code] }
> > [pos] : (number) 16159
>
> > What's going on, guys?
>
> > If there's a radical change to the API, please update the WWW page above.
> > All the information available by calling those item.get*() methods is
> > REALLY useful...
>
> > Thanks in advance.
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users