Increase the debugger version field size from 1 byte to 4 byte (#2513)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-09-20 09:33:56 +02:00
committed by László Langó
parent df69e1e08b
commit 35fbcd1ffd
3 changed files with 38 additions and 20 deletions
+11 -3
View File
@@ -39,7 +39,7 @@ typedef struct
*/ */
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 28 JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 28
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19
&& JERRY_DEBUGGER_VERSION == 5, && JERRY_DEBUGGER_VERSION == 6,
debugger_version_correlates_to_message_type_count); debugger_version_correlates_to_message_type_count);
/** /**
@@ -880,10 +880,18 @@ jerry_debugger_send_configuration (uint8_t max_message_size) /**< maximum messag
endian_data.uint16_value = 1; endian_data.uint16_value = 1;
configuration_p->type = JERRY_DEBUGGER_CONFIGURATION; configuration_p->type = JERRY_DEBUGGER_CONFIGURATION;
configuration_p->configuration = 0;
if (endian_data.uint8_value[0] == 1)
{
configuration_p->configuration |= (uint8_t) JERRY_DEBUGGER_LITTLE_ENDIAN;
}
uint32_t version = JERRY_DEBUGGER_VERSION;
memcpy (configuration_p->version, &version, sizeof (uint32_t));
configuration_p->max_message_size = max_message_size; configuration_p->max_message_size = max_message_size;
configuration_p->cpointer_size = sizeof (jmem_cpointer_t); configuration_p->cpointer_size = sizeof (jmem_cpointer_t);
configuration_p->little_endian = (endian_data.uint8_value[0] == 1);
configuration_p->version = JERRY_DEBUGGER_VERSION;
return jerry_debugger_send (sizeof (jerry_debugger_send_configuration_t)); return jerry_debugger_send (sizeof (jerry_debugger_send_configuration_t));
} /* jerry_debugger_send_configuration */ } /* jerry_debugger_send_configuration */
+11 -3
View File
@@ -26,7 +26,7 @@
/** /**
* JerryScript debugger protocol version. * JerryScript debugger protocol version.
*/ */
#define JERRY_DEBUGGER_VERSION (5) #define JERRY_DEBUGGER_VERSION (6)
/** /**
* Frequency of calling jerry_debugger_receive() by the VM. * Frequency of calling jerry_debugger_receive() by the VM.
@@ -191,6 +191,14 @@ typedef enum
JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */ JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */
} jerry_debugger_header_type_t; } jerry_debugger_header_type_t;
/**
* Debugger option flags.
*/
typedef enum
{
JERRY_DEBUGGER_LITTLE_ENDIAN = 1u << 0, /**< little endian */
} jerry_debugger_configuration_flags_t;
/** /**
* Subtypes of eval. * Subtypes of eval.
*/ */
@@ -250,10 +258,10 @@ typedef struct
typedef struct typedef struct
{ {
uint8_t type; /**< type of the message */ uint8_t type; /**< type of the message */
uint8_t configuration; /**< configuration option bits */
uint8_t version[sizeof (uint32_t)]; /**< debugger version */
uint8_t max_message_size; /**< maximum incoming message size */ uint8_t max_message_size; /**< maximum incoming message size */
uint8_t cpointer_size; /**< size of compressed pointers */ uint8_t cpointer_size; /**< size of compressed pointers */
uint8_t little_endian; /**< little endian machine */
uint8_t version; /**< debugger version */
} jerry_debugger_send_configuration_t; } jerry_debugger_send_configuration_t;
/** /**
+16 -14
View File
@@ -24,7 +24,7 @@ import struct
import sys import sys
# Expected debugger protocol version. # Expected debugger protocol version.
JERRY_DEBUGGER_VERSION = 5 JERRY_DEBUGGER_VERSION = 6
# Messages sent by the server to client. # Messages sent by the server to client.
JERRY_DEBUGGER_CONFIGURATION = 1 JERRY_DEBUGGER_CONFIGURATION = 1
@@ -55,6 +55,9 @@ JERRY_DEBUGGER_WAIT_FOR_SOURCE = 25
JERRY_DEBUGGER_OUTPUT_RESULT = 26 JERRY_DEBUGGER_OUTPUT_RESULT = 26
JERRY_DEBUGGER_OUTPUT_RESULT_END = 27 JERRY_DEBUGGER_OUTPUT_RESULT_END = 27
# Debugger option flags
JERRY_DEBUGGER_LITTLE_ENDIAN = 0x1
# Subtypes of eval # Subtypes of eval
JERRY_DEBUGGER_EVAL_EVAL = "\0" JERRY_DEBUGGER_EVAL_EVAL = "\0"
JERRY_DEBUGGER_EVAL_THROW = "\1" JERRY_DEBUGGER_EVAL_THROW = "\1"
@@ -308,14 +311,14 @@ class JerryDebugger(object):
else: else:
result = b"" result = b""
len_expected = 7 len_expected = 10
# Network configurations, which has the following struct: # Network configurations, which has the following struct:
# header [2] - opcode[1], size[1] # header [2] - opcode[1], size[1]
# type [1] # type [1]
# configuration [1]
# version [4]
# max_message_size [1] # max_message_size [1]
# cpointer_size [1] # cpointer_size [1]
# little_endian [1]
# version [1]
while len(result) < len_expected: while len(result) < len_expected:
result += self.client_socket.recv(1024) result += self.client_socket.recv(1024)
@@ -324,21 +327,15 @@ class JerryDebugger(object):
expected = struct.pack("BBB", expected = struct.pack("BBB",
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT, WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
5, 8,
JERRY_DEBUGGER_CONFIGURATION) JERRY_DEBUGGER_CONFIGURATION)
if result[0:3] != expected: if result[0:3] != expected:
raise Exception("Unexpected configuration") raise Exception("Unexpected configuration")
self.max_message_size = ord(result[3]) self.little_endian = ord(result[3]) & JERRY_DEBUGGER_LITTLE_ENDIAN
self.cp_size = ord(result[4]) self.max_message_size = ord(result[8])
self.little_endian = ord(result[5]) self.cp_size = ord(result[9])
self.version = ord(result[6])
if self.version != JERRY_DEBUGGER_VERSION:
raise Exception("Incorrect debugger version from target: %d expected: %d" %
(self.version, JERRY_DEBUGGER_VERSION))
if self.little_endian: if self.little_endian:
self.byte_order = "<" self.byte_order = "<"
@@ -354,6 +351,11 @@ class JerryDebugger(object):
self.idx_format = "I" self.idx_format = "I"
self.version = struct.unpack(self.byte_order + self.idx_format, result[4:8])[0]
if self.version != JERRY_DEBUGGER_VERSION:
raise Exception("Incorrect debugger version from target: %d expected: %d" %
(self.version, JERRY_DEBUGGER_VERSION))
logging.debug("Compressed pointer size: %d", self.cp_size) logging.debug("Compressed pointer size: %d", self.cp_size)
if len_result > len_expected: if len_result > len_expected: