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
This commit is contained in:
committed by
Robert Sipka
parent
87897849f6
commit
64051b5bd8
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -356,6 +357,15 @@ typedef struct
|
||||
jerry_debugger_frame_t frames[]; /**< frames */
|
||||
} 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.
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user