X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftrace.c;h=a9045c25eabd9f7350a74454c6f393cc2ba5ba06;hb=40580e2d71ac56131a5da7e5f67a0b63450e4f24;hp=536e34a5f427cf0149d4b7e4cc57a6b82731fe0a;hpb=29000b204d039bc1123027eba755329ab36a3dde;p=openocd.git diff --git a/src/target/trace.c b/src/target/trace.c index 536e34a5f4..a9045c25ea 100644 --- a/src/target/trace.c +++ b/src/target/trace.c @@ -31,11 +31,11 @@ #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++; @@ -60,7 +60,7 @@ int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, cha if (argc == 0) { - int i; + u32 i; for (i = 0; i < trace->num_trace_points; i++) { @@ -75,7 +75,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; @@ -122,10 +125,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;