From ed53bb3917e80a2f1283712a7dbf151883f490de Mon Sep 17 00:00:00 2001 From: Imre Kiss Date: Mon, 12 Mar 2018 09:02:50 +0100 Subject: [PATCH] Add finish debugger command. With this command the engine continue running just after the function in the current stack frame returns. JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com --- jerry-core/debugger/debugger.c | 17 +++++++++-- jerry-core/debugger/debugger.h | 9 +++--- jerry-debugger/jerry-client-ws.html | 15 +++++++--- jerry-debugger/jerry-client-ws.py | 16 ++++++++--- tests/debugger/do_finish.cmd | 6 ++++ tests/debugger/do_finish.expected | 20 +++++++++++++ tests/debugger/do_finish.js | 44 +++++++++++++++++++++++++++++ tests/debugger/do_help.expected | 6 ++-- tools/pylint/pylintrc | 2 +- 9 files changed, 117 insertions(+), 18 deletions(-) create mode 100644 tests/debugger/do_finish.cmd create mode 100644 tests/debugger/do_finish.expected create mode 100644 tests/debugger/do_finish.js diff --git a/jerry-core/debugger/debugger.c b/jerry-core/debugger/debugger.c index ebc0a364b5..0ff7e9bcff 100644 --- a/jerry-core/debugger/debugger.c +++ b/jerry-core/debugger/debugger.c @@ -35,8 +35,8 @@ * debugger versioning. */ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 27 - && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 18 - && JERRY_DEBUGGER_VERSION == 1, + && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19 + && JERRY_DEBUGGER_VERSION == 2, debugger_version_correlates_to_message_type_count); /** @@ -438,6 +438,19 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer to the rece return true; } + case JERRY_DEBUGGER_FINISH: + { + JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t); + + JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP); + + /* This will point to the current context's parent (where the function was called) + * and in case of NULL the result will the same as in case of STEP. */ + JERRY_CONTEXT (debugger_stop_context) = JERRY_CONTEXT (vm_top_context_p->prev_context_p); + *resume_exec_p = true; + return true; + } + case JERRY_DEBUGGER_GET_BACKTRACE: { JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_get_backtrace_t); diff --git a/jerry-core/debugger/debugger.h b/jerry-core/debugger/debugger.h index 0deeb8e3d9..3c0d27664c 100644 --- a/jerry-core/debugger/debugger.h +++ b/jerry-core/debugger/debugger.h @@ -26,7 +26,7 @@ /** * JerryScript debugger protocol version. */ -#define JERRY_DEBUGGER_VERSION (1) +#define JERRY_DEBUGGER_VERSION (2) /** * Frequency of calling jerry_debugger_receive() by the VM. @@ -178,11 +178,12 @@ typedef enum JERRY_DEBUGGER_CONTINUE = 12, /**< continue execution */ JERRY_DEBUGGER_STEP = 13, /**< next breakpoint, step into functions */ JERRY_DEBUGGER_NEXT = 14, /**< next breakpoint in the same context */ + JERRY_DEBUGGER_FINISH = 15, /**< Continue running just after the function in the current stack frame returns */ /* The following messages are only available in breakpoint * mode and this mode is kept after the message is processed. */ - JERRY_DEBUGGER_GET_BACKTRACE = 15, /**< get backtrace */ - JERRY_DEBUGGER_EVAL = 16, /**< first message of evaluating a string */ - JERRY_DEBUGGER_EVAL_PART = 17, /**< next message of evaluating a string */ + JERRY_DEBUGGER_GET_BACKTRACE = 16, /**< get backtrace */ + JERRY_DEBUGGER_EVAL = 17, /**< first message of evaluating a string */ + JERRY_DEBUGGER_EVAL_PART = 18, /**< next message of evaluating a string */ JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */ } jerry_debugger_header_type_t; diff --git a/jerry-debugger/jerry-client-ws.html b/jerry-debugger/jerry-client-ws.html index c0fd2861f6..b8f3f015ce 100644 --- a/jerry-debugger/jerry-client-ws.html +++ b/jerry-debugger/jerry-client-ws.html @@ -36,7 +36,7 @@

JerryScript HTML (WebSocket) Debugger Client