33JerryScript provides a remote debugger which allows debugging
44JavaScript programs. The debugger has two main components:
55a server which is part of the JerryScript binary and a
6- separate client application. Currently two debugger clients
7- are available in the /jerry-debugger subdirectory: an HTML
8- and a Python application. These simple applications demonstrate
9- the communication protocol between the client and server and can
10- be reused by integrated development environments.
6+ separate client application. Currently a Python-based debugger
7+ client is available in the /jerry-debugger subdirectory.
8+ This simple application demonstrates the communication protocol
9+ between the client and server, and can be reused by integrated
10+ development environments.
1111
1212## Setting up the debugger server
1313
1414The following arguments must be passed to ` tools/build.py ` :
1515
1616` --jerry-debugger=on --jerry-libc=off `
1717
18- At the moment only a Websocket-based implementation is provided
19- by JerryScript which transmits messages over TCP/IP networks.
18+ The transport layer of the communication protocol is pluggable.
19+ At the moment, a WebSocket-based implementation is provided as a
20+ JerryScript extension, which transmits messages over TCP/IP networks.
2021This implementation requires a socket API which is not yet
2122supported by jerry-libc so the standard libc is used instead.
22- In the future any reliable stream or datagram based protocol
23- can be used for transmitting debugger messages.
23+ If necessary/implemented, any reliable stream or datagram based
24+ protocol can be used for transmitting debugger messages.
2425
2526## Debugging JavaScript applications
2627
@@ -49,8 +50,8 @@ the *Waiting for client connection* message:
4950
5051` --log-level 2 `
5152
52- The HTML client can connect to the IP address of the server with
53- the ` connect ` command. The IP address can be localhost
53+ The Python client can connect to the server by specifying its
54+ IP address on the command line . The address can be localhost
5455if the server and the client are running on the same machine.
5556
5657After the connection is established the execution can be
@@ -65,9 +66,12 @@ All available commands of the client can be queried by the
6566
6667## Integrating debugger support into applications using JerryScript
6768
68- The debugger can be enabled by calling the ` jerry_debugger_init (uint16_t port) `
69- function after the ` jerry_init () ` function. It initializes the debugger
70- and blocks until a client connects.
69+ When using the extension-provided WebSocket transport layer, the
70+ debugger can be enabled by calling `jerryx_debugger_after_connect
71+ (jerryx_debugger_tcp_create (debug_port) && jerryx_debugger_ws_create ())`
72+ after the ` jerry_init () ` function. It initializes the debugger and
73+ blocks until a client connects. (Custom transport layers may be
74+ implemented and initialized similarly.)
7175
7276The resource name provided to ` jerry_parse () ` is used by the client
7377to identify the resource name of the source code. This resource name
@@ -76,7 +80,7 @@ is usually a file name.
7680## JerryScript debugger C-API interface
7781
7882The following section describes the debugger functions
79- available for the host application.
83+ available to the host application.
8084
8185## JerryScript debugger types
8286
@@ -107,36 +111,6 @@ typedef jerry_value_t
107111
108112## JerryScript debugger functions
109113
110- ### jerry_debugger_init
111-
112- ** Summary**
113-
114- Debugger server initialization. Must be called after ` jerry_init ` .
115-
116- ** Prototype**
117-
118- ``` c
119- void
120- jerry_debugger_init (uint16_t port);
121- ```
122-
123- - `port` - Server port number
124-
125-
126- **Example**
127-
128- ```c
129- {
130- jerry_init (JERRY_INIT_EMPTY);
131- jerry_debugger_init (5001);
132-
133- // ...
134-
135- jerry_cleanup ();
136- }
137- ```
138-
139-
140114### jerry_debugger_is_connected
141115
142116** Summary**
@@ -155,7 +129,8 @@ jerry_debugger_is_connected (void);
155129```c
156130{
157131 jerry_init (JERRY_INIT_EMPTY);
158- jerry_debugger_init (5001);
132+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
133+ && jerryx_debugger_ws_create ());
159134
160135 if (jerry_debugger_is_connected ())
161136 {
@@ -187,7 +162,8 @@ jerry_debugger_stop (void)
187162```c
188163{
189164 jerry_init (JERRY_INIT_EMPTY);
190- jerry_debugger_init (5001);
165+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
166+ && jerryx_debugger_ws_create ());
191167
192168 jerry_debugger_stop ();
193169
@@ -221,7 +197,8 @@ jerry_debugger_continue (void)
221197```c
222198{
223199 jerry_init (JERRY_INIT_EMPTY);
224- jerry_debugger_init (5001);
200+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
201+ && jerryx_debugger_ws_create ());
225202
226203 jerry_debugger_continue ();
227204
@@ -233,7 +210,7 @@ jerry_debugger_continue (void)
233210
234211- [ jerry_debugger_stop] ( #jerry_debugger_stop )
235212
236- ### jerry_debugger_disable_stop_at_breakpoint
213+ ### jerry_debugger_stop_at_breakpoint
237214
238215** Summary**
239216
@@ -255,7 +232,8 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint)
255232```c
256233{
257234 jerry_init (JERRY_INIT_EMPTY);
258- jerry_debugger_init (5001);
235+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
236+ && jerryx_debugger_ws_create ());
259237
260238 jerry_debugger_stop_at_breakpoint (true);
261239
@@ -323,7 +301,8 @@ int main ()
323301 * received. Applications usually registers their core bindings
324302 * here as well (e.g. print, setTimeout). */
325303 jerry_init (JERRY_INIT_EMPTY);
326- jerry_debugger_init (5001);
304+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
305+ && jerryx_debugger_ws_create ());
327306
328307 do
329308 {
@@ -368,7 +347,8 @@ jerry_debugger_send_output (jerry_char_t buffer[], jerry_size_t string_size)
368347```c
369348{
370349 jerry_init (JERRY_INIT_EMPTY);
371- jerry_debugger_init (5001);
350+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
351+ && jerryx_debugger_ws_create ());
372352
373353 jerry_char_t my_output = "Hey, this should be sent too!";
374354 jerry_size_t my_output_size = sizeof (my_output);
@@ -397,7 +377,8 @@ jerry_debugger_send_log (jerry_log_level_t level, jerry_char_t buffer[], jerry_s
397377```c
398378{
399379 jerry_init (JERRY_INIT_EMPTY);
400- jerry_debugger_init (5001);
380+ jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
381+ && jerryx_debugger_ws_create ());
401382
402383 jerry_char_t my_log = "Custom diagnostics";
403384 jerry_size_t my_log_size = sizeof (my_log);
0 commit comments