Enable Debug Support for Multiple Isolates

149 views
Skip to first unread message

Ian Bull

unread,
Sep 3, 2014, 12:58:16 PM9/3/14
to v8-u...@googlegroups.com
I've read a bit on enabling debug support with multiple isolates, but I'm still struggling with the API [1].


In my case I have a single thread per isolate. I would like to enable debug support for each isolate (with a different port). Isolates can come and go. I've managed to Enable the Agent, and attach the DebugMessageDispatchHandler. However, when my callback is invoked I have no idea what isolate it is for. This is important since I need to lookup the isolate and synchronize with that thread in order to setup the proper context and ProcessDebugMessages.

Without any parameters to the DispatchHandler, what is the proper way to figure out what isolate this callback is for? Even the name of the embedding application or the debug port would be enough. I looked at some of the other static methods (such as Isolate::GetCurrent -- this returns NULL), but using these seems like a race condition waiting to happen.

Thoughts?
Ian

Ben Noordhuis

unread,
Sep 3, 2014, 4:00:50 PM9/3/14
to v8-u...@googlegroups.com
What version of V8 are you targeting, Ian? The debug API has seen
significant changes recently.

Ian Bull

unread,
Sep 3, 2014, 4:53:07 PM9/3/14
to v8-u...@googlegroups.com
Currently I'm targeting 3.26 (I had trouble building 3.27 & 3.28 on both my Mac and for Android, although I can certainly revisit that). 

I'll take a look at the new API. Thanks!

Ian

Anoop R. S.

unread,
May 18, 2017, 11:44:16 PM5/18/17
to v8-users
Hi Ian,
I am also trying to achieve what you are trying. 
Where you able to debug multiple isolates? Please provide some info.

regards,
Anoop R. S.

Anoop R. S.

unread,
May 19, 2017, 12:20:02 AM5/19/17
to v8-users
 I would like to enable debug support for each isolate (with a different port). 

Does it have to be a separate port for each isolate ? (if you are talking about the websocket port where the debugger is exposed, it would be 9222 usually)
If that is the case, I guess you would be generating new port numbers for each new v8::isolate that is to be debugged. 

Am I getting it correctly? 

Is there any way around that? Could we achieve the debugging of multiple v8::isolate by exposing the websocket service in a single port? 


regards,
Anoop R. S.

Anoop R. S.

unread,
May 24, 2017, 4:28:23 AM5/24/17
to v8-users
https://groups.google.com/forum/#!search/v8$20debugging/v8-users/9G1SXYNNf0M/79DdexFCBgAJ

Maybe someone having the same query might benefit. 

regards,
Anoop R. S. 

Zac Hansen

unread,
May 25, 2017, 12:06:07 AM5/25/17
to v8-users
How would that work if you had multiple isolates running simultaneously in multiple threads?  

I like the model of keeping isolates completely separate as much as possible.   

Ian Bull

unread,
May 25, 2017, 1:15:52 AM5/25/17
to v8-users
When I originally asked this question it was about the debug agent. That agent no longer exists.

I now use the JS debugger that's available in V8. You can set a flag (something like "expose-debug-as=__j2v8_debug_handler"). 
This is what I use in J2V8 and there is a debug handler registered in the global scope called __j2v8_debug_handler.

I can then add breakpoints, and interact with the debugger using JavaScript against this object.

Cheers,
Ian

Anoop R. S.

unread,
May 25, 2017, 1:26:34 AM5/25/17
to v8-users
Hi Zac,
Thank you for replying.
Then how they do it for Chrome? I mean, we can open localhost:9222 and select the tabs that we want to inspect. I had a notion that each tab corresponds to separate v8::isolate.

regards,
Anoop R. S.

Anoop R. S.

unread,
May 25, 2017, 1:36:20 AM5/25/17
to v8-users
Thank you for replying, Ian.
I guess you are using something which uses node.js. But my case is different. We have embedded v8 into our application without any node.js involved. 
I guess the correct way is to use a separate port for each v8::isolate and redirect the json messages to each isolate correctly. 

regards,
Anoop R. S.

Ian Bull

unread,
May 25, 2017, 12:13:41 PM5/25/17
to v8-users
No, it's not a node.js thing. I just have a V8 static library. There is a debug interface written in JS that comes with V8. Some information is available at [1].


Cheers,
Ian

Anoop R. S.

unread,
Jun 8, 2017, 5:08:33 AM6/8/17
to v8-users
Hi,
I figured out a way to do this. 
Going by the way how multiple tags are debugged using the remote debugging in chrome, I displayed different links for each isolate in the index page (that is loaded on 9222). Based on which link is clicked, I checked the querystring part, which I made different for different isolates, the messages are redirected to the corresponding isolate wrapper. 

I am not sure if there are any drawbacks for this approach. If I open each inspectable page in a new tab, I am also able to debug parallelly. 

Please provide your thoughts about this.

regards,
Anoop R. S.
Reply all
Reply to author
Forward
0 new messages