Fix logging issues in the debugger. (#2483)
- Properly handle logging during transport close - Properly display data during parse Furthermore hide global functions of the debugger. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -48,7 +48,7 @@ jerryx_debugger_tcp_log_error (int err_val)
|
||||
static void
|
||||
jerryx_debugger_tcp_close (jerry_debugger_transport_header_t *header_p) /**< tcp implementation */
|
||||
{
|
||||
JERRYX_ASSERT (jerry_debugger_transport_is_connected ());
|
||||
JERRYX_ASSERT (!jerry_debugger_transport_is_connected ());
|
||||
|
||||
jerryx_debugger_transport_tcp_t *tcp_p = (jerryx_debugger_transport_tcp_t *) header_p;
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ jerryx_process_handshake (uint8_t *request_buffer_p) /**< temporary buffer */
|
||||
static void
|
||||
jerryx_debugger_ws_close (jerry_debugger_transport_header_t *header_p) /**< tcp implementation */
|
||||
{
|
||||
JERRYX_ASSERT (jerry_debugger_transport_is_connected ());
|
||||
JERRYX_ASSERT (!jerry_debugger_transport_is_connected ());
|
||||
|
||||
jerry_debugger_transport_free ((void *) header_p, sizeof (jerry_debugger_transport_header_t));
|
||||
} /* jerryx_debugger_ws_close */
|
||||
|
||||
@@ -48,60 +48,95 @@ jerryx_handler_print (const jerry_value_t func_obj_val, /**< function object */
|
||||
|
||||
jerry_value_t ret_val = jerry_create_undefined ();
|
||||
|
||||
for (jerry_length_t arg_index = 0;
|
||||
jerry_value_is_undefined (ret_val) && arg_index < args_cnt;
|
||||
arg_index++)
|
||||
for (jerry_length_t arg_index = 0; arg_index < args_cnt; arg_index++)
|
||||
{
|
||||
jerry_value_t str_val = jerry_value_to_string (args_p[arg_index]);
|
||||
|
||||
if (!jerry_value_is_error (str_val))
|
||||
if (jerry_value_is_error (str_val))
|
||||
{
|
||||
if (arg_index != 0)
|
||||
/* There is no need to free the undefined value. */
|
||||
ret_val = str_val;
|
||||
break;
|
||||
}
|
||||
|
||||
jerry_length_t length = jerry_get_utf8_string_length (str_val);
|
||||
jerry_length_t substr_pos = 0;
|
||||
jerry_char_t substr_buf[256];
|
||||
|
||||
do
|
||||
{
|
||||
jerry_size_t substr_size = jerry_substring_to_utf8_char_buffer (str_val,
|
||||
substr_pos,
|
||||
length,
|
||||
substr_buf,
|
||||
256 - 1);
|
||||
|
||||
jerry_char_t *buf_end_p = substr_buf + substr_size;
|
||||
|
||||
/* Update start position by the number of utf-8 characters. */
|
||||
for (jerry_char_t *buf_p = substr_buf; buf_p < buf_end_p; buf_p++)
|
||||
{
|
||||
jerryx_port_handler_print_char (' ');
|
||||
/* Skip intermediate utf-8 octets. */
|
||||
if ((*buf_p & 0xc0) != 0x80)
|
||||
{
|
||||
substr_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
jerry_size_t substr_size;
|
||||
jerry_length_t substr_pos = 0;
|
||||
jerry_char_t substr_buf[256];
|
||||
|
||||
while ((substr_size = jerry_substring_to_utf8_char_buffer (str_val,
|
||||
substr_pos,
|
||||
substr_pos + 256,
|
||||
substr_buf,
|
||||
256)) != 0)
|
||||
if (substr_pos == length)
|
||||
{
|
||||
*buf_end_p++ = (arg_index < args_cnt - 1) ? ' ' : '\n';
|
||||
}
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
jerry_debugger_send_output (substr_buf, substr_size);
|
||||
jerry_char_t *debugger_start_p = substr_buf;
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
for (jerry_size_t chr_index = 0; chr_index < substr_size; chr_index++)
|
||||
|
||||
for (jerry_char_t *buf_p = substr_buf; buf_p < buf_end_p; buf_p++)
|
||||
{
|
||||
char chr = (char) *buf_p;
|
||||
|
||||
if (chr != '\0')
|
||||
{
|
||||
char chr = (char) substr_buf[chr_index];
|
||||
if (chr == '\0')
|
||||
{
|
||||
for (jerry_size_t null_index = 0; null_str[null_index] != 0; null_index++)
|
||||
{
|
||||
jerryx_port_handler_print_char (null_str[null_index]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jerryx_port_handler_print_char (chr);
|
||||
}
|
||||
jerryx_port_handler_print_char (chr);
|
||||
continue;
|
||||
}
|
||||
|
||||
substr_pos += substr_size;
|
||||
for (jerry_size_t null_index = 0; null_str[null_index] != '\0'; null_index++)
|
||||
{
|
||||
jerryx_port_handler_print_char (null_str[null_index]);
|
||||
}
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (debugger_start_p < buf_p)
|
||||
{
|
||||
jerry_debugger_send_output (debugger_start_p, (jerry_size_t) (buf_p - debugger_start_p));
|
||||
}
|
||||
|
||||
jerry_debugger_send_output ((jerry_char_t *) null_str, 6);
|
||||
debugger_start_p = buf_p + 1;
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
}
|
||||
|
||||
jerry_release_value (str_val);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_val = str_val;
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (debugger_start_p < buf_end_p)
|
||||
{
|
||||
jerry_debugger_send_output (debugger_start_p, (jerry_size_t) (buf_end_p - debugger_start_p));
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
}
|
||||
while (substr_pos < length);
|
||||
|
||||
jerry_release_value (str_val);
|
||||
}
|
||||
|
||||
jerryx_port_handler_print_char ('\n');
|
||||
if (args_cnt == 0 || jerry_value_is_error (ret_val))
|
||||
{
|
||||
jerryx_port_handler_print_char ('\n');
|
||||
#ifdef JERRY_DEBUGGER
|
||||
jerry_debugger_send_output ((jerry_char_t *) "\n", 1);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
} /* jerryx_handler_print */
|
||||
|
||||
Reference in New Issue
Block a user