[Debugger] Create a simplified transmission layer (#2781)
It supports the raw packet sending over a TCP/IP protocol JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
@@ -22,6 +22,8 @@ import select
|
||||
import struct
|
||||
import sys
|
||||
from jerry_client_websocket import WebSocket
|
||||
from jerry_client_rawpacket import RawPacket
|
||||
from jerry_client_tcp import Socket
|
||||
|
||||
# Expected debugger protocol version.
|
||||
JERRY_DEBUGGER_VERSION = 8
|
||||
@@ -134,7 +136,8 @@ def arguments_parse():
|
||||
help="set exception config, usage 1: [Enable] or 0: [Disable]")
|
||||
parser.add_argument("--client-source", action="store", default=[], type=str, nargs="+",
|
||||
help="specify a javascript source file to execute")
|
||||
|
||||
parser.add_argument("--channel", choices=["websocket", "rawpacket"], default="websocket",
|
||||
help="specify the communication channel (default: %(default)s)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.verbose:
|
||||
@@ -262,8 +265,8 @@ class DebuggerAction(object):
|
||||
|
||||
|
||||
class JerryDebugger(object):
|
||||
# pylint: disable=too-many-instance-attributes,too-many-statements,too-many-public-methods,no-self-use
|
||||
def __init__(self, address):
|
||||
# pylint: disable=too-many-instance-attributes,too-many-statements,too-many-public-methods,no-self-use,redefined-variable-type
|
||||
def __init__(self, address, channel):
|
||||
|
||||
if ":" not in address:
|
||||
self.host = address
|
||||
@@ -301,8 +304,15 @@ class JerryDebugger(object):
|
||||
self.non_interactive = False
|
||||
self.current_out = b""
|
||||
self.current_log = b""
|
||||
self.channel = None
|
||||
|
||||
self.channel = WebSocket(address=(self.host, self.port))
|
||||
protocol = Socket()
|
||||
if channel == "websocket":
|
||||
self.channel = WebSocket(address=(self.host, self.port), protocol=protocol)
|
||||
elif channel == "rawpacket":
|
||||
self.channel = RawPacket(address=(self.host, self.port), protocol=protocol)
|
||||
else:
|
||||
raise Exception("Unsupported communication channel")
|
||||
|
||||
config_size = 8
|
||||
# The server will send the configuration message after connection established
|
||||
@@ -342,7 +352,8 @@ class JerryDebugger(object):
|
||||
logging.debug("Compressed pointer size: %d", self.cp_size)
|
||||
|
||||
def __del__(self):
|
||||
self.channel.close()
|
||||
if self.channel is not None:
|
||||
self.channel.close()
|
||||
|
||||
def _exec_command(self, command_id):
|
||||
self.send_command(command_id)
|
||||
|
||||
Reference in New Issue
Block a user