On Sat, May 25, 2019 at 11:34 AM Luo Wu <lwye...@pku.edu.cn> wrote: > > Hi all, > > I want to intercept and log the context changing event in v8. > > Say I have a script in main.html which invokes a function foo in the > iframe.html. When the function foo is executed, the isolate->context() is > changed to represent for iframe.html. But I cannot find where the v8 sets the > corresponding context variable (isolate->set_context() is not invoked). My > purpose is to immediately know that the context is changed, and log some > information. > > Please tell me how can I achieve this goal. Appreciate if there is any idea > for that.
The short answer is that you can't, at least not easily. The context is changed directly from the generated machine code, there is no associated C++ function call that you can instrument. Grep src/builtins/*/builtins-*.cc for IsolateAddressId::kContextAddress and IsolateAddressId::kPendingHandlerContextAddress to find out how it works. It's possible to augment the generated code to call out to a C++ function but it's not exactly trivial. Grep the aforementioned files for CallCFunction() and note how e.g. Runtime::kUnwindAndFindExceptionHandler corresponds to Runtime_UnwindAndFindExceptionHandler in src/runtime/runtime-internal.cc. Good luck! -- -- 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/CAHQurc-Ljw0SJiGqV5ZJQxfe4OjKOBJre4qi82L2wQHgMfXk_g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.