V8 - wait for debug connection

13 views
Skip to first unread message

Eugene Ostroukhov

unread,
Nov 22, 2009, 10:02:43 AM11/22/09
to v8-users
Hi, All.
I'm creating JavaScript debugger that uses Chrome/V8 as a runtime.

The question I have - is it possible to have V8 wait for debugger
connection on start? So it is paused on start and does not execute any
JS until the debugger connects, sets the breakpoints, gives resume
command?

Best regards,
Eugene

Ryan Dahl

unread,
Nov 22, 2009, 4:39:45 PM11/22/09
to v8-u...@googlegroups.com

Yes. There is at least one way. Use the recently added
DebugMessageDispatchHandler:
http://code.google.com/p/v8/source/browse/trunk/include/v8-debug.h?spec=svn3342&r=3333#219

You'll have to do the idling yourself - have the main loop sit in
select() listening on a pipe, for example. The
DebugMessageDispatchHandler will be called from the debugger thread -
so if using select() you could write something to the pipe and the
select() will wake up the main thread. At that point you can execute
an arbitrary bit of javascript and handle the message.

An example of this can be seen in here:
http://github.com/ry/node/blob/0433d828cffaaf1a6a69a8ba175a172ae1af0f11/src/node.cc#L846-873
http://github.com/ry/node/blob/0433d828cffaaf1a6a69a8ba175a172ae1af0f11/src/node.cc#L608-625

Reply all
Reply to author
Forward
0 new messages