[Debugger] Implementation of transport over serial connection (#2800)

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka
2019-03-26 09:39:51 +01:00
committed by GitHub
parent 0981985134
commit 3d656cdf57
14 changed files with 577 additions and 51 deletions
+45 -7
View File
@@ -318,6 +318,8 @@ typedef enum
OPT_DEBUG_SERVER,
OPT_DEBUG_PORT,
OPT_DEBUG_CHANNEL,
OPT_DEBUG_PROTOCOL,
OPT_DEBUG_SERIAL_CONFIG,
OPT_DEBUGGER_WAIT_SOURCE,
OPT_EXEC_SNAP,
OPT_EXEC_SNAP_FUNC,
@@ -349,6 +351,10 @@ static const cli_opt_t main_opts[] =
.help = "debug server port (default: 5001)"),
CLI_OPT_DEF (.id = OPT_DEBUG_CHANNEL, .longopt = "debug-channel", .meta = "[websocket|rawpacket]",
.help = "Specify the debugger transmission channel (default: websocket)"),
CLI_OPT_DEF (.id = OPT_DEBUG_PROTOCOL, .longopt = "debug-protocol", .meta = "PROTOCOL",
.help = "Specify the transmission protocol over the communication channel (tcp|serial, default: tcp)"),
CLI_OPT_DEF (.id = OPT_DEBUG_SERIAL_CONFIG, .longopt = "serial-config", .meta = "OPTIONS_STRING",
.help = "Configure parameters for serial port (default: /dev/ttyS0,115200,8,N,1)"),
CLI_OPT_DEF (.id = OPT_DEBUGGER_WAIT_SOURCE, .longopt = "debugger-wait-source",
.help = "wait for an executable source from the client"),
CLI_OPT_DEF (.id = OPT_EXEC_SNAP, .longopt = "exec-snapshot", .meta = "FILE",
@@ -422,21 +428,33 @@ context_alloc (size_t size,
static void
init_engine (jerry_init_flag_t flags, /**< initialized flags for the engine */
char *debug_channel, /**< enable the debugger init or not */
uint16_t debug_port) /**< the debugger port */
char *debug_protocol, /**< enable the debugger init or not */
uint16_t debug_port, /**< the debugger port for tcp protocol */
char *debug_serial_config) /**< configuration string for serial protocol */
{
jerry_init (flags);
if (strcmp (debug_channel, ""))
{
bool tcp_created = jerryx_debugger_tcp_create (debug_port);
bool protocol = false;
if (!strcmp (debug_protocol, "tcp"))
{
protocol = jerryx_debugger_tcp_create (debug_port);
}
else
{
assert (!strcmp (debug_protocol, "serial"));
protocol = jerryx_debugger_serial_create (debug_serial_config);
}
if (!strcmp (debug_channel, "rawpacket"))
{
jerryx_debugger_after_connect (tcp_created && jerryx_debugger_rp_create ());
jerryx_debugger_after_connect (protocol && jerryx_debugger_rp_create ());
}
else
{
assert (!strcmp (debug_channel, "websocket"));
jerryx_debugger_after_connect (tcp_created && jerryx_debugger_ws_create ());
jerryx_debugger_after_connect (protocol && jerryx_debugger_ws_create ());
}
}
@@ -464,6 +482,8 @@ main (int argc,
bool start_debug_server = false;
uint16_t debug_port = 5001;
char *debug_channel = "websocket";
char *debug_protocol = "tcp";
char *debug_serial_config = "/dev/ttyS0,115200,8,N,1";
bool is_repl_mode = false;
bool is_wait_mode = false;
@@ -542,6 +562,24 @@ main (int argc,
}
break;
}
case OPT_DEBUG_PROTOCOL:
{
if (check_feature (JERRY_FEATURE_DEBUGGER, cli_state.arg))
{
debug_protocol = (char *) cli_consume_string (&cli_state);
check_usage (!strcmp (debug_protocol, "tcp") || !strcmp (debug_protocol, "serial"),
argv[0], "Error: invalid value for --debug-protocol: ", cli_state.arg);
}
break;
}
case OPT_DEBUG_SERIAL_CONFIG:
{
if (check_feature (JERRY_FEATURE_DEBUGGER, cli_state.arg))
{
debug_serial_config = (char *) cli_consume_string (&cli_state);
}
break;
}
case OPT_DEBUGGER_WAIT_SOURCE:
{
if (check_feature (JERRY_FEATURE_DEBUGGER, cli_state.arg))
@@ -640,7 +678,7 @@ main (int argc,
debug_channel = "";
}
init_engine (flags, debug_channel, debug_port);
init_engine (flags, debug_channel, debug_protocol, debug_port, debug_serial_config);
jerry_value_t ret_value = jerry_create_undefined ();
@@ -758,7 +796,7 @@ main (int argc,
break;
}
init_engine (flags, debug_channel, debug_port);
init_engine (flags, debug_channel, debug_protocol, debug_port, debug_serial_config);
ret_value = jerry_create_undefined ();
}
@@ -802,7 +840,7 @@ main (int argc,
jerry_cleanup ();
init_engine (flags, debug_channel, debug_port);
init_engine (flags, debug_channel, debug_protocol, debug_port, debug_serial_config);
ret_value = jerry_create_undefined ();
}