Multiple client source sending feature. (#1957)
Whit this enhancement the debugger can able handle more than one source file across the new source wait mode. This feature can be used by the python client with the --client-source [paths] switch. The client will store every source path, when the debugger send a signal about the waiting status, then the client will send one file from the list. JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi.szeged@partner.samsung.com
This commit is contained in:
@@ -58,6 +58,7 @@ var JERRY_DEBUGGER_BACKTRACE = 19;
|
||||
var JERRY_DEBUGGER_BACKTRACE_END = 20;
|
||||
var JERRY_DEBUGGER_EVAL_RESULT = 21;
|
||||
var JERRY_DEBUGGER_EVAL_RESULT_END = 22;
|
||||
var JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23;
|
||||
|
||||
// Subtypes of eval
|
||||
var JERRY_DEBUGGER_EVAL_OK = 1;
|
||||
@@ -71,12 +72,13 @@ var JERRY_DEBUGGER_MEMSTATS = 4;
|
||||
var JERRY_DEBUGGER_STOP = 5;
|
||||
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 JERRY_DEBUGGER_NO_MORE_SOURCES = 8;
|
||||
var JERRY_DEBUGGER_CONTINUE = 9;
|
||||
var JERRY_DEBUGGER_STEP = 10;
|
||||
var JERRY_DEBUGGER_NEXT = 11;
|
||||
var JERRY_DEBUGGER_GET_BACKTRACE = 12;
|
||||
var JERRY_DEBUGGER_EVAL = 13;
|
||||
var JERRY_DEBUGGER_EVAL_PART = 14;
|
||||
|
||||
var textBox = document.getElementById("log");
|
||||
var commandBox = document.getElementById("command");
|
||||
@@ -921,6 +923,12 @@ function DebuggerClient(address)
|
||||
return;
|
||||
}
|
||||
|
||||
case JERRY_DEBUGGER_WAIT_FOR_SOURCE:
|
||||
{
|
||||
// This message does not have effect in this client.
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
abortConnection("unexpected message.");
|
||||
|
||||
@@ -48,6 +48,7 @@ JERRY_DEBUGGER_BACKTRACE = 19
|
||||
JERRY_DEBUGGER_BACKTRACE_END = 20
|
||||
JERRY_DEBUGGER_EVAL_RESULT = 21
|
||||
JERRY_DEBUGGER_EVAL_RESULT_END = 22
|
||||
JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23
|
||||
|
||||
# Subtypes of eval
|
||||
JERRY_DEBUGGER_EVAL_OK = 1
|
||||
@@ -62,12 +63,13 @@ JERRY_DEBUGGER_MEMSTATS = 4
|
||||
JERRY_DEBUGGER_STOP = 5
|
||||
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
|
||||
JERRY_DEBUGGER_NO_MORE_SOURCES = 8
|
||||
JERRY_DEBUGGER_CONTINUE = 9
|
||||
JERRY_DEBUGGER_STEP = 10
|
||||
JERRY_DEBUGGER_NEXT = 11
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 12
|
||||
JERRY_DEBUGGER_EVAL = 13
|
||||
JERRY_DEBUGGER_EVAL_PART = 14
|
||||
|
||||
MAX_BUFFER_SIZE = 128
|
||||
WEBSOCKET_BINARY_FRAME = 2
|
||||
@@ -89,7 +91,7 @@ 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,
|
||||
parser.add_argument("--client-source", action="store", default=[], type=str, nargs="+",
|
||||
help="specify a javascript source file to execute")
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -181,6 +183,7 @@ class DebuggerPrompt(Cmd):
|
||||
self.quit = False
|
||||
self.cont = True
|
||||
self.non_interactive = False
|
||||
self.client_sources = []
|
||||
|
||||
def precmd(self, line):
|
||||
self.stop = False
|
||||
@@ -431,16 +434,28 @@ 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'):
|
||||
def store_client_sources(self, args):
|
||||
self.client_sources = args
|
||||
|
||||
def send_client_source(self):
|
||||
# Send no more source message if there is no source
|
||||
if not self.client_sources:
|
||||
self.send_no_more_source()
|
||||
return
|
||||
|
||||
path = self.client_sources.pop(0)
|
||||
if not path.lower().endswith('.js'):
|
||||
sys.exit("Error: Javascript file expected!")
|
||||
return
|
||||
|
||||
with open(args, 'r') as f:
|
||||
content = args + "\0" + f.read()
|
||||
with open(path, 'r') as f:
|
||||
content = path + "\0" + f.read()
|
||||
self.send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
|
||||
|
||||
def send_no_more_source(self):
|
||||
self.exec_command("", JERRY_DEBUGGER_NO_MORE_SOURCES)
|
||||
self.cont = True
|
||||
|
||||
class Multimap(object):
|
||||
|
||||
def __init__(self):
|
||||
@@ -963,7 +978,7 @@ def main():
|
||||
prompt.do_exception(str(args.exception))
|
||||
|
||||
if args.client_source is not None:
|
||||
prompt.send_client_source(str(args.client_source))
|
||||
prompt.store_client_sources(args.client_source)
|
||||
|
||||
while True:
|
||||
if not non_interactive and prompt.cont:
|
||||
@@ -1106,6 +1121,9 @@ def main():
|
||||
|
||||
prompt.cmdloop()
|
||||
|
||||
elif buffer_type == JERRY_DEBUGGER_WAIT_FOR_SOURCE:
|
||||
prompt.send_client_source()
|
||||
|
||||
else:
|
||||
raise Exception("Unknown message")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user