X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftrace.c;h=59489fe4e77ca8b7a5a92ac28eae6adfd20fab39;hb=c6e80f63a3955baed6666e966ab1dd3950ea91b8;hp=536e34a5f427cf0149d4b7e4cc57a6b82731fe0a;hpb=167ce32a7cb99962e6ae8f8c6d36b0999c16888c;p=openocd.git diff --git a/src/target/trace.c b/src/target/trace.c index 536e34a5f4..59489fe4e7 100644 --- a/src/target/trace.c +++ b/src/target/trace.c @@ -21,21 +21,15 @@ #include "config.h" #endif -#include "replacements.h" #include "log.h" #include "trace.h" #include "target.h" -#include "command.h" -#include -#include -#include - -int trace_point(target_t *target, int number) +int trace_point(target_t *target, u32 number) { trace_t *trace = target->trace_info; - DEBUG("tracepoint: %i", number); + LOG_DEBUG("tracepoint: %i", number); if (number < trace->num_trace_points) trace->trace_points[number].hit_counter++; @@ -53,18 +47,18 @@ int trace_point(target_t *target, int number) return ERROR_OK; } -int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target = get_current_target(cmd_ctx); trace_t *trace = target->trace_info; if (argc == 0) { - int i; + u32 i; for (i = 0; i < trace->num_trace_points; i++) { - command_print(cmd_ctx, "trace point 0x%8.8x (%"PRIi64" times hit)", + command_print(cmd_ctx, "trace point 0x%8.8x (%lld times hit)", trace->trace_points[i].address, trace->trace_points[i].hit_counter); } @@ -75,7 +69,10 @@ int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, cha if (!strcmp(args[0], "clear")) { if (trace->trace_points) + { free(trace->trace_points); + trace->trace_points = NULL; + } trace->num_trace_points = 0; trace->trace_points_size = 0; @@ -96,7 +93,7 @@ int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, cha return ERROR_OK; } -int handle_trace_history_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_trace_history_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target = get_current_target(cmd_ctx); trace_t *trace = target->trace_info; @@ -122,10 +119,14 @@ int handle_trace_history_command(struct command_context_s *cmd_ctx, char *cmd, c } else { - int i; - int first = 0; - int last = trace->trace_history_pos; - + u32 i; + u32 first = 0; + u32 last = trace->trace_history_pos; + + if ( !trace->trace_history_size ) { + command_print(cmd_ctx, "trace history buffer is not allocated"); + return ERROR_OK; + } if (trace->trace_history_overflowed) { first = trace->trace_history_pos;