Add source sending feature to the debugger. (#1932)
With this feature the debugger webIDE and the python client can able to send a source code to the debugger while that is running in wait mode. This feature can be activated with the --debugger-wait-source switch and the debugger will wait for the source messages. If every message part are received the debugger will continue the exectuion with the initalized options. JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com
This commit is contained in:
committed by
Zoltan Herczeg
parent
a3885be6ce
commit
3e3d6373b8
@@ -65,12 +65,14 @@ var JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2;
|
||||
var JERRY_DEBUGGER_EXCEPTION_CONFIG = 3;
|
||||
var JERRY_DEBUGGER_MEMSTATS = 4;
|
||||
var JERRY_DEBUGGER_STOP = 5;
|
||||
var JERRY_DEBUGGER_CONTINUE = 6;
|
||||
var JERRY_DEBUGGER_STEP = 7;
|
||||
var JERRY_DEBUGGER_NEXT = 8;
|
||||
var JERRY_DEBUGGER_GET_BACKTRACE = 9;
|
||||
var JERRY_DEBUGGER_EVAL = 10;
|
||||
var JERRY_DEBUGGER_EVAL_PART = 11;
|
||||
var JERRY_DEBUGGER_CLIENT_SOURCE = 6;
|
||||
var JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7;
|
||||
var JERRY_DEBUGGER_CONTINUE = 8;
|
||||
var JERRY_DEBUGGER_STEP = 9;
|
||||
var JERRY_DEBUGGER_NEXT = 10;
|
||||
var JERRY_DEBUGGER_GET_BACKTRACE = 11;
|
||||
var JERRY_DEBUGGER_EVAL = 12;
|
||||
var JERRY_DEBUGGER_EVAL_PART = 13;
|
||||
|
||||
var textBox = document.getElementById("log");
|
||||
var commandBox = document.getElementById("command");
|
||||
|
||||
@@ -58,12 +58,14 @@ JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2
|
||||
JERRY_DEBUGGER_EXCEPTION_CONFIG = 3
|
||||
JERRY_DEBUGGER_MEMSTATS = 4
|
||||
JERRY_DEBUGGER_STOP = 5
|
||||
JERRY_DEBUGGER_CONTINUE = 6
|
||||
JERRY_DEBUGGER_STEP = 7
|
||||
JERRY_DEBUGGER_NEXT = 8
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 9
|
||||
JERRY_DEBUGGER_EVAL = 10
|
||||
JERRY_DEBUGGER_EVAL_PART = 11
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE = 6
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7
|
||||
JERRY_DEBUGGER_CONTINUE = 8
|
||||
JERRY_DEBUGGER_STEP = 9
|
||||
JERRY_DEBUGGER_NEXT = 10
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 11
|
||||
JERRY_DEBUGGER_EVAL = 12
|
||||
JERRY_DEBUGGER_EVAL_PART = 13
|
||||
|
||||
MAX_BUFFER_SIZE = 128
|
||||
WEBSOCKET_BINARY_FRAME = 2
|
||||
@@ -85,6 +87,8 @@ def arguments_parse():
|
||||
help="set display range")
|
||||
parser.add_argument("--exception", action="store", default=None, type=int, choices=[0, 1],
|
||||
help="set exception config, usage 1: [Enable] or 0: [Disable]")
|
||||
parser.add_argument("--client-source", action="store", default=None, type=str,
|
||||
help="specify a javascript source file to execute")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -345,7 +349,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
pprint(self.debugger.function_list)
|
||||
|
||||
def eval_string(self, args):
|
||||
def send_string(self, args, message_type):
|
||||
size = len(args)
|
||||
if size == 0:
|
||||
return
|
||||
@@ -359,7 +363,7 @@ class DebuggerPrompt(Cmd):
|
||||
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
|
||||
WEBSOCKET_FIN_BIT + max_fragment + message_header,
|
||||
0,
|
||||
JERRY_DEBUGGER_EVAL,
|
||||
message_type,
|
||||
size)
|
||||
|
||||
if size == max_fragment:
|
||||
@@ -370,6 +374,11 @@ class DebuggerPrompt(Cmd):
|
||||
self.debugger.send_message(message + args[0:max_fragment])
|
||||
offset = max_fragment
|
||||
|
||||
if message_type == JERRY_DEBUGGER_EVAL:
|
||||
message_type = JERRY_DEBUGGER_EVAL_PART
|
||||
else:
|
||||
message_type = JERRY_DEBUGGER_CLIENT_SOURCE_PART
|
||||
|
||||
# 1: length of type byte
|
||||
message_header = 1
|
||||
|
||||
@@ -381,7 +390,7 @@ class DebuggerPrompt(Cmd):
|
||||
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
|
||||
WEBSOCKET_FIN_BIT + next_fragment + message_header,
|
||||
0,
|
||||
JERRY_DEBUGGER_EVAL_PART)
|
||||
message_type)
|
||||
|
||||
prev_offset = offset
|
||||
offset += next_fragment
|
||||
@@ -391,7 +400,7 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
def do_eval(self, args):
|
||||
""" Evaluate JavaScript source code """
|
||||
self.eval_string(args)
|
||||
self.send_string(args, JERRY_DEBUGGER_EVAL)
|
||||
|
||||
do_e = do_eval
|
||||
|
||||
@@ -420,6 +429,16 @@ class DebuggerPrompt(Cmd):
|
||||
|
||||
do_ms = do_memstats
|
||||
|
||||
def send_client_source(self, args):
|
||||
""" Send and execute the specified Javascript source file to the debugger """
|
||||
if not args.lower().endswith('.js'):
|
||||
sys.exit("Error: Javascript file expected!")
|
||||
return
|
||||
|
||||
with open(args, 'r') as f:
|
||||
content = args + "\0" + f.read()
|
||||
self.send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
|
||||
|
||||
class Multimap(object):
|
||||
|
||||
def __init__(self):
|
||||
@@ -941,6 +960,9 @@ def main():
|
||||
if args.exception is not None:
|
||||
prompt.do_exception(str(args.exception))
|
||||
|
||||
if args.client_source is not None:
|
||||
prompt.send_client_source(str(args.client_source))
|
||||
|
||||
while True:
|
||||
if not non_interactive and prompt.cont:
|
||||
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
|
||||
|
||||
Reference in New Issue
Block a user