Introduce debugger status flags to control the operation of the debugger. (#1596)

Two issues were fixed as well: inserting breakpoints before non-directive
prologue strings and the receive can process multiple messages.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-02-21 11:57:04 +01:00
committed by GitHub
parent 33138c09f5
commit 00e3de230f
9 changed files with 99 additions and 77 deletions
+29 -18
View File
@@ -327,7 +327,7 @@ parser_parse_var_statement (parser_context_t *context_p) /**< context */
if (context_p->token.type == LEXER_ASSIGN)
{
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
if (ident_line_counter != context_p->last_breakpoint_line)
{
@@ -402,7 +402,7 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
}
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_function_name (name_p->u.char_p,
name_p->prop.length);
@@ -1609,7 +1609,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
#ifdef JERRY_DEBUGGER
/* Set lexical enviroment for the debugger. */
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
}
@@ -1650,6 +1650,19 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|| context_p->token.type == LEXER_LEFT_SQUARE
|| context_p->token.type == LEXER_DOT)
{
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
&& context_p->line != context_p->last_breakpoint_line)
{
parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
parser_flush_cbc (context_p);
parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->line);
context_p->last_breakpoint_line = context_p->line;
}
#endif /* JERRY_DEBUGGER */
/* The string is part of an expression statement. */
context_p->status_flags = status_flags;
@@ -1703,24 +1716,22 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
#endif /* !JERRY_NDEBUG */
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
&& context_p->line != context_p->last_breakpoint_line
&& context_p->token.type != LEXER_SEMICOLON
&& context_p->token.type != LEXER_LEFT_BRACE
&& context_p->token.type != LEXER_RIGHT_BRACE
&& context_p->token.type != LEXER_KEYW_VAR
&& context_p->token.type != LEXER_KEYW_FUNCTION
&& context_p->token.type != LEXER_KEYW_CASE
&& context_p->token.type != LEXER_KEYW_DEFAULT)
{
if (context_p->line != context_p->last_breakpoint_line
&& context_p->token.type != LEXER_SEMICOLON
&& context_p->token.type != LEXER_LEFT_BRACE
&& context_p->token.type != LEXER_RIGHT_BRACE
&& context_p->token.type != LEXER_KEYW_VAR
&& context_p->token.type != LEXER_KEYW_FUNCTION
&& context_p->token.type != LEXER_KEYW_CASE
&& context_p->token.type != LEXER_KEYW_DEFAULT)
{
parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
parser_flush_cbc (context_p);
parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
parser_flush_cbc (context_p);
parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->line);
parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->line);
context_p->last_breakpoint_line = context_p->line;
}
context_p->last_breakpoint_line = context_p->line;
}
#endif /* JERRY_DEBUGGER */
+10 -10
View File
@@ -1273,7 +1273,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
JERRY_ASSERT (context_p->literal_count <= PARSER_MAXIMUM_NUMBER_OF_LITERALS);
#ifdef JERRY_DEBUGGER
if ((JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& context_p->breakpoint_info_count > 0)
{
parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST);
@@ -1687,7 +1687,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
}
#ifdef JERRY_DEBUGGER
if ((JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& context_p->breakpoint_info_count > 0)
{
parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST);
@@ -1798,7 +1798,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
}
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_function_cp (JERRY_DEBUGGER_BYTE_CODE_CP, compiled_code_p);
}
@@ -1988,7 +1988,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
#ifdef JERRY_DEBUGGER
if ((JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
&& context_p->breakpoint_info_count > 0)
{
parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST);
@@ -2047,7 +2047,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
#endif /* PARSER_DUMP_BYTE_CODE */
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
/* This option has a high memory and performance costs,
* but it is necessary for executing eval operations by the debugger. */
@@ -2076,7 +2076,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
LEXER_IDENT_LITERAL);
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_function_name (context_p->lit_object.literal_p->u.char_p,
context_p->lit_object.literal_p->prop.length);
@@ -2101,7 +2101,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
}
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_type (JERRY_DEBUGGER_PARSE_FUNCTION);
}
@@ -2315,7 +2315,7 @@ parser_append_breakpoint_info (parser_context_t *context_p, /**< context */
jerry_debugger_header_type_t type, /**< message type */
uint32_t value) /**< line or offset of the breakpoint */
{
JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER);
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
if (context_p->breakpoint_info_count >= JERRY_DEBUGGER_SEND_MAX (parser_list_t))
{
@@ -2333,7 +2333,7 @@ void
parser_send_breakpoints (parser_context_t *context_p, /**< context */
jerry_debugger_header_type_t type) /**< message type */
{
JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER);
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
JERRY_ASSERT (context_p->breakpoint_info_count > 0);
jerry_debugger_send_data (type,
@@ -2376,7 +2376,7 @@ parser_parse_script (const uint8_t *source_p, /**< source code */
if (!*bytecode_data_p)
{
#ifdef JERRY_DEBUGGER
if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_type (JERRY_DEBUGGER_PARSE_ERROR);
}