This is a bug in our API implementation. Or better, there is a mismatch
between API and what we do internally. "Method names" and "class names" are
stored separately from function names. This can be seen here, when we
collect all the information for a single frame:
https://cs.chromium.org/chromium/src/v8/src/heap/factory.cc?rcl=e1eb815647f334a8cf970439343a8febfa9f6d11&l=3732

There is really no reason why this information shouldn't be made available
in the API. The only tricky thing is to come up with a better API, as some
of the getters change meaning depending whether its a JS or WASM frame and
I am not really happy with the current solution.

On Mon, Nov 18, 2019 at 4:40 PM Darin Dimitrov <darin.dimit...@gmail.com>
wrote:

> I am embedding V8 and trying to capture the current javascript stacktrace
> using the "v8::StackTrace::CurrentStackTrace":
>
> Isolate* isolate = info.GetIsolate();
>
> Local<StackTrace> stack = v8::StackTrace::CurrentStackTrace(isolate, 10,
> v8::StackTrace::StackTraceOptions::kDetailed);
>
> *for* (*int* i = 0; i < stack->GetFrameCount(); i++) {
>
>     Local<v8::StackFrame> frame = stack->GetFrame(isolate, i);
>
>     Local<v8::String> funcName = frame->GetFunctionName();
>
>     v8::String::Utf8Value str(isolate, funcName);
>
>     *const* *char** name = *str;
>
>     printf("%s (%d:%d)\n", name, frame->GetLineNumber(), frame->GetColumn
> ());
>
> }
>
> I have placed this code inside a custom function that I have registered to
> the global scope.
>
> Before calling my custom function, I tried logging the stack property of
> an Error object (by using : console.log(new Error().stack)) and I obtained
> the following output:
>
> Error
>     at bar (file:///app/bundle.js:266:29)
>     at test (file:///app/bundle.js:267:15)
>     at Observable.onTap (file:///app/bundle.js:268:11)
>     at Button.notify (file:///app/vendor.js:3620:32)
>     at Button._emit (file:///app/vendor.js:3640:18)
>     at TapHandlerImpl.tap (file:///app/vendor.js:15540:19)
>
> With the "v8::StackTrace::CurrentStackTrace" method I get:
>
> bar (266:29)
> test (267:15)
> (null) (268:11)
> (null) (3620:32)
> (null) (3640:18)
> (null) (15540:19)
>
> I am getting empty function names from some frames, while all the other
> information is present (script name, line, column numbers, ...).
>
> Do you know what might be the reason for getting empty function names?
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-users/64d9e4ca-b271-4d83-aace-753c28e193f4%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-users/64d9e4ca-b271-4d83-aace-753c28e193f4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CACswSC2PmjxdkT9qcED%2B1rHs1AkmZ3q0zTt%3D-cBfB51TTbKj6A%40mail.gmail.com.

Reply via email to