On Wed, Sep 14, 2022 at 6:16 PM Nathan Sandum <[email protected]> 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. -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAHQurc9%3DUGYtLdh4SiLdaZifKXtdAeKGkBrAP39C%3D2%2Bs9dsOvQ%40mail.gmail.com.
