Re: [v8-dev] Looking for help understanding StackFrameIterator

26 views
Skip to first unread message
Message has been deleted

Ben Noordhuis

unread,
Sep 14, 2022, 4:49:35 PM9/14/22
to v8-...@googlegroups.com
On Wed, Sep 14, 2022 at 6:16 PM Nathan Sandum <nathan...@gmail.com> wrote:
>
> I've been writing some code to trace through the stack in the middle of a WebAssembly execution. Mostly I've just been using v8::internal::GetCurrentStackPosition() and sorta just guessing when to stop, but this is probably unreliable and unsafe. I see there exists stuff like StackFrameIterator, and other similar looking classes in v8, but I can't quite figure out how to use the,. How can I go about figuring this out a little better?
> Basically all I have so far is:
> auto isolate = v8::internal::Isolate::Current();
> auto stack_memory = v8::internal::wasm::StackMemory::GetCurrentStackView(isolate);
> auto iter = v8::internal::StackFrameIterator(isolate, stack_memory);
> Which does not work.
> My other attempt was to use isolate->wasm_stacks() instead of v8::internal::wasm::StackMemory::GetCurrentStackView(isolate), but this function just seems to return nullptr for me. I don't have any better guesses, so I was hoping someone would know better and be able to give me some direction
> Thanks for any help!

I believe StackMemory::GetCurrentStackView() is related to
https://github.com/WebAssembly/stack-switching. It's probably not what
you're looking for.

The single argument StackFrameIterator::StackFrameIterator(isolate)
constructor is what you would normally use to walk the call stack. See
WasmModuleDebug::GetCallStack() in
src/debug/wasm/gdb-server/wasm-module-debug.cc for an example that
also uses FrameSummary.

Perhaps stating the obvious but you need to call it at a point when
there are WASM stack frames on the call stack, so a place where
there's a callout from WASM to JS or the runtime.
Reply all
Reply to author
Forward
0 new messages