Add context reset to the debugger.
- The context reset request message can be sent anytime from a client. - After the message received the engine will call the cleanup and init when in the source waiting mode (which means the currently processed file will be executed). - After the reinitialization is done, the engine will wait for a new client connection(rest of the work is the client's responsibility). JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com
This commit is contained in:
@@ -109,6 +109,7 @@ jerry_debugger_init (uint16_t port) /**< server port number */
|
||||
* @return enum JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED - if the source is not received
|
||||
* JERRY_DEBUGGER_SOURCE_RECEIVED - if a source code received
|
||||
* JERRY_DEBUGGER_SOURCE_END - the end of the source codes
|
||||
* JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED - the end of the context
|
||||
*/
|
||||
jerry_debugger_wait_and_run_type_t
|
||||
jerry_debugger_wait_and_run_client_source (jerry_value_t *return_value) /**< [out] parse and run return value */
|
||||
@@ -135,10 +136,21 @@ jerry_debugger_wait_and_run_client_source (jerry_value_t *return_value) /**< [ou
|
||||
break;
|
||||
}
|
||||
|
||||
/* Stop executing the current context. */
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONTEXT_RESET_MODE))
|
||||
{
|
||||
ret_type = JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED;
|
||||
JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
|
||||
& ~JERRY_DEBUGGER_CONTEXT_RESET_MODE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Stop waiting for a new source file. */
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_NO_SOURCE))
|
||||
{
|
||||
ret_type = JERRY_DEBUGGER_SOURCE_END;
|
||||
JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
|
||||
& ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -586,6 +586,25 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec
|
||||
return true;
|
||||
}
|
||||
|
||||
case JERRY_DEBUGGER_CONTEXT_RESET:
|
||||
{
|
||||
if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_SOURCE_MODE))
|
||||
{
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Not in client source mode\n");
|
||||
jerry_debugger_close_connection ();
|
||||
return false;
|
||||
}
|
||||
|
||||
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
|
||||
|
||||
JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
|
||||
JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CONTEXT_RESET_MODE);
|
||||
|
||||
*resume_exec_p = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Unexpected message.");
|
||||
|
||||
@@ -90,6 +90,7 @@ typedef enum
|
||||
JERRY_DEBUGGER_VM_IGNORE_EXCEPTION = 1u << 4, /**< debugger stop at an exception */
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_MODE = 1u << 5, /**< debugger waiting for client code */
|
||||
JERRY_DEBUGGER_CLIENT_NO_SOURCE = 1u << 6, /**< debugger leaving the client source loop */
|
||||
JERRY_DEBUGGER_CONTEXT_RESET_MODE = 1u << 7, /**< debugger and engine reinitialization mode */
|
||||
} jerry_debugger_flags_t;
|
||||
|
||||
/**
|
||||
@@ -135,16 +136,17 @@ typedef enum
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE = 6, /**< first message of client source */
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7, /**< next message of client source */
|
||||
JERRY_DEBUGGER_NO_MORE_SOURCES = 8, /**< no more sources notification */
|
||||
JERRY_DEBUGGER_CONTEXT_RESET = 9, /**< context reset request */
|
||||
/* The following messages are only available in breakpoint
|
||||
* mode and they switch the engine to run mode. */
|
||||
JERRY_DEBUGGER_CONTINUE = 9, /**< continue execution */
|
||||
JERRY_DEBUGGER_STEP = 10, /**< next breakpoint, step into functions */
|
||||
JERRY_DEBUGGER_NEXT = 11, /**< next breakpoint in the same context */
|
||||
JERRY_DEBUGGER_CONTINUE = 10, /**< continue execution */
|
||||
JERRY_DEBUGGER_STEP = 11, /**< next breakpoint, step into functions */
|
||||
JERRY_DEBUGGER_NEXT = 12, /**< next breakpoint in the same context */
|
||||
/* The following messages are only available in breakpoint
|
||||
* mode and this mode is kept after the message is processed. */
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 12, /**< get backtrace */
|
||||
JERRY_DEBUGGER_EVAL = 13, /**< first message of evaluating a string */
|
||||
JERRY_DEBUGGER_EVAL_PART = 14, /**< next message of evaluating a string */
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 13, /**< get backtrace */
|
||||
JERRY_DEBUGGER_EVAL = 14, /**< first message of evaluating a string */
|
||||
JERRY_DEBUGGER_EVAL_PART = 15, /**< next message of evaluating a string */
|
||||
} jerry_debugger_header_type_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef enum
|
||||
JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED = 0, /**< source is not received */
|
||||
JERRY_DEBUGGER_SOURCE_RECEIVED = 1, /**< a source has been received */
|
||||
JERRY_DEBUGGER_SOURCE_END = 2, /**< the end of the sources signal received */
|
||||
JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED, /**< the context reset request has been received */
|
||||
} jerry_debugger_wait_and_run_type_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,12 +82,13 @@ var JERRY_DEBUGGER_STOP = 5;
|
||||
var JERRY_DEBUGGER_CLIENT_SOURCE = 6;
|
||||
var JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7;
|
||||
var JERRY_DEBUGGER_NO_MORE_SOURCES = 8;
|
||||
var JERRY_DEBUGGER_CONTINUE = 9;
|
||||
var JERRY_DEBUGGER_STEP = 10;
|
||||
var JERRY_DEBUGGER_NEXT = 11;
|
||||
var JERRY_DEBUGGER_GET_BACKTRACE = 12;
|
||||
var JERRY_DEBUGGER_EVAL = 13;
|
||||
var JERRY_DEBUGGER_EVAL_PART = 14;
|
||||
var JERRY_DEBUGGER_CONTEXT_RESET = 9;
|
||||
var JERRY_DEBUGGER_CONTINUE = 10;
|
||||
var JERRY_DEBUGGER_STEP = 11;
|
||||
var JERRY_DEBUGGER_NEXT = 12;
|
||||
var JERRY_DEBUGGER_GET_BACKTRACE = 13;
|
||||
var JERRY_DEBUGGER_EVAL = 14;
|
||||
var JERRY_DEBUGGER_EVAL_PART = 15;
|
||||
|
||||
var textBox = document.getElementById("log");
|
||||
var commandBox = document.getElementById("command");
|
||||
|
||||
@@ -73,12 +73,13 @@ JERRY_DEBUGGER_STOP = 5
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE = 6
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7
|
||||
JERRY_DEBUGGER_NO_MORE_SOURCES = 8
|
||||
JERRY_DEBUGGER_CONTINUE = 9
|
||||
JERRY_DEBUGGER_STEP = 10
|
||||
JERRY_DEBUGGER_NEXT = 11
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 12
|
||||
JERRY_DEBUGGER_EVAL = 13
|
||||
JERRY_DEBUGGER_EVAL_PART = 14
|
||||
JERRY_DEBUGGER_CONTEXT_RESET = 9
|
||||
JERRY_DEBUGGER_CONTINUE = 10
|
||||
JERRY_DEBUGGER_STEP = 11
|
||||
JERRY_DEBUGGER_NEXT = 12
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 13
|
||||
JERRY_DEBUGGER_EVAL = 14
|
||||
JERRY_DEBUGGER_EVAL_PART = 15
|
||||
|
||||
MAX_BUFFER_SIZE = 128
|
||||
WEBSOCKET_BINARY_FRAME = 2
|
||||
|
||||
@@ -726,6 +726,8 @@ main (int argc,
|
||||
jerry_value_t run_result;
|
||||
jerry_debugger_wait_and_run_type_t receive_status;
|
||||
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
receive_status = jerry_debugger_wait_and_run_client_source (&run_result);
|
||||
@@ -745,6 +747,22 @@ main (int argc,
|
||||
}
|
||||
while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
|
||||
|
||||
if (receive_status == JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED)
|
||||
{
|
||||
jerry_cleanup ();
|
||||
|
||||
jerry_init (flags);
|
||||
jerry_debugger_init (debug_port);
|
||||
|
||||
register_js_function ("assert", jerryx_handler_assert);
|
||||
register_js_function ("gc", jerryx_handler_gc);
|
||||
register_js_function ("print", jerryx_handler_print);
|
||||
|
||||
ret_value = jerry_create_undefined ();
|
||||
}
|
||||
}
|
||||
while (receive_status == JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED);
|
||||
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user