diff --git a/jerry-core/debugger/jerry-debugger-ws.c b/jerry-core/debugger/jerry-debugger-ws.c index ab7880cf5..2d4a98cf2 100644 --- a/jerry-core/debugger/jerry-debugger-ws.c +++ b/jerry-core/debugger/jerry-debugger-ws.c @@ -65,9 +65,12 @@ typedef struct static void jerry_debugger_close_connection_tcp (bool log_error) /**< log error */ { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); - JERRY_CONTEXT (jerry_init_flags) &= (uint32_t) ~JERRY_INIT_DEBUGGER; + uint8_t debugger_flags = JERRY_CONTEXT (debugger_flags); + debugger_flags = (uint8_t) (debugger_flags & ~(JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_VM_STOP)); + debugger_flags = (uint8_t) (debugger_flags | JERRY_DEBUGGER_VM_IGNORE); + JERRY_CONTEXT (debugger_flags) = debugger_flags; if (log_error) { @@ -92,7 +95,7 @@ static bool jerry_debugger_send_tcp (const uint8_t *data_p, /**< data pointer */ size_t data_size) /**< data size */ { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); do { @@ -314,9 +317,6 @@ jerry_debugger_accept_connection () JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); - /* Disable debugger flag temporarily. */ - JERRY_CONTEXT (jerry_init_flags) &= (uint32_t) ~JERRY_INIT_DEBUGGER; - addr.sin_family = AF_INET; addr.sin_port = htons (JERRY_DEBUGGER_PORT); addr.sin_addr.s_addr = INADDR_ANY; @@ -363,8 +363,7 @@ jerry_debugger_accept_connection () close (server_socket); - /* Enable debugger flag again. */ - JERRY_CONTEXT (jerry_init_flags) |= JERRY_INIT_DEBUGGER; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CONNECTED); bool is_handshake_ok = false; @@ -403,7 +402,7 @@ jerry_debugger_accept_connection () jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Connected from: %s\n", inet_ntoa (addr.sin_addr)); - JERRY_CONTEXT (debugger_stop_exec) = true; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; return true; @@ -438,7 +437,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MAX_RECEIVE_SIZE < 126, * * Note: * If the function returns with true, the value of - * JERRY_CONTEXT (debugger_stop_exec) should be ignored. + * JERRY_DEBUGGER_VM_STOP flag should be ignored. * * @return true - if execution should be resumed, * false - otherwise @@ -446,7 +445,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MAX_RECEIVE_SIZE < 126, bool jerry_debugger_receive (void) { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); JERRY_CONTEXT (debugger_message_delay) = JERRY_DEBUGGER_MESSAGE_FREQUENCY; @@ -458,30 +457,27 @@ jerry_debugger_receive (void) while (true) { uint32_t offset = JERRY_CONTEXT (debugger_receive_buffer_offset); + ssize_t byte_recv = recv (JERRY_CONTEXT (debugger_connection), recv_buffer_p + offset, JERRY_DEBUGGER_MAX_BUFFER_SIZE - offset, 0); - if (byte_recv <= 0) + if (byte_recv < 0) { - if (byte_recv < 0 && errno != EWOULDBLOCK) + if (errno != EWOULDBLOCK) { jerry_debugger_close_connection_tcp (true); return true; } - if (expected_message_type != 0) - { - continue; - } - - return resume_exec; + byte_recv = 0; } - JERRY_CONTEXT (debugger_receive_buffer_offset) += (uint32_t) byte_recv; + offset += (uint32_t) byte_recv; + JERRY_CONTEXT (debugger_receive_buffer_offset) = (uint16_t) offset; - if (JERRY_CONTEXT (debugger_receive_buffer_offset) < sizeof (jerry_debugger_receive_header_t)) + if (offset < sizeof (jerry_debugger_receive_header_t)) { if (expected_message_type != 0) { @@ -510,7 +506,7 @@ jerry_debugger_receive (void) uint32_t message_size = (uint32_t) (recv_buffer_p[1] & JERRY_DEBUGGER_WEBSOCKET_LENGTH_MASK); uint32_t message_total_size = (uint32_t) (message_size + sizeof (jerry_debugger_receive_header_t)); - if (JERRY_CONTEXT (debugger_receive_buffer_offset) < message_total_size) + if (offset < message_total_size) { if (expected_message_type != 0) { @@ -551,14 +547,14 @@ jerry_debugger_receive (void) return true; } - if (message_total_size < JERRY_CONTEXT (debugger_receive_buffer_offset)) + if (message_total_size < offset) { memcpy (recv_buffer_p, recv_buffer_p + message_total_size, - JERRY_CONTEXT (debugger_receive_buffer_offset) - message_total_size); + offset - message_total_size); } - JERRY_CONTEXT (debugger_receive_buffer_offset) -= message_total_size; + JERRY_CONTEXT (debugger_receive_buffer_offset) = (uint16_t) (offset - message_total_size); } } /* jerry_debugger_receive */ diff --git a/jerry-core/debugger/jerry-debugger.c b/jerry-core/debugger/jerry-debugger.c index 9ee87f71f..928afab94 100644 --- a/jerry-core/debugger/jerry-debugger.c +++ b/jerry-core/debugger/jerry-debugger.c @@ -129,11 +129,12 @@ static bool jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated string */ size_t eval_string_size) /**< evaluated string size */ { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); + JERRY_ASSERT (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_IGNORE)); - JERRY_CONTEXT (jerry_init_flags) &= (uint32_t) ~JERRY_INIT_DEBUGGER; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_IGNORE); ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p, eval_string_size, true, false); - JERRY_CONTEXT (jerry_init_flags) |= (uint32_t) JERRY_INIT_DEBUGGER; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_IGNORE); if (!ECMA_IS_VALUE_ERROR (result)) { @@ -338,7 +339,7 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec { JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t); - JERRY_CONTEXT (debugger_stop_exec) = true; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; *resume_exec_p = false; return true; @@ -348,9 +349,8 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec { JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t); - JERRY_CONTEXT (debugger_stop_exec) = false; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; - *resume_exec_p = true; return true; } @@ -359,7 +359,7 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec { JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t); - JERRY_CONTEXT (debugger_stop_exec) = true; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; *resume_exec_p = true; return true; @@ -369,7 +369,7 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec { JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t); - JERRY_CONTEXT (debugger_stop_exec) = true; + JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = JERRY_CONTEXT (vm_top_context_p); *resume_exec_p = true; return true; @@ -444,7 +444,7 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the rec void jerry_debugger_breakpoint_hit (void) { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_breakpoint_hit_t, breakpoint_hit_p); @@ -479,7 +479,7 @@ jerry_debugger_breakpoint_hit (void) void jerry_debugger_send_type (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_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p); @@ -552,7 +552,7 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */ const uint8_t *string_p, /**< string data */ size_t string_length) /**< length of string */ { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); const size_t max_fragment_len = JERRY_DEBUGGER_SEND_MAX (uint8_t); @@ -590,7 +590,7 @@ 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 (jerry_init_flags) & JERRY_INIT_DEBUGGER); + 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 */ @@ -605,7 +605,7 @@ bool jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, /**< message type */ ecma_compiled_code_t *compiled_code_p) /**< byte code pointer */ { - JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_byte_code_cp_t, byte_code_cp_p); diff --git a/jerry-core/debugger/jerry-debugger.h b/jerry-core/debugger/jerry-debugger.h index e472f6b26..8da5fa8a5 100644 --- a/jerry-core/debugger/jerry-debugger.h +++ b/jerry-core/debugger/jerry-debugger.h @@ -43,6 +43,17 @@ #define JERRY_DEBUGGER_SEND_MAX(type) \ ((JERRY_DEBUGGER_MAX_SEND_SIZE - sizeof (jerry_debugger_send_header_t) - 1) / sizeof (type)) +/** + * Debugger option flags. + */ +typedef enum +{ + JERRY_DEBUGGER_CONNECTED = 1u << 0, /**< debugger is connected */ + JERRY_DEBUGGER_VM_STOP = 1u << 1, /**< stop at the next breakpoint + * regardless it is enabled */ + JERRY_DEBUGGER_VM_IGNORE = 1u << 2, /**< ignore all breakpoints */ +} jerry_debugger_flags_t; + /** * Types for the package. */ diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c index 4f48863f8..9a75650ab 100644 --- a/jerry-core/ecma/base/ecma-helpers.c +++ b/jerry-core/ecma/base/ecma-helpers.c @@ -1476,7 +1476,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */ } #ifdef JERRY_DEBUGGER - if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) { if (jerry_debugger_send_function_cp (JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP, bytecode_p)) { diff --git a/jerry-core/jcontext/jcontext.h b/jerry-core/jcontext/jcontext.h index ec0e06f1d..7b8628725 100644 --- a/jerry-core/jcontext/jcontext.h +++ b/jerry-core/jcontext/jcontext.h @@ -83,13 +83,13 @@ typedef struct #endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */ #ifdef JERRY_DEBUGGER - uint32_t debugger_message_delay; /**< call receive message when reaches zero */ + uint16_t debugger_message_delay; /**< call receive message when reaches zero */ + uint16_t debugger_receive_buffer_offset; /**< receive buffer offset */ uint8_t debugger_send_buffer[JERRY_DEBUGGER_MAX_BUFFER_SIZE]; /**< buffer for sending messages */ uint8_t debugger_receive_buffer[JERRY_DEBUGGER_MAX_BUFFER_SIZE]; /**< buffer for receiving messages */ jmem_cpointer_t debugger_byte_code_free_head; /**< head of byte code free linked list */ - uint32_t debugger_receive_buffer_offset; /**< receive buffer offset */ int debugger_connection; /**< hold the file descriptor for socket communication */ - bool debugger_stop_exec; /**< stop at the next breakpoint regardless it is enabled */ + uint8_t debugger_flags; /**< debugger flags */ vm_frame_ctx_t *debugger_stop_context; /**< stop only if the current context is equal to this context */ #endif /* JERRY_DEBUGGER */ diff --git a/jerry-core/jerry.c b/jerry-core/jerry.c index 8ae75382d..4e2e0ad6c 100644 --- a/jerry-core/jerry.c +++ b/jerry-core/jerry.c @@ -175,7 +175,7 @@ jerry_cleanup (void) ecma_finalize (); #ifdef JERRY_DEBUGGER - if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) { jerry_debugger_close_connection (); } @@ -329,7 +329,7 @@ jerry_parse_named_resource (const jerry_char_t *name_p, /**< name (usually a fil bool is_strict) /**< strict mode */ { #ifdef JERRY_DEBUGGER - if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) { jerry_debugger_send_string (JERRY_DEBUGGER_RESOURCE_NAME, name_p, name_length); } diff --git a/jerry-core/parser/js/js-parser-statm.c b/jerry-core/parser/js/js-parser-statm.c index 9b54e5c72..ff7fcb861 100644 --- a/jerry-core/parser/js/js-parser-statm.c +++ b/jerry-core/parser/js/js-parser-statm.c @@ -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 */ diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index a2e10e520..334939f5f 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -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); } diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index af1179898..22468d08a 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -2308,11 +2308,13 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ case VM_OC_BREAKPOINT_ENABLED: { #ifdef JERRY_DEBUGGER - if (!(JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_IGNORE) { continue; } + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); + frame_ctx_p->byte_code_p = byte_code_start_p; jerry_debugger_breakpoint_hit (); @@ -2322,14 +2324,16 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ case VM_OC_BREAKPOINT_DISABLED: { #ifdef JERRY_DEBUGGER - if (!(JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_DEBUGGER)) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_IGNORE) { continue; } + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED); + frame_ctx_p->byte_code_p = byte_code_start_p; - if (JERRY_CONTEXT (debugger_stop_exec) + if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_STOP) && (JERRY_CONTEXT (debugger_stop_context) == NULL || JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p))) { @@ -2350,7 +2354,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ continue; } - if (JERRY_CONTEXT (debugger_stop_exec)) + if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_STOP) { JERRY_ASSERT (JERRY_CONTEXT (debugger_stop_context) == NULL); jerry_debugger_breakpoint_hit (); @@ -2663,7 +2667,7 @@ vm_execute (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ if (JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p)) { /* The engine will stop when the next breakpoint is reached. */ - JERRY_ASSERT (JERRY_CONTEXT (debugger_stop_exec)); + JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; } #endif /* JERRY_DEBUGGER */