I have the same problem, when handling exception through MessageCallback
registered with v8::AddMessageListener, you cannot get original stack trace
of the error, instead you get an empty stack trace, seems like the original
context is unwound. The only way to get stack trace is to
call v8::V8::SetCaptureStackTraceForUncaughtExceptions(true, 10,
v8::StackTrace::kDetailed) while initializing v8. Then you can call
message->GetStackTrace() to get real stack trace of the error. But I heard
that SetCaptureStackTraceForUncaughtExceptions is not recommended as it
might cause integration problems with Inspector. So is this the only way?
Czarek.
On Thursday, June 11, 2009 6:24:21 PM UTC+2, Sébastien Pierre wrote:
>
> 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
>
>
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users