pmed / v8pp

Bind C++ functions and classes into V8 JavaScript engine
http://pmed.github.io/v8pp/
Other
898 stars 120 forks source link

Debugging JS running under V8 #23

Closed 0xn3bs closed 8 years ago

0xn3bs commented 8 years ago

Perhaps this isn't the appropriate place to post this but googling didn't provide a lot of answers. How does one go about debugging JavaScript running under V8 through v8pp?

Thanks!

pmed commented 8 years ago

Well, some time ago V8 had a debugger agent inside. It could be started in an embedding application and accessed on HTTP. Then Google removed this agent, published https://github.com/v8/v8/wiki/Debugging-Protocol

As I understand, now debugger for V8 should be implemented in user code.

Actually I've not used V8 JS debugger from that time. There is a llnode - Node.js plugin for LLDB, but AFAIK it works on OS X only.

mhalitk commented 8 years ago

I'm using V8 v5.1 in project I'm working and we are using debugger. Still Debug agent is inside V8 and to run debugger you just need to set a message handler for debugger messages.

Debugger class is v8::Debug and to set Message Handler Debug::SetMessageHandler function is used. When you set it will start to send messages with this protocol https://github.com/v8/v8/wiki/Debugging-Protocol. To send a message to Debug agent there is Debug::SendCommand function.

Of course these functionalities needs V8 built with debuggersupport flag "on".

I hope this will help.

pmed commented 8 years ago

@mhalitk thanks for sharing this!

xaxxon commented 7 years ago

I've gotten minimal debugging functionality implemented in my (competing) library as shown in this 5m movie: https://www.youtube.com/watch?v=qkP49-f_eRg It's mostly a proof of concept thus far, but if anyone wants to help (hint hint) I'm sure it can be made in a generic fashion so it would be easy to plug in to any existing v8-integration library.