Add source sending feature to the debugger. (#1932)

With this feature the debugger webIDE and the python client can able to send a source code to the debugger while that is running in wait mode.
This feature can be activated with the --debugger-wait-source switch and the debugger will wait for the source messages.
If every message part are received the debugger will continue the exectuion with the initalized options.

JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com
This commit is contained in:
Imre Kiss
2017-08-03 14:29:47 +02:00
committed by Zoltan Herczeg
parent a3885be6ce
commit 3e3d6373b8
16 changed files with 423 additions and 86 deletions
+27
View File
@@ -281,6 +281,7 @@ typedef enum
OPT_SHOW_RE_OP,
OPT_DEBUG_SERVER,
OPT_DEBUG_PORT,
OPT_DEBUGGER_WAIT_SOURCE,
OPT_SAVE_SNAP_GLOBAL,
OPT_SAVE_SNAP_EVAL,
OPT_SAVE_LIT_LIST,
@@ -312,6 +313,8 @@ static const cli_opt_t main_opts[] =
.help = "start debug server and wait for a connecting client"),
CLI_OPT_DEF (.id = OPT_DEBUG_PORT, .longopt = "debug-port", .meta = "NUM",
.help = "debug server port (default: 5001)"),
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_SAVE_SNAP_GLOBAL, .longopt = "save-snapshot-for-global", .meta = "FILE",
.help = "save binary snapshot of parsed JS input (for execution in global context)"),
CLI_OPT_DEF (.id = OPT_SAVE_SNAP_EVAL, .longopt = "save-snapshot-for-eval", .meta = "FILE",
@@ -407,6 +410,7 @@ main (int argc,
uint16_t debug_port = 5001;
bool is_repl_mode = false;
bool is_wait_mode = false;
bool no_prompt = false;
cli_state_t cli_state = cli_init (main_opts, argc - 1, argv + 1);
@@ -472,6 +476,14 @@ main (int argc,
}
break;
}
case OPT_DEBUGGER_WAIT_SOURCE:
{
if (check_feature (JERRY_FEATURE_DEBUGGER, cli_state.arg))
{
is_wait_mode = true;
}
break;
}
case OPT_SAVE_SNAP_GLOBAL:
case OPT_SAVE_SNAP_EVAL:
{
@@ -707,6 +719,21 @@ main (int argc,
}
}
if (is_wait_mode)
{
is_repl_mode = false;
#ifdef JERRY_DEBUGGER
jerry_value_t wait_and_run_value;
if (jerry_debugger_wait_and_run_client_source (&wait_and_run_value) == JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED)
{
ret_value = jerry_create_error (JERRY_ERROR_COMMON, (jerry_char_t *) "Connection aborted before source arrived.");
}
jerry_release_value (wait_and_run_value);
#endif /* JERRY_DEBUGGER */
}
if (is_repl_mode)
{
const char *prompt = !no_prompt ? "jerry> " : "";