Improve breakpoint generator of the debugger. (#1652)

Now the debugger generates a breakpoint for each function before
its first executable statement. This allows inspecting the function
arguments. Position (line and column) info is also added which
simplifies finding of anonymus functions. Several tests were
update to check more corner cases.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-03-13 11:36:34 +01:00
committed by GitHub
parent 57ea06782b
commit 679500b327
30 changed files with 409 additions and 226 deletions
+3 -3
View File
@@ -67,19 +67,19 @@ typedef struct
* Initialize the header of an outgoing message.
*/
#define JERRY_DEBUGGER_INIT_SEND_MESSAGE(message_p) \
(message_p)->header.ws_opcode = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME;
(message_p)->header.ws_opcode = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME
/**
* Set the size of an outgoing message from type.
*/
#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE(message_p, type) \
(message_p)->header.size = (uint8_t) (sizeof (type) - sizeof (jerry_debugger_send_header_t));
(message_p)->header.size = (uint8_t) (sizeof (type) - sizeof (jerry_debugger_send_header_t))
/**
* Set the size of an outgoing message.
*/
#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE(message_p, byte_size) \
(message_p)->header.size = (uint8_t) (byte_size);
(message_p)->header.size = (uint8_t) (byte_size)
bool jerry_debugger_accept_connection (void);
void jerry_debugger_close_connection (void);
+24 -13
View File
@@ -496,7 +496,7 @@ jerry_debugger_send_type (jerry_debugger_header_type_t type) /**< message type *
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p);
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p);
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_type_p, jerry_debugger_send_type_t)
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_type_p, jerry_debugger_send_type_t);
message_type_p->type = (uint8_t) type;
jerry_debugger_send (sizeof (jerry_debugger_send_type_t));
@@ -595,18 +595,6 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */
return jerry_debugger_send (sizeof (jerry_debugger_send_type_t) + string_length);
} /* jerry_debugger_send_string */
/**
* Send the function name to the debugger client.
*/
void
jerry_debugger_send_function_name (const uint8_t *function_name_p, /**< function name */
size_t function_name_length) /**< length of function name */
{
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
jerry_debugger_send_string (JERRY_DEBUGGER_FUNCTION_NAME, function_name_p, function_name_length);
} /* jerry_debugger_send_function_name */
/**
* Send the function compressed pointer to the debugger client.
*
@@ -632,4 +620,27 @@ jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, /**< message
return jerry_debugger_send (sizeof (jerry_debugger_send_byte_code_cp_t));
} /* jerry_debugger_send_function_cp */
/**
* Send function data to the debugger client.
*
* @return true - if the data sent successfully to the debugger client,
* false - otherwise
*/
bool
jerry_debugger_send_parse_function (uint32_t line, /**< line */
uint32_t column) /**< column */
{
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_parse_function_t, message_parse_function_p);
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_parse_function_p);
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_parse_function_p, jerry_debugger_send_parse_function_t);
message_parse_function_p->type = JERRY_DEBUGGER_PARSE_FUNCTION;
memcpy (message_parse_function_p->line, &line, sizeof (uint32_t));
memcpy (message_parse_function_p->column, &column, sizeof (uint32_t));
return jerry_debugger_send (sizeof (jerry_debugger_send_parse_function_t));
} /* jerry_debugger_send_parse_function */
#endif /* JERRY_DEBUGGER */
+12 -1
View File
@@ -172,6 +172,17 @@ typedef struct
uint8_t string[JERRY_DEBUGGER_SEND_MAX (uint8_t)]; /**< string data */
} jerry_debugger_send_string_t;
/**
* Outgoing message: uint32 value.
*/
typedef struct
{
jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t line[sizeof (uint32_t)]; /**< value data */
uint8_t column[sizeof (uint32_t)]; /**< value data */
} jerry_debugger_send_parse_function_t;
/**
* Outgoing message: byte code compressed pointer.
*/
@@ -277,8 +288,8 @@ void jerry_debugger_send_type (jerry_debugger_header_type_t type);
bool jerry_debugger_send_configuration (uint8_t max_message_size);
void jerry_debugger_send_data (jerry_debugger_header_type_t type, const void *data, size_t size);
bool jerry_debugger_send_string (uint8_t message_type, const uint8_t *string_p, size_t string_length);
void jerry_debugger_send_function_name (const uint8_t *function_name_p, size_t function_name_length);
bool jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, ecma_compiled_code_t *compiled_code_p);
bool jerry_debugger_send_parse_function (uint32_t line, uint32_t column);
#endif /* JERRY_DEBUGGER */