aboutsummaryrefslogtreecommitdiff
path: root/src/target/armv7m_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/armv7m_trace.c')
-rw-r--r--src/target/armv7m_trace.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/target/armv7m_trace.c b/src/target/armv7m_trace.c
index eb07a6e..3592bad 100644
--- a/src/target/armv7m_trace.c
+++ b/src/target/armv7m_trace.c
@@ -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++;