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 <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5093
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Antonio Borneo 2019-04-07 05:12:31 +02:00 committed by Tomas Vanek
parent 31c67cc830
commit c826746068
1 changed files with 3 additions and 12 deletions

View File

@ -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) {