Thanks for prompt reply, Jakob,
 
To solve our issue we did following changes in our local v8 copy (looks 
drastical, but works perfectly for our purpose):

In *debug.h* for storage location for registers when handling debug break 
calls we just added static thread_local

> static thread_local ThreadLocal thread_local_;
>
>
and in *debug.cc*
//Make thread_local_ really thread_local :)
thread_local Debug::ThreadLocal Debug::thread_local_;
 char* Debug::ArchiveDebug(char* storage) {
  // Leave thread_local storage as is in thread_local memory
   return storage + ArchiveSpacePerThread();
}
 char* Debug::RestoreDebug(char* storage) {
  // Leave thread_local storage as is in thread_local memory
   return storage + ArchiveSpacePerThread();
}





17 травня 2017 р. 09:29:41 UTC+3 користувач Jakob Gruber написав:
>
> We removed support for preserving debugger state across thread switches 
> because it was untested, probably buggy, and unused. 
>
> As a workaround, you would need to store state (e.g. active breakpoints) 
> yourself and reissue debugger commands after switching threads.
>
> On Tue, May 16, 2017 at 12:49 PM, Pavlo Mur <[email protected] 
> <javascript:>> wrote:
>
>> While integrating debugger support into our v8 embedding application it 
>> was discovered that debugger state is not saved/restored when threads are 
>> switched - thus once we step over any such C++ call that temporary unlocks 
>> v8 engine, debugger is not able to stop on next statement and script just 
>> runs without stops.
>>
>> v8 version 5.8.283.32
>>
>> * Are there any workarounds to save debug context without modifying v8 
>> souces?
>>
> * Why Debug::ArchiveDebug does "Simply reset state. Don't archive 
>> anything." in this case?
>>
>>
>> Details:
>> Corresponding source fragment
>>
>>>
>>> char* Debug::ArchiveDebug(char* storage) {
>>>   // Simply reset state. Don't archive anything.
>>>   ThreadInit();
>>>   return storage + ArchiveSpacePerThread();
>>> }
>>>  char* Debug::RestoreDebug(char* storage) {
>>>   // Simply reset state. Don't restore anything.
>>>   ThreadInit();
>>>   return storage + ArchiveSpacePerThread();
>>> }
>>> int Debug::ArchiveSpacePerThread() { return 0; }
>>>
>>>
>> Call stack:
>>
>>
>> <https://lh3.googleusercontent.com/-L_dbS0DO1k8/WRrFuqm3o2I/AAAAAAAAAMw/V8n33pl9l3Qxq37nMAwuTfHGuykepf7kACLcB/s1600/call_stack.bmp>
>>
>> Actual sequence:
>> 1. While step by step debugging stop on API exported from C++ that does 
>> following
>> 2.a. Unlock v8 via v8::Unlocker
>> 2.b. Set native event
>> 2.c. Meanwhile other C++ thread will wake, lock v8 via v8::Locker, issue JS 
>> callback, unlock v8
>>
>> 2.d. Wait for confirmation from that other C++ thread 
>> 2.e. Lock v8 again in destuctor of v8::Unlocker
>> 3. After return from that API debugger does not stop any more because 
>> inside of Debug::Break(JavaScriptFrame* frame)
>>  call to last_step_action(); now returns StepNone instead of 
>>
>> StepNext and JS continues to run instead of stopping on next JS statement.
>>
>> -- 
>> -- 
>> v8-users mailing list
>> [email protected] <javascript:>
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
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