diff options
author | Daniella Barsony <bella@inf.u-szeged.hu> | 2018-08-03 11:30:13 +0200 |
---|---|---|
committer | Robert Sipka <rsipka.uszeged@partner.samsung.com> | 2018-08-03 11:30:13 +0200 |
commit | 64051b5bd857985e67b4922ecc654f26144c5520 (patch) | |
tree | 71cd62bd71a35d1bdffa6c50a72bb88aaaa6b2e6 /jerry-core | |
parent | 87897849f6879df10e8ad68a41bf8cf507edf710 (diff) |
Add total frame counter to backtrace in debugger (#2428)
This was needed for the VScode extension so we know in total howmany frames we have in the backtrace.
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
Diffstat (limited to 'jerry-core')
-rw-r--r-- | jerry-core/debugger/debugger.c | 21 | ||||
-rw-r--r-- | jerry-core/debugger/debugger.h | 27 |
2 files changed, 38 insertions, 10 deletions
diff --git a/jerry-core/debugger/debugger.c b/jerry-core/debugger/debugger.c index 9dff4798..7a1a5920 100644 --- a/jerry-core/debugger/debugger.c +++ b/jerry-core/debugger/debugger.c @@ -37,9 +37,9 @@ typedef struct * The number of message types in the debugger should reflect the * debugger versioning. */ -JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 27 +JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 28 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19 - && JERRY_DEBUGGER_VERSION == 4, + && JERRY_DEBUGGER_VERSION == 5, debugger_version_correlates_to_message_type_count); /** @@ -120,6 +120,23 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the max_depth = UINT32_MAX; } + if (get_backtrace_p->get_total_frame_count != 0) + { + JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_backtrace_total_t, backtrace_total_p); + backtrace_total_p->type = JERRY_DEBUGGER_BACKTRACE_TOTAL; + + vm_frame_ctx_t *iter_frame_ctx_p = JERRY_CONTEXT (vm_top_context_p); + uint32_t frame_count = 0; + while (iter_frame_ctx_p != NULL) + { + frame_count++; + iter_frame_ctx_p = iter_frame_ctx_p->prev_context_p; + } + memcpy (backtrace_total_p->frame_count, &frame_count, sizeof (frame_count)); + + jerry_debugger_send (sizeof (jerry_debugger_send_type_t) + sizeof (frame_count)); + } + JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_backtrace_t, backtrace_p); backtrace_p->type = JERRY_DEBUGGER_BACKTRACE; diff --git a/jerry-core/debugger/debugger.h b/jerry-core/debugger/debugger.h index 0f40735c..58c051c6 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 (4) +#define JERRY_DEBUGGER_VERSION (5) /** * Frequency of calling jerry_debugger_receive() by the VM. @@ -149,13 +149,14 @@ typedef enum JERRY_DEBUGGER_EXCEPTION_HIT = 17, /**< notify exception hit */ JERRY_DEBUGGER_EXCEPTION_STR = 18, /**< exception string fragment */ JERRY_DEBUGGER_EXCEPTION_STR_END = 19, /**< exception string last fragment */ - JERRY_DEBUGGER_BACKTRACE = 20, /**< backtrace data */ - JERRY_DEBUGGER_BACKTRACE_END = 21, /**< last backtrace data */ - JERRY_DEBUGGER_EVAL_RESULT = 22, /**< eval result */ - JERRY_DEBUGGER_EVAL_RESULT_END = 23, /**< last part of eval result */ - JERRY_DEBUGGER_WAIT_FOR_SOURCE = 24, /**< engine waiting for source code */ - JERRY_DEBUGGER_OUTPUT_RESULT = 25, /**< output sent by the program to the debugger */ - JERRY_DEBUGGER_OUTPUT_RESULT_END = 26, /**< last output result data */ + JERRY_DEBUGGER_BACKTRACE_TOTAL = 20, /**< number of total frames */ + JERRY_DEBUGGER_BACKTRACE = 21, /**< backtrace data */ + JERRY_DEBUGGER_BACKTRACE_END = 22, /**< last backtrace data */ + JERRY_DEBUGGER_EVAL_RESULT = 23, /**< eval result */ + JERRY_DEBUGGER_EVAL_RESULT_END = 24, /**< last part of eval result */ + JERRY_DEBUGGER_WAIT_FOR_SOURCE = 25, /**< engine waiting for source code */ + JERRY_DEBUGGER_OUTPUT_RESULT = 26, /**< output sent by the program to the debugger */ + JERRY_DEBUGGER_OUTPUT_RESULT_END = 27, /**< last output result data */ JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT, /**< number of different type of output messages by the debugger */ @@ -357,6 +358,15 @@ typedef struct } jerry_debugger_send_backtrace_t; /** + * Outgoing message: number of total frames in backtrace. + */ +typedef struct +{ + uint8_t type; /**< type of the message */ + uint8_t frame_count[sizeof (uint32_t)]; /**< total number of frames*/ +} jerry_debugger_send_backtrace_total_t; + +/** * Incoming message: set behaviour when exception occures. */ typedef struct @@ -382,6 +392,7 @@ typedef struct uint8_t type; /**< type of the message */ uint8_t min_depth[sizeof (uint32_t)]; /**< minimum depth*/ uint8_t max_depth[sizeof (uint32_t)]; /**< maximum depth (0 - unlimited) */ + uint8_t get_total_frame_count; /**< non-zero: if total frame count is also requested */ } jerry_debugger_receive_get_backtrace_t; /** |