Add version fields for debugger configuration
By adding version information to the debugger protocol it is possible to report if the debugger client and server have different expectations on debugger workings (opcodes, types, etc.). JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
@@ -35,6 +35,9 @@ textarea {
|
||||
<div>
|
||||
</div>
|
||||
<script>
|
||||
// Expected JerryScript debugger protocol version
|
||||
var JERRY_DEBUGGER_VERSION = 1;
|
||||
|
||||
// Messages sent by the server to client.
|
||||
var JERRY_DEBUGGER_CONFIGURATION = 1;
|
||||
var JERRY_DEBUGGER_PARSE_ERROR = 2;
|
||||
@@ -136,6 +139,7 @@ function DebuggerClient(address)
|
||||
var outputResult = null;
|
||||
var exceptionData = null;
|
||||
var display = 0;
|
||||
var version = 0;
|
||||
|
||||
function assert(expr)
|
||||
{
|
||||
@@ -783,7 +787,7 @@ function DebuggerClient(address)
|
||||
if (cpointerSize == 0)
|
||||
{
|
||||
if (message[0] != JERRY_DEBUGGER_CONFIGURATION
|
||||
|| message.byteLength != 4)
|
||||
|| message.byteLength != 5)
|
||||
{
|
||||
abortConnection("the first message must be configuration.");
|
||||
}
|
||||
@@ -792,11 +796,19 @@ function DebuggerClient(address)
|
||||
cpointerSize = message[2]
|
||||
littleEndian = (message[3] != 0);
|
||||
|
||||
version = message[4];
|
||||
|
||||
if (cpointerSize != 2 && cpointerSize != 4)
|
||||
{
|
||||
abortConnection("compressed pointer must be 2 or 4 byte long.");
|
||||
}
|
||||
|
||||
if (version != JERRY_DEBUGGER_VERSION)
|
||||
{
|
||||
abortConnection("incorrect target debugger version detected: "
|
||||
+ version + " expected: " + JERRY_DEBUGGER_VERSION);
|
||||
}
|
||||
|
||||
config = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ import socket
|
||||
import struct
|
||||
import sys
|
||||
|
||||
# Expected debugger protocol version.
|
||||
JERRY_DEBUGGER_VERSION = 1
|
||||
|
||||
# Messages sent by the server to client.
|
||||
JERRY_DEBUGGER_CONFIGURATION = 1
|
||||
JERRY_DEBUGGER_PARSE_ERROR = 2
|
||||
@@ -563,13 +566,14 @@ class JerryDebugger(object):
|
||||
else:
|
||||
result = b""
|
||||
|
||||
len_expected = 6
|
||||
len_expected = 7
|
||||
# Network configurations, which has the following struct:
|
||||
# header [2] - opcode[1], size[1]
|
||||
# type [1]
|
||||
# max_message_size [1]
|
||||
# cpointer_size [1]
|
||||
# little_endian [1]
|
||||
# version [1]
|
||||
|
||||
while len(result) < len_expected:
|
||||
result += self.client_socket.recv(1024)
|
||||
@@ -578,7 +582,7 @@ class JerryDebugger(object):
|
||||
|
||||
expected = struct.pack("BBB",
|
||||
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
|
||||
4,
|
||||
5,
|
||||
JERRY_DEBUGGER_CONFIGURATION)
|
||||
|
||||
if result[0:3] != expected:
|
||||
@@ -587,6 +591,12 @@ class JerryDebugger(object):
|
||||
self.max_message_size = ord(result[3])
|
||||
self.cp_size = ord(result[4])
|
||||
self.little_endian = ord(result[5])
|
||||
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:
|
||||
self.byte_order = "<"
|
||||
|
||||
Reference in New Issue
Block a user