From c826746068d46099eb787c403a240b4afff37c0a Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sun, 7 Apr 2019 05:12:31 +0200 Subject: [PATCH] helper/command: send command output only to the right server When opening multiple telnet connections, the command output on one console is broadcast to all the other console. Send the command output only to the output handler that has been set for that context. For the moment, still broadcast the errors. Note that contexts which doesn't explicitly set the output handler (e.g. gdb_server), will inherit the global output handler configuration_output_handler() that will broadcast the output. Change-Id: I1f2d6e6a3bbf730f5fa77246730fce1445742a1e Signed-off-by: Antonio Borneo Reviewed-on: http://openocd.zylin.com/5093 Tested-by: jenkins Reviewed-by: Tomas Vanek --- src/helper/command.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/helper/command.c b/src/helper/command.c index 0f35f8565..ddf77d187 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -676,18 +676,8 @@ int command_run_line(struct command_context *context, char *line) result = Jim_GetString(Jim_GetResult(interp), &reslen); if (reslen > 0) { - int i; - char buff[256 + 1]; - for (i = 0; i < reslen; i += 256) { - int chunk; - chunk = reslen - i; - if (chunk > 256) - chunk = 256; - strncpy(buff, result + i, chunk); - buff[chunk] = 0; - LOG_USER_N("%s", buff); - } - LOG_USER_N("\n"); + command_output_text(context, result); + command_output_text(context, "\n"); } retval = ERROR_OK; } else if (retcode == JIM_EXIT) { @@ -697,6 +687,7 @@ int command_run_line(struct command_context *context, char *line) return retcode; } else { Jim_MakeErrorMessage(interp); + /* error is broadcast */ LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); if (retval == ERROR_OK) {