Make debugger port runtime configurable
Convert debug server port from a compile-time constant to a context variable. This enables each engine instance (either running in the same process or in different processes) to listen for connections at different ports, i.e., multiple engines can be debugged at the same time on the same machine. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -19,7 +19,6 @@ project (${JERRY_CORE_NAME} C)
|
||||
# Optional features
|
||||
set(FEATURE_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
|
||||
set(FEATURE_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
|
||||
set(FEATURE_DEBUGGER_PORT "5001" CACHE STRING "Set debugger port number (default: 5001)")
|
||||
set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(FEATURE_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
|
||||
set(FEATURE_JS_PARSER ON CACHE BOOL "Enable js-parser?")
|
||||
@@ -54,7 +53,6 @@ endif()
|
||||
# Status messages
|
||||
message(STATUS "FEATURE_CPOINTER_32_BIT " ${FEATURE_CPOINTER_32_BIT} ${FEATURE_CPOINTER_32_BIT_MESSAGE})
|
||||
message(STATUS "FEATURE_DEBUGGER " ${FEATURE_DEBUGGER})
|
||||
message(STATUS "FEATURE_DEBUGGER_PORT " ${FEATURE_DEBUGGER_PORT})
|
||||
message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
|
||||
message(STATUS "FEATURE_EXTERNAL_CONTEXT " ${FEATURE_EXTERNAL_CONTEXT})
|
||||
message(STATUS "FEATURE_JS_PARSER " ${FEATURE_JS_PARSER})
|
||||
@@ -192,7 +190,6 @@ if(FEATURE_DEBUGGER)
|
||||
endif()
|
||||
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DEBUGGER)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DEBUGGER_PORT=${FEATURE_DEBUGGER_PORT})
|
||||
endif()
|
||||
|
||||
# Memory management stress-test mode
|
||||
|
||||
@@ -88,3 +88,31 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/d
|
||||
JERRY_UNUSED (enable_stop_at_breakpoint);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_stop_at_breakpoint */
|
||||
|
||||
/**
|
||||
* Debugger server initialization. Must be called after jerry_init.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_init (uint16_t port) /**< server port number */
|
||||
{
|
||||
#ifdef JERRY_DEBUGGER
|
||||
JERRY_CONTEXT (debugger_port) = port;
|
||||
jerry_debugger_accept_connection ();
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (port);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_init */
|
||||
|
||||
/**
|
||||
* Debugger server shutdown. Must be called before jerry_cleanup.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_cleanup (void)
|
||||
{
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_close_connection ();
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_cleanup */
|
||||
|
||||
+1
-17
@@ -51,8 +51,7 @@ JERRY_STATIC_ASSERT ((int) ECMA_ERROR_COMMON == (int) JERRY_ERROR_COMMON
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_INIT_EMPTY == (int) JERRY_INIT_EMPTY
|
||||
&& (int) ECMA_INIT_SHOW_OPCODES == (int) JERRY_INIT_SHOW_OPCODES
|
||||
&& (int) ECMA_INIT_SHOW_REGEXP_OPCODES == (int) JERRY_INIT_SHOW_REGEXP_OPCODES
|
||||
&& (int) ECMA_INIT_MEM_STATS == (int) JERRY_INIT_MEM_STATS
|
||||
&& (int) ECMA_INIT_DEBUGGER == (int) JERRY_INIT_DEBUGGER,
|
||||
&& (int) ECMA_INIT_MEM_STATS == (int) JERRY_INIT_MEM_STATS,
|
||||
ecma_init_flag_t_must_be_equal_to_jerry_init_flag_t);
|
||||
|
||||
#ifndef JERRY_JS_PARSER
|
||||
@@ -157,13 +156,6 @@ jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
|
||||
|
||||
jmem_init ();
|
||||
ecma_init ();
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (flags & JERRY_INIT_DEBUGGER)
|
||||
{
|
||||
jerry_debugger_accept_connection ();
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_init */
|
||||
|
||||
/**
|
||||
@@ -184,14 +176,6 @@ jerry_cleanup (void)
|
||||
}
|
||||
|
||||
ecma_finalize ();
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_close_connection ();
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
jmem_finalize ();
|
||||
jerry_make_api_unavailable ();
|
||||
} /* jerry_cleanup */
|
||||
|
||||
@@ -24,13 +24,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* Debugger socket communication port.
|
||||
*/
|
||||
#ifndef JERRY_DEBUGGER_PORT
|
||||
#define JERRY_DEBUGGER_PORT 5001
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Masking-key is available.
|
||||
*/
|
||||
@@ -314,10 +307,8 @@ jerry_debugger_accept_connection (void)
|
||||
struct sockaddr_in addr;
|
||||
socklen_t sin_size = sizeof (struct sockaddr_in);
|
||||
|
||||
JERRY_ASSERT (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_DEBUGGER);
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons (JERRY_DEBUGGER_PORT);
|
||||
addr.sin_port = htons (JERRY_CONTEXT (debugger_port));
|
||||
addr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if ((server_socket = socket (AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
|
||||
@@ -62,7 +62,6 @@ typedef enum
|
||||
ECMA_INIT_SHOW_OPCODES = (1u << 0), /**< dump byte-code to log after parse */
|
||||
ECMA_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */
|
||||
ECMA_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */
|
||||
ECMA_INIT_DEBUGGER = (1u << 4), /**< enable all features required by debugging */
|
||||
} ecma_init_flag_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,7 +56,7 @@ typedef enum
|
||||
JERRY_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */
|
||||
JERRY_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */
|
||||
JERRY_INIT_MEM_STATS_SEPARATE = (1u << 3), /**< deprecated, an unused placeholder now */
|
||||
JERRY_INIT_DEBUGGER = (1u << 4), /**< enable all features required by debugging */
|
||||
JERRY_INIT_DEBUGGER = (1u << 4), /**< deprecated, an unused placeholder now */
|
||||
} jerry_init_flag_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,9 @@ void jerry_debugger_stop (void);
|
||||
void jerry_debugger_continue (void);
|
||||
void jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint);
|
||||
|
||||
void jerry_debugger_init (uint16_t port);
|
||||
void jerry_debugger_cleanup (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -121,6 +121,7 @@ typedef struct
|
||||
uint8_t debugger_message_delay; /**< call receive message when reaches zero */
|
||||
uint16_t debugger_receive_buffer_offset; /**< receive buffer offset */
|
||||
int debugger_connection; /**< holds the file descriptor of the socket communication */
|
||||
uint16_t debugger_port; /**< debugger socket communication port */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
#ifdef JMEM_STATS
|
||||
|
||||
Reference in New Issue
Block a user