mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Send every kind of output to the debugger client
Now correctly sending jerry_port_log output to the debugger client as well. JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
parent
c21c21f9f9
commit
c8b99d05e1
@ -48,10 +48,10 @@ typedef enum
|
||||
} jerry_log_level_t;
|
||||
|
||||
/**
|
||||
* Display or log a debug/error message. The function should implement a printf-like
|
||||
* interface, where the first argument specifies the log level
|
||||
* and the second argument specifies a format string on how to stringify the rest
|
||||
* of the parameter list.
|
||||
* Display or log a debug/error message, and sends it to the debugger client as well.
|
||||
* The function should implement a printf-like interface, where the first argument
|
||||
* specifies the log level and the second argument specifies a format string on how
|
||||
* to stringify the rest of the parameter list.
|
||||
*
|
||||
* This function is only called with messages coming from the jerry engine as
|
||||
* the result of some abnormal operation or describing its internal operations
|
||||
@ -230,4 +230,4 @@ jerry_port_get_current_instance (void)
|
||||
{
|
||||
return current_instance_p;
|
||||
} /* jerry_port_get_current_instance */
|
||||
```
|
||||
```
|
||||
|
||||
@ -291,7 +291,6 @@ jerry_debugger_wait_and_run_client_source (jerry_value_t *return_value)
|
||||
**Summary**
|
||||
|
||||
Sends the program's output to the debugger client.
|
||||
At the moment only the JS print size is implemented.
|
||||
|
||||
**Prototype**
|
||||
|
||||
|
||||
@ -162,8 +162,10 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_OUTPUT_OK = 1, /**< output result, no error */
|
||||
JERRY_DEBUGGER_OUTPUT_WARNING = 2, /**< output result, warning */
|
||||
JERRY_DEBUGGER_OUTPUT_ERROR = 3, /**< output result, error */
|
||||
JERRY_DEBUGGER_OUTPUT_ERROR = 2, /**< output result, error */
|
||||
JERRY_DEBUGGER_OUTPUT_WARNING = 3, /**< output result, warning */
|
||||
JERRY_DEBUGGER_OUTPUT_DEBUG = 4, /**< output result, debug */
|
||||
JERRY_DEBUGGER_OUTPUT_TRACE = 5, /**< output result, trace */
|
||||
} jerry_debugger_output_subtype_t;
|
||||
|
||||
/**
|
||||
|
||||
@ -68,8 +68,10 @@ 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;
|
||||
var JERRY_DEBUGGER_OUTPUT_ERROR = 2;
|
||||
var JERRY_DEBUGGER_OUTPUT_WARNING = 3;
|
||||
var JERRY_DEBUGGER_OUTPUT_DEBUG = 4;
|
||||
var JERRY_DEBUGGER_OUTPUT_TRACE = 5;
|
||||
|
||||
// Messages sent by the client to server.
|
||||
var JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1;
|
||||
@ -944,6 +946,7 @@ function DebuggerClient(address)
|
||||
switch (subType)
|
||||
{
|
||||
case JERRY_DEBUGGER_OUTPUT_OK:
|
||||
case JERRY_DEBUGGER_OUTPUT_DEBUG:
|
||||
outString = "out: " + cesu8ToString(outputResult);
|
||||
break;
|
||||
case JERRY_DEBUGGER_OUTPUT_WARNING:
|
||||
@ -952,12 +955,15 @@ function DebuggerClient(address)
|
||||
case JERRY_DEBUGGER_OUTPUT_ERROR:
|
||||
outString = "err: " + cesu8ToString(outputResult);
|
||||
break;
|
||||
case JERRY_DEBUGGER_OUTPUT_TRACE:
|
||||
outString = "trace: " + cesu8ToString(outputResult);
|
||||
break;
|
||||
}
|
||||
|
||||
appendLog(outString);
|
||||
outputResult = null;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +58,10 @@ JERRY_DEBUGGER_EVAL_ERROR = 2
|
||||
|
||||
# Subtypes of output
|
||||
JERRY_DEBUGGER_OUTPUT_OK = 1
|
||||
JERRY_DEBUGGER_OUTPUT_WARNING = 2
|
||||
JERRY_DEBUGGER_OUTPUT_ERROR = 3
|
||||
JERRY_DEBUGGER_OUTPUT_ERROR = 2
|
||||
JERRY_DEBUGGER_OUTPUT_WARNING = 3
|
||||
JERRY_DEBUGGER_OUTPUT_DEBUG = 4
|
||||
JERRY_DEBUGGER_OUTPUT_TRACE = 5
|
||||
|
||||
|
||||
# Messages sent by the client to server.
|
||||
@ -1115,12 +1117,15 @@ def main():
|
||||
|
||||
# Subtypes of output
|
||||
if buffer_type == JERRY_DEBUGGER_OUTPUT_RESULT_END:
|
||||
if subtype == JERRY_DEBUGGER_OUTPUT_OK:
|
||||
if subtype in [JERRY_DEBUGGER_OUTPUT_OK,
|
||||
JERRY_DEBUGGER_OUTPUT_DEBUG]:
|
||||
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))
|
||||
elif subtype == JERRY_DEBUGGER_OUTPUT_TRACE:
|
||||
print("%strace: %s%s" % (debugger.blue, debugger.nocolor, message))
|
||||
|
||||
# Subtypes of eval
|
||||
elif buffer_type == JERRY_DEBUGGER_EVAL_RESULT_END:
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "jerryscript-port.h"
|
||||
#include "jerryscript-port-default.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#ifndef DISABLE_EXTRA_API
|
||||
|
||||
@ -60,9 +61,10 @@ jerry_port_default_set_log_level (jerry_log_level_t level) /**< log level */
|
||||
#endif /* !DISABLE_EXTRA_API */
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_log. Prints log message to standard
|
||||
* error with 'vfprintf' if message level is less than or equal to the set log
|
||||
* level.
|
||||
* Default implementation of jerry_port_log. Prints log message to a buffer
|
||||
* then prints the buffer to the standard error with 'fprintf' if message
|
||||
* level is less than or equal to the set log level.
|
||||
* Additionally, sends the message to the debugger client.
|
||||
*
|
||||
* Note:
|
||||
* Changing the log level from JERRY_LOG_LEVEL_ERROR is only possible if
|
||||
@ -78,7 +80,17 @@ jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
#ifdef JERRY_DEBUGGER
|
||||
char buffer[256];
|
||||
int length = 0;
|
||||
length = vsnprintf (buffer, 255, format, args);
|
||||
buffer[length] = '\0';
|
||||
fprintf (stderr, "%s", buffer);
|
||||
jerry_char_t *jbuffer = (jerry_char_t *) buffer;
|
||||
jerry_debugger_send_output (jbuffer, (jerry_size_t) length, (uint8_t) (level + 2));
|
||||
#else /* If jerry-debugger isn't defined, libc is turned on */
|
||||
vfprintf (stderr, format, args);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
va_end (args);
|
||||
}
|
||||
} /* jerry_port_log */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user