#include "config.h"
#endif
-#include "replacements.h"
#include "log.h"
#include "trace.h"
#include "target.h"
-#include "command.h"
-#include <stdlib.h>
-#include <string.h>
#include <inttypes.h>
-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++;
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);
}
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;
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;
}
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;