X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Farmv7m_trace.c;h=c1e4f5baac33d7f2b8a5c282c7c56f605bddfc59;hb=6b2acc0243f6dd54823c336ded8c20d16cdc50a3;hp=eb07a6e64056f9db57907b0b28c22496159c5069;hpb=6819468a78ce9f0835a9063d93bc839f3d55eb84;p=openocd.git diff --git a/src/target/armv7m_trace.c b/src/target/armv7m_trace.c index eb07a6e640..c1e4f5baac 100644 --- a/src/target/armv7m_trace.c +++ b/src/target/armv7m_trace.c @@ -10,6 +10,9 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -35,11 +38,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 +190,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++;