There is a way to break the JS execution. In the C++ API
(include/v8-debug.h) there is the function Debug::DebugBreak(). This
function can be called from any thread. When --expose_debug_as=<name> is
used that function can be called from JavaScript using
<name>.Debug.breakExecution. Calling it from JavaScript is not that
interesting as it is almost the same as inserting a debugger statement.

The way Debug::DebugBreak() works is that it piggy-bags on the stack check.
For each function call and backwards branch V8 performs a stack
check. Debug::DebugBreak() artificially lowers the stack size so that these
stack check always fail. The handling of a failing stack check can then see
that the failing stack check is due to a debugger break and handle
it accordingly.

Regards,
Søren

On Sun, May 6, 2012 at 5:27 PM, Camilo Aguilar <[email protected]>wrote:

> Yeah, I thought v8 was handling the thread under the hood keeping the
> paused context and state available for us through the
> JS Debug object. Karl, if you want to fork
> https://github.com/c4milo/node-debugger and send pull requests that will
> be awesome.
>
>
> On Sun, May 6, 2012 at 4:36 AM, Karl Skomski <[email protected]> wrote:
>
>> Hi  Camilo,
>>
>> yeah I tried the same thing in my fork. :D But when you think about it
>> twice it's pretty clear why you need a separate thread for the agent
>> when you use the debugger.
>> I consider to use the debugger agent from v8 or to implement my own
>> C++ module that replicates some v8 debugger agent features but what
>> better integrates with the rest of the module.
>>
>> Maybe we could collaborate on this.
>>
>> Kind regards,
>>
>> Karl Skomski
>>
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: Camilo Aguilar <[email protected]>
>> Date: Thu, May 3, 2012 at 11:30 PM
>> Subject: [v8-users] about javascript debugger object exposed with
>> --expose_debug_as=<name>
>> To: v8-users <[email protected]>
>>
>>
>>
>> Hi there,
>>
>> I've been trying to use the javascript object exposed with
>> --expose_debug_as=<name> and I got stuck trying to determine how to
>> stop the main thread upon pause. Also I still can't find a function to
>> continue the execution. This is the only black hole right now. The
>> rest of the functionality is pretty straight forward, may anybody shed
>> some light on this please?.
>>
>> Thanks in advance.
>> Camilo
>>
>> --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>>
>
>  --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to