Reputation: 2196
I have a fairly special-case debugging problem, in that my Node app will itself be a Node debugger (one section of the app will provide a debugging interface for debugging another section).
I am familiar with the V8 debugging protocol documented at:
https://code.google.com/p/v8/wiki/DebuggerProtocol
and with the manifold tools that use it (including the internal debugger in Node, node-inspector, and many others). If I have to talk to that API over a network connection, as all of the existing tools seem to do, I can do that, but I'd rather not for a few reasons. I'm already in-proc, would like to avoid opening the debug port in all cases and the network overhead (this is part of my production environment), and I'd like to get Javascript objects back from the debugging APIs as opposed to the JSON-ified versions you get through the JSON API (which lack some fidelity).
The V8 debugger docs say: "There are two API's for this: a function based API using JavaScript objects and a message based API using a JSON based protocol. The function based API can be used by an in-process debugger agent, whereas the message based API can be used out of process as well."
The function-based API using JavaScript objects sounds like exactly what I need, but I can see nothing else in the V8 docs regarding this API or how to use it. Nor can I see how to access this API (or V8 in general) from Node.js. So is this possible, and if so, how?
Upvotes: 1
Views: 719
Reputation: 2196
It never fails. Research all day. Post to SO. Find answer 10 minutes later.
Launch Node.js with this parameter: --expose-debug-as=v8debug
That, unsurprisingly, exposes the V8 debug state as a module that you can reference thusly:
var debug = v8debug.Debug;
var scripts = debug.scripts();
Still sorting out the pile of JS entry points and how they line up with the published API, but I think the main issue I had is more or less resolved.
Upvotes: 6