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>
bscan_optimization
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); result = Jim_GetString(Jim_GetResult(interp), &reslen);
if (reslen > 0) { if (reslen > 0) {
int i; command_output_text(context, result);
char buff[256 + 1]; command_output_text(context, "\n");
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");
} }
retval = ERROR_OK; retval = ERROR_OK;
} else if (retcode == JIM_EXIT) { } else if (retcode == JIM_EXIT) {
@ -697,6 +687,7 @@ int command_run_line(struct command_context *context, char *line)
return retcode; return retcode;
} else { } else {
Jim_MakeErrorMessage(interp); Jim_MakeErrorMessage(interp);
/* error is broadcast */
LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL));
if (retval == ERROR_OK) { if (retval == ERROR_OK) {