TritonDataCenter / mdb_v8

postmortem debugging for Node.js and other V8-based programs
Mozilla Public License 2.0
240 stars 18 forks source link

want dcmd to find context and global object from threadlocals #115

Open arekinath opened 5 years ago

arekinath commented 5 years ago

v8 stashes a pointer to the current Isolate in a thread-local which we can very quickly read from mdb and use to walk down to the global object in use. This would be useful to quickly read (some) data out of process memory without doing a full heap scan.

https://gist.github.com/arekinath/f118c19af43d3955e674d22d3b0a5eb5 is an example of using this data to locate the "process" global and then the exports of all require() loaded modules in a nodejs process (and then it goes to specifically grab data that's accessible from the exports of the cueball module). I've also automated this process in https://gist.github.com/arekinath/6b46eb5291e400de117350f9bca905c6#file-diagnose-js-L380 which can run reliably with -o nostop.

It would be useful to turn basically this procedure into a couple of dcmds (the first of which would be this one, to get from the thread id to the context and global object)