mark usage of in_handler that can be converted into user code
[fw/openocd] / src / target / trace.c
index 257e8ceb8a767946fe655acf67b4b8d5d42fcbc9..50f526a949acdd965dc55d3307e04b4b2c315044 100644 (file)
@@ -31,7 +31,7 @@
 #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;
 
@@ -53,14 +53,14 @@ 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++)
                {
@@ -99,7 +99,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;
@@ -125,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;