Send output to debugger client (#1955)

Sending the output to the debugger client, at the moment only the JS side prints are sent over.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
Daniel Balla
2017-08-30 16:01:06 +02:00
committed by László Langó
parent e897858c64
commit 733f0ceea0
17 changed files with 172 additions and 7 deletions
+38
View File
@@ -59,11 +59,18 @@ 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;
var JERRY_DEBUGGER_OUTPUT_RESULT = 24;
var JERRY_DEBUGGER_OUTPUT_RESULT_END = 25;
// Subtypes of eval
var JERRY_DEBUGGER_EVAL_OK = 1;
var JERRY_DEBUGGER_EVAL_ERROR = 2;
// Subtypes of output result
var JERRY_DEBUGGER_OUTPUT_OK = 1;
var JERRY_DEBUGGER_OUTPUT_WARNING = 2;
var JERRY_DEBUGGER_OUTPUT_ERROR = 3;
// Messages sent by the client to server.
var JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1;
var JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2;
@@ -123,6 +130,7 @@ function DebuggerClient(address)
var pendingBreakpoints = [ ];
var backtraceFrame = 0;
var evalResult = null;
var outputResult = null;
var exceptionData = null;
var display = 0;
@@ -922,6 +930,36 @@ function DebuggerClient(address)
return;
}
case JERRY_DEBUGGER_OUTPUT_RESULT:
case JERRY_DEBUGGER_OUTPUT_RESULT_END:
{
outputResult = concatUint8Arrays(outputResult, message);
if (message[0] == JERRY_DEBUGGER_OUTPUT_RESULT_END)
{
var subType = outputResult[outputResult.length - 1];
var outString;
outputResult = outputResult.slice(0, -1);
switch (subType)
{
case JERRY_DEBUGGER_OUTPUT_OK:
outString = "out: " + cesu8ToString(outputResult);
break;
case JERRY_DEBUGGER_OUTPUT_WARNING:
outString = "warning: " + cesu8ToString(outputResult);
break;
case JERRY_DEBUGGER_OUTPUT_ERROR:
outString = "err: " + cesu8ToString(outputResult);
break;
}
appendLog(outString);
outputResult = null;
}
return;
}
case JERRY_DEBUGGER_WAIT_FOR_SOURCE:
{
+35
View File
@@ -49,11 +49,18 @@ JERRY_DEBUGGER_BACKTRACE_END = 20
JERRY_DEBUGGER_EVAL_RESULT = 21
JERRY_DEBUGGER_EVAL_RESULT_END = 22
JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23
JERRY_DEBUGGER_OUTPUT_RESULT = 24
JERRY_DEBUGGER_OUTPUT_RESULT_END = 25
# Subtypes of eval
JERRY_DEBUGGER_EVAL_OK = 1
JERRY_DEBUGGER_EVAL_ERROR = 2
# Subtypes of output
JERRY_DEBUGGER_OUTPUT_OK = 1
JERRY_DEBUGGER_OUTPUT_WARNING = 2
JERRY_DEBUGGER_OUTPUT_ERROR = 3
# Messages sent by the client to server.
JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1
@@ -511,6 +518,7 @@ class JerryDebugger(object):
self.yellow = ''
self.green_bg = ''
self.yellow_bg = ''
self.blue = ''
self.nocolor = ''
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client_socket.connect((self.host, self.port))
@@ -658,6 +666,7 @@ class JerryDebugger(object):
self.yellow = '\033[93m'
self.green_bg = '\033[42m'
self.yellow_bg = '\033[43m'
self.blue = '\033[94m'
def get_message(self, blocking):
# Connection was closed
@@ -1124,6 +1133,32 @@ def main():
elif buffer_type == JERRY_DEBUGGER_WAIT_FOR_SOURCE:
prompt.send_client_source()
elif buffer_type in [JERRY_DEBUGGER_OUTPUT_RESULT, JERRY_DEBUGGER_OUTPUT_RESULT_END]:
message = ""
msg_type = buffer_type
while True:
if buffer_type == JERRY_DEBUGGER_OUTPUT_RESULT_END:
subtype = ord(data[-1])
message += data[3:-1]
break
else:
message += data[3:]
data = debugger.get_message(True)
buffer_type = ord(data[2])
buffer_size = ord(data[1]) - 1
if buffer_type not in [msg_type, msg_type + 1]:
raise Exception("Output data expected")
if subtype == JERRY_DEBUGGER_OUTPUT_OK:
print("%sout: %s%s" % (debugger.blue, debugger.nocolor, message))
elif subtype == JERRY_DEBUGGER_OUTPUT_WARNING:
print("%swarning: %s%s" % (debugger.yellow, debugger.nocolor, message))
elif subtype == JERRY_DEBUGGER_OUTPUT_ERROR:
print("%serr: %s%s" % (debugger.red, debugger.nocolor, message))
else:
raise Exception("Unknown message")