Skip to content

Commit 35fbcd1

Browse files
zherczegLaszloLango
authored andcommitted
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
1 parent df69e1e commit 35fbcd1

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

jerry-core/debugger/debugger.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct
3939
*/
4040
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 28
4141
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19
42-
&& JERRY_DEBUGGER_VERSION == 5,
42+
&& JERRY_DEBUGGER_VERSION == 6,
4343
debugger_version_correlates_to_message_type_count);
4444

4545
/**
@@ -880,10 +880,18 @@ jerry_debugger_send_configuration (uint8_t max_message_size) /**< maximum messag
880880
endian_data.uint16_value = 1;
881881

882882
configuration_p->type = JERRY_DEBUGGER_CONFIGURATION;
883+
configuration_p->configuration = 0;
884+
885+
if (endian_data.uint8_value[0] == 1)
886+
{
887+
configuration_p->configuration |= (uint8_t) JERRY_DEBUGGER_LITTLE_ENDIAN;
888+
}
889+
890+
uint32_t version = JERRY_DEBUGGER_VERSION;
891+
memcpy (configuration_p->version, &version, sizeof (uint32_t));
892+
883893
configuration_p->max_message_size = max_message_size;
884894
configuration_p->cpointer_size = sizeof (jmem_cpointer_t);
885-
configuration_p->little_endian = (endian_data.uint8_value[0] == 1);
886-
configuration_p->version = JERRY_DEBUGGER_VERSION;
887895

888896
return jerry_debugger_send (sizeof (jerry_debugger_send_configuration_t));
889897
} /* jerry_debugger_send_configuration */

jerry-core/debugger/debugger.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* JerryScript debugger protocol version.
2828
*/
29-
#define JERRY_DEBUGGER_VERSION (5)
29+
#define JERRY_DEBUGGER_VERSION (6)
3030

3131
/**
3232
* Frequency of calling jerry_debugger_receive() by the VM.
@@ -191,6 +191,14 @@ typedef enum
191191
JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */
192192
} jerry_debugger_header_type_t;
193193

194+
/**
195+
* Debugger option flags.
196+
*/
197+
typedef enum
198+
{
199+
JERRY_DEBUGGER_LITTLE_ENDIAN = 1u << 0, /**< little endian */
200+
} jerry_debugger_configuration_flags_t;
201+
194202
/**
195203
* Subtypes of eval.
196204
*/
@@ -250,10 +258,10 @@ typedef struct
250258
typedef struct
251259
{
252260
uint8_t type; /**< type of the message */
261+
uint8_t configuration; /**< configuration option bits */
262+
uint8_t version[sizeof (uint32_t)]; /**< debugger version */
253263
uint8_t max_message_size; /**< maximum incoming message size */
254264
uint8_t cpointer_size; /**< size of compressed pointers */
255-
uint8_t little_endian; /**< little endian machine */
256-
uint8_t version; /**< debugger version */
257265
} jerry_debugger_send_configuration_t;
258266

259267
/**

jerry-debugger/jerry_client_ws.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import sys
2525

2626
# Expected debugger protocol version.
27-
JERRY_DEBUGGER_VERSION = 5
27+
JERRY_DEBUGGER_VERSION = 6
2828

2929
# Messages sent by the server to client.
3030
JERRY_DEBUGGER_CONFIGURATION = 1
@@ -55,6 +55,9 @@
5555
JERRY_DEBUGGER_OUTPUT_RESULT = 26
5656
JERRY_DEBUGGER_OUTPUT_RESULT_END = 27
5757

58+
# Debugger option flags
59+
JERRY_DEBUGGER_LITTLE_ENDIAN = 0x1
60+
5861
# Subtypes of eval
5962
JERRY_DEBUGGER_EVAL_EVAL = "\0"
6063
JERRY_DEBUGGER_EVAL_THROW = "\1"
@@ -308,14 +311,14 @@ def __init__(self, address):
308311
else:
309312
result = b""
310313

311-
len_expected = 7
314+
len_expected = 10
312315
# Network configurations, which has the following struct:
313316
# header [2] - opcode[1], size[1]
314317
# type [1]
318+
# configuration [1]
319+
# version [4]
315320
# max_message_size [1]
316321
# cpointer_size [1]
317-
# little_endian [1]
318-
# version [1]
319322

320323
while len(result) < len_expected:
321324
result += self.client_socket.recv(1024)
@@ -324,21 +327,15 @@ def __init__(self, address):
324327

325328
expected = struct.pack("BBB",
326329
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
327-
5,
330+
8,
328331
JERRY_DEBUGGER_CONFIGURATION)
329332

330333
if result[0:3] != expected:
331334
raise Exception("Unexpected configuration")
332335

333-
self.max_message_size = ord(result[3])
334-
self.cp_size = ord(result[4])
335-
self.little_endian = ord(result[5])
336-
self.version = ord(result[6])
337-
338-
if self.version != JERRY_DEBUGGER_VERSION:
339-
raise Exception("Incorrect debugger version from target: %d expected: %d" %
340-
(self.version, JERRY_DEBUGGER_VERSION))
341-
336+
self.little_endian = ord(result[3]) & JERRY_DEBUGGER_LITTLE_ENDIAN
337+
self.max_message_size = ord(result[8])
338+
self.cp_size = ord(result[9])
342339

343340
if self.little_endian:
344341
self.byte_order = "<"
@@ -354,6 +351,11 @@ def __init__(self, address):
354351

355352
self.idx_format = "I"
356353

354+
self.version = struct.unpack(self.byte_order + self.idx_format, result[4:8])[0]
355+
if self.version != JERRY_DEBUGGER_VERSION:
356+
raise Exception("Incorrect debugger version from target: %d expected: %d" %
357+
(self.version, JERRY_DEBUGGER_VERSION))
358+
357359
logging.debug("Compressed pointer size: %d", self.cp_size)
358360

359361
if len_result > len_expected:

0 commit comments

Comments
 (0)