Unfortunately this won't work 100% of the time. V8's GC may move objects, so the address you would need to watch is not fixed.
Yang On Thu, Oct 4, 2018 at 2:25 PM <eloy.de.en...@gmail.com> wrote: > Hi, > > I’m completely new to v8, so bare with me. Because the node debugging > facility lacks the ability to define watchpoints (i.e. break when a > variable changes), I was thinking that maybe I could do so at the VM level > using lldb/gdb. > > The code I’m trying to debug tries to access a global variable, which > somewhere during execution gets set to `null`. A pseudo example looks like: > > ``` > var doc = document > debugger // <- here the object is a non-null value as expected > // Enzyme (a React testing utility) renders an async React tree and > somewhere during that period `document` gets set to `null` > mount(<SomeComponentThatDoesAsyncRendering />) // <- an exception is > raised because `document` is `null` > ``` > > My thinking is: > > 1. I use node/v8’s JS debugger to hit a breakpoint where I know the > variable is what I expect it to be > 2. break using lldb/gdb, find the JS variable > 3. set a native watchpoint or a conditional breakpoint on the VM code that > assigns variables for the address of the JS variable > 4. when the native breakpoint hits, get a JS execution stack trace to find > the location that is assigning the new (`null`) value > > Does this make any sense? > > Cheers, > Eloy > > -- > -- > v8-dev mailing list > v8-dev@googlegroups.com > 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 v8-dev+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-dev mailing list v8-dev@googlegroups.com 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 v8-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.