So basically there are two ways of handling debugging with V8

1. Handle debugging inside the VM using callback
2. Handle debugging outside the VM using the debugger protocol.

The d8 developer shell supports both modes of operation.

Running

$ ./d8 --debugger

Will enable the debugging inside the VM. Typing debugger (the debugger
statement) will enter the debugger.

Running

$ ./d8 --debugger-agent

Will enable debugging through a socket connection. Typing debugger now will
have no effect as no debugger is attached. d8 can also act as a remote
debugger, so running

$ ./d8 --remote-debugger

in a separate shell will connect to the first V8. Now typing debugger in d8
will enter the debugger in the remote debugger.

Take a look at the debugger header include/v8-debug.h and the d8 source
code in src/d8*. The debugger protocol is documented in
http://code.google.com/p/v8/wiki/DebuggerProtocol.

Regards,
Søren

On Mon, May 7, 2012 at 6:39 PM, Camilo Aguilar <[email protected]>wrote:

> Hey Søren, thanks for your explanation, I was really looking forward to
> your comments.
>
> At this point, based in your and Yang answers, it seems like using
> --expose_debug_as is not a good idea in order to implement a fully working
> debugger backend for WebKit DevTools, using only javascript in nodejs.
>
> Søren, Debug::DebugBreak() seems pretty straightforward from a user
> standpoint. What about resuming the execution?
>
> On Mon, May 7, 2012 at 3:03 AM, Søren Gjesse <[email protected]> wrote:
>
>> 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
>>
>
>  --
> 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