forked from auracaster/openocd
server: tcl_trace command
Implements async target trace output to the tcl server Change-Id: I0178f6404447337d523782a1d2c317457030da40 Signed-off-by: Austin Morton <austinpmorton@gmail.com> Reviewed-on: http://openocd.zylin.com/2588 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
This commit is contained in:
committed by
Paul Fertser
parent
85903156d7
commit
d28ab08cfa
@@ -35,11 +35,15 @@ static int armv7m_poll_trace(void *target)
|
||||
if (retval != ERROR_OK || !size)
|
||||
return retval;
|
||||
|
||||
if (fwrite(buf, 1, size, armv7m->trace_config.trace_file) == size)
|
||||
fflush(armv7m->trace_config.trace_file);
|
||||
else {
|
||||
LOG_ERROR("Error writing to the trace destination file");
|
||||
return ERROR_FAIL;
|
||||
target_call_trace_callbacks(target, size, buf);
|
||||
|
||||
if (armv7m->trace_config.trace_file != NULL) {
|
||||
if (fwrite(buf, 1, size, armv7m->trace_config.trace_file) == size)
|
||||
fflush(armv7m->trace_config.trace_file);
|
||||
else {
|
||||
LOG_ERROR("Error writing to the trace destination file");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -183,10 +187,13 @@ COMMAND_HANDLER(handle_tpiu_config_command)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
armv7m->trace_config.config_type = INTERNAL;
|
||||
armv7m->trace_config.trace_file = fopen(CMD_ARGV[cmd_idx], "ab");
|
||||
if (!armv7m->trace_config.trace_file) {
|
||||
LOG_ERROR("Can't open trace destination file");
|
||||
return ERROR_FAIL;
|
||||
|
||||
if (strcmp(CMD_ARGV[cmd_idx], "-") != 0) {
|
||||
armv7m->trace_config.trace_file = fopen(CMD_ARGV[cmd_idx], "ab");
|
||||
if (!armv7m->trace_config.trace_file) {
|
||||
LOG_ERROR("Can't open trace destination file");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
cmd_idx++;
|
||||
|
||||
Reference in New Issue
Block a user