Hi Christian,
I've tried your solution by registering a message listener, which is called
properly when the program fails because of an exception.
However a call to "message->PrintCurrentStackTrace()" does not print the
full stack trace, instead, I still get:
at #<an Object>.command
instead of
at fail.js:5 f2()
at fail.js:7 f()
at #<an Object>.command
Where the "#<an Object>.command" is a function that loads a file from the
disc, reads it and feeds it to V8 for evaluation -- so it seems like
PrintCurrentStackTrace does not see what's happening inside the evaluated
source code.
The evaluation function used by the command function is this one:
---
Handle<Value> k7::eval (Handle<String> source, Handle<Value> fromFileName) {
if (source->Length() == 0) return JS_undefined;
HandleScope handle_scope;
// FIXME: We disabled this, as we registered a V8 message listener
//TryCatch try_catch;
String::Utf8Value utf8_value(source);
Handle<Script> script = Script::Compile(source, fromFileName);
if (script.IsEmpty()) {
// FIXME: We disabled this, as we registered a V8 message listener
//k7::trace(&try_catch);
return JS_undefined;
}
Handle<Value> result = script->Run();
if (result.IsEmpty()) {
// FIXME: We disabled this, as we registered a V8 message listener
//k7::trace(&try_catch);
return JS_undefined;
}
return result;
}
---
Am I missing something ?
Overall, it seems like PrintStackTrace does not really see the invocation
stack, or that the message is perceived after the stack is unwind. Is there
an opened ticket for the feature you mention ?
-- Sébastien
On Tue, Jun 9, 2009 at 7:11 AM, Christian Plesner Hansen <
[email protected]> wrote:
>
> I suspect the reason you don't get the full stack trace is that you
> call PrintCurrentStackTrace after the stack has been unwound. If you
> use V8::AddMessageListener to add a message callback you will get a
> callback before the stack is unwound and PrintCurrentStackTrace should
> give you the full stack.
>
> This is not a pretty solution though. The "proper" way to do this
> would be to capture the stack trace in the message object at the point
> when the exception is thrown and then printing it when the vm has
> bailed out and returned to your code. We had an implementation of
> that but there were some problems with it so I disabled it.
> Eventually we should finish that and reenable that so you don't need
> to use AddMessageListener.
>
>
> -- Christian
>
> On Mon, Jun 8, 2009 at 6:17 PM, ryan dahl<[email protected]> wrote:
> >
> >> Any guidance from the V8 dev team ?
> >
> > I'm also interested in this problem.
> >
> > >
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---