]> git.sur5r.net Git - openocd/blob - src/target/trace.c
- renamed M5960 USB JTAG to "flyswatter"
[openocd] / src / target / trace.c
1 /***************************************************************************
2  *   Copyright (C) 2005, 2007 by Dominic Rath                              *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include "replacements.h"
25 #include "log.h"
26 #include "trace.h"
27 #include "target.h"
28
29 #include <stdlib.h>
30
31 int handle_trace_history_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
32 {
33         target_t *target = get_current_target(cmd_ctx);
34         trace_t *trace = target->trace_info;
35         
36         if (argc > 0)
37         {
38                 if (trace->trace_history)
39                         free(trace->trace_history);
40                 
41                 trace->trace_history_size = strtoul(args[0], NULL, 0);
42                 trace->trace_history = malloc(sizeof(u32) * trace->trace_history_size);
43                 
44                 command_print(cmd_ctx, "new trace history size: %i", trace->trace_history_size);
45         }
46         else
47         {
48                 int i;
49                 
50                 for (i = 0; i < trace->trace_history_size; i++)
51                 {
52                         if (trace->trace_history[i] < trace->num_trace_points)
53                         {
54                                 u32 address;
55                                 address = trace->trace_points[trace->trace_history[i]].address;
56                                 command_print(cmd_ctx, "trace point %i: 0x%8.8x",
57                                         trace->trace_history[i],
58                                         address);
59                         }
60
61                         else
62                         {
63                                 command_print(cmd_ctx, "trace point %i: -not defined-", trace->trace_history[i]);
64                         }
65                 }
66         }
67
68         return ERROR_OK;
69 }