diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-03-18 15:07:16 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-03-18 15:22:55 -0400 |
commit | 1943405871c7df43ba08c2af6c2e0b83a3aad9f2 (patch) | |
tree | f3a838df9fc0843240737d794e10102e5e7de30c | |
parent | b5d9ba0ed7a62ecc6b44a2375f4d321b68e96610 (diff) |
trace-cmd: Add trace-cmd options
Add trace-cmd options that reads all the plugins and lists
the available options for trace-cmd report.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Documentation/trace-cmd-options.1.txt | 35 | ||||
-rw-r--r-- | Documentation/trace-cmd.1.txt | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | trace-cmd.c | 3 | ||||
-rw-r--r-- | trace-local.h | 2 | ||||
-rw-r--r-- | trace-options.c | 113 | ||||
-rw-r--r-- | trace-usage.c | 5 |
7 files changed, 161 insertions, 1 deletions
diff --git a/Documentation/trace-cmd-options.1.txt b/Documentation/trace-cmd-options.1.txt new file mode 100644 index 0000000..2373554 --- /dev/null +++ b/Documentation/trace-cmd-options.1.txt | |||
@@ -0,0 +1,35 @@ | |||
1 | TRACE-CMD-OPTIONS(1) | ||
2 | =================== | ||
3 | |||
4 | NAME | ||
5 | ---- | ||
6 | trace-cmd-options - list available options from trace-cmd plugins | ||
7 | |||
8 | SYNOPSIS | ||
9 | -------- | ||
10 | *trace-cmd options* | ||
11 | |||
12 | DESCRIPTION | ||
13 | ----------- | ||
14 | The trace-cmd(1) options command will examine all the trace-cmd plugins | ||
15 | that are used by *trace-cmd report(1)* and list them. | ||
16 | |||
17 | SEE ALSO | ||
18 | -------- | ||
19 | trace-cmd(1), trace-cmd-record(1), trace-cmd-start(1), trace-cmd-stop(1), | ||
20 | trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), | ||
21 | trace-cmd-list(1), trace-cmd-listen(1) | ||
22 | |||
23 | AUTHOR | ||
24 | ------ | ||
25 | Written by Steven Rostedt, <rostedt@goodmis.org> | ||
26 | |||
27 | RESOURCES | ||
28 | --------- | ||
29 | git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git | ||
30 | |||
31 | COPYING | ||
32 | ------- | ||
33 | Copyright \(C) 2011 Red Hat, Inc. Free use of this software is granted under | ||
34 | the terms of the GNU Public License (GPL). | ||
35 | |||
diff --git a/Documentation/trace-cmd.1.txt b/Documentation/trace-cmd.1.txt index b67c023..f416b74 100644 --- a/Documentation/trace-cmd.1.txt +++ b/Documentation/trace-cmd.1.txt | |||
@@ -26,6 +26,8 @@ COMMANDS | |||
26 | report - reads a trace.dat file and converts the binary data to a | 26 | report - reads a trace.dat file and converts the binary data to a |
27 | ASCII text readable format. | 27 | ASCII text readable format. |
28 | 28 | ||
29 | options - list the plugin options that are available to *report* | ||
30 | |||
29 | start - start the tracing without recording to a trace.dat file. | 31 | start - start the tracing without recording to a trace.dat file. |
30 | 32 | ||
31 | stop - stop tracing (only disables recording, overhead of tracer | 33 | stop - stop tracing (only disables recording, overhead of tracer |
@@ -276,7 +276,7 @@ $(obj)/%.o: $(src)/%.c | |||
276 | TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-hash.o trace-dialog.o \ | 276 | TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-hash.o trace-dialog.o \ |
277 | trace-xml.o | 277 | trace-xml.o |
278 | TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ | 278 | TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \ |
279 | trace-stack.o | 279 | trace-stack.o trace-options.o |
280 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o | 280 | TRACE_VIEW_OBJS = trace-view.o trace-view-store.o |
281 | TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o | 281 | TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o |
282 | TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) | 282 | TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS) |
diff --git a/trace-cmd.c b/trace-cmd.c index c0b564c..02e16c0 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
@@ -166,6 +166,9 @@ int main (int argc, char **argv) | |||
166 | trace_record(argc, argv); | 166 | trace_record(argc, argv); |
167 | exit(0); | 167 | exit(0); |
168 | 168 | ||
169 | } else if (strcmp(argv[1], "options") == 0) { | ||
170 | trace_option(argc, argv); | ||
171 | exit(0); | ||
169 | } else if (strcmp(argv[1], "list") == 0) { | 172 | } else if (strcmp(argv[1], "list") == 0) { |
170 | int events = 0; | 173 | int events = 0; |
171 | int plug = 0; | 174 | int plug = 0; |
diff --git a/trace-local.h b/trace-local.h index a73377f..5bfa3bd 100644 --- a/trace-local.h +++ b/trace-local.h | |||
@@ -48,4 +48,6 @@ void trace_restore(int argc, char **argv); | |||
48 | 48 | ||
49 | void trace_stack(int argc, char **argv); | 49 | void trace_stack(int argc, char **argv); |
50 | 50 | ||
51 | void trace_option(int argc, char **argv); | ||
52 | |||
51 | #endif /* __TRACE_LOCAL_H */ | 53 | #endif /* __TRACE_LOCAL_H */ |
diff --git a/trace-options.c b/trace-options.c new file mode 100644 index 0000000..70c6343 --- /dev/null +++ b/trace-options.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> | ||
3 | * | ||
4 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License (not later!) | ||
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 Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | * | ||
19 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
20 | */ | ||
21 | #define _LARGEFILE64_SOURCE | ||
22 | #define _GNU_SOURCE | ||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | #include <getopt.h> | ||
27 | #include <unistd.h> | ||
28 | |||
29 | #include "trace-local.h" | ||
30 | |||
31 | enum { | ||
32 | OPT_kallsyms = 253, | ||
33 | OPT_events = 254, | ||
34 | OPT_cpu = 255, | ||
35 | }; | ||
36 | |||
37 | struct option_list { | ||
38 | struct option_list *next; | ||
39 | struct plugin_option *op; | ||
40 | }; | ||
41 | |||
42 | static struct plugin_list { | ||
43 | struct plugin_list *next; | ||
44 | const char *name; | ||
45 | struct option_list *ops; | ||
46 | } *plugin_list; | ||
47 | |||
48 | static void add_option(struct plugin_option *option) | ||
49 | { | ||
50 | struct plugin_list *pl; | ||
51 | struct option_list *po; | ||
52 | const char *name; | ||
53 | |||
54 | name = option->plugin_alias ? : option->file; | ||
55 | |||
56 | for (pl = plugin_list; pl; pl = pl->next) { | ||
57 | if (strcmp(name, pl->name) == 0) | ||
58 | break; | ||
59 | } | ||
60 | if (!pl) { | ||
61 | pl = malloc_or_die(sizeof(*pl)); | ||
62 | memset(pl, 0, sizeof(*pl)); | ||
63 | pl->name = name; | ||
64 | pl->next = plugin_list; | ||
65 | plugin_list = pl; | ||
66 | }; | ||
67 | po = malloc_or_die(sizeof(*po)); | ||
68 | po->next = pl->ops; | ||
69 | pl->ops = po; | ||
70 | po->op = option; | ||
71 | } | ||
72 | |||
73 | void trace_option (int argc, char **argv) | ||
74 | { | ||
75 | struct plugin_option *options; | ||
76 | struct plugin_option *op; | ||
77 | struct plugin_list *pl; | ||
78 | struct plugin_list *npl; | ||
79 | struct option_list *po; | ||
80 | struct option_list *npo; | ||
81 | |||
82 | if (argc < 2) | ||
83 | usage(argv); | ||
84 | |||
85 | if (strcmp(argv[1], "options") != 0) | ||
86 | usage(argv); | ||
87 | |||
88 | options = trace_util_read_plugin_options(); | ||
89 | if (!options) { | ||
90 | printf("No plugin options found\n"); | ||
91 | goto out; | ||
92 | } | ||
93 | |||
94 | /* Group them up according to aliases */ | ||
95 | for (op = options; op; op = op->next) | ||
96 | add_option(op); | ||
97 | |||
98 | for (pl = plugin_list; pl; pl = npl) { | ||
99 | npl = pl->next; | ||
100 | printf("%s\n", pl->name); | ||
101 | for (po = pl->ops; po; po = npo) { | ||
102 | npo = po->next; | ||
103 | printf(" %s: %s\n", | ||
104 | po->op->name, po->op->description); | ||
105 | free(po); | ||
106 | } | ||
107 | free(pl); | ||
108 | } | ||
109 | |||
110 | out: | ||
111 | trace_util_free_options(options); | ||
112 | return; | ||
113 | } | ||
diff --git a/trace-usage.c b/trace-usage.c index 1497279..39c8fc1 100644 --- a/trace-usage.c +++ b/trace-usage.c | |||
@@ -111,6 +111,11 @@ static struct usage_help usage_help[] = { | |||
111 | " end - decimal end time in seconds\n" | 111 | " end - decimal end time in seconds\n" |
112 | }, | 112 | }, |
113 | { | 113 | { |
114 | "options", | ||
115 | "list the plugin options available for trace-cmd report", | ||
116 | " %s options\n" | ||
117 | }, | ||
118 | { | ||
114 | "listen", | 119 | "listen", |
115 | "listen on a network socket for trace clients", | 120 | "listen on a network socket for trace clients", |
116 | " %s listen -p port[-D][-o file][-d dir][-l logfile]\n" | 121 | " %s listen -p port[-D][-o file][-d dir][-l logfile]\n" |