On Thursday, October 30, 2014 5:29:13 AM UTC-7, Ben Noordhuis wrote:
>
>
> You can interrupt a running script by calling v8::Debug::DebugBreak() 
> from another thread.  It's de facto async signal-safe if, perhaps, not 
> de jure; that is, I don't know whether V8 guarantees that it's async 
> signal-safe but the current implementation is. 
>
> You can do more advanced things programmatically with 
> v8::Debug::SetDebugEventListener() and v8::Debug::SetMessageHandler(). 
> See test/cctest/test-debug.cc for more details. 
>

This is useful info. I have a follow-up question.

It appears as though SetDebugEventListener(), unlike DebugBreak(),  must be 
called in a thread-safe manner (i.e. it must enter the appropriate isolate 
that it wants to install the DebugEventListener on).  I say this because 
looking at the v8 internal code, it appears to be creating handles, scopes 
etc when installing the DebugEventListener callback.

In my case, I'd like to install a DebugEventListener only in response to a 
signal sent to the running process -- the reason being that installing a 
DebugEventListener from the very beginning of the code appears to result in 
a fairly major decrease in v8 Javascript performance (a factor of 3x 
slowdown in my test application).

So, I have a main thread running with the  v8 isolate, and a separate 
monitor thread running which is waiting for the SIGHUP.  After setting a 
hupFired flag, I want to then  install the DebugEventListener from the 
separate monitor thread - while the main thread may still be running its 
code.  After installing the DebugEventListener, I then want to fire a 
DebugBreak event (so I can capture the stack trace of where the main v8 
thread is running).

So far, I've been fairly unsuccessful in doing so -- in fact, I'm wondering 
if this is even possible if the main v8 Javascript code is in an infinite 
loop (the use case for which I want to interrupt it).  I can certainly send 
a DebugBreak event, but unless I have a DebugEventListener installed, then 
I won't be able to get a callback to my own code.  Or am I missing 
something?

Thanks for any help.

 

>
> V8 used to have an embedded debug agent that created a TCP listen 
> socket for clients to connect to.  That was removed recently, you have 
> to implement your own now. 
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to