aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Hart <dvhltc@us.ibm.com>2009-12-29 14:17:37 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-29 14:40:37 -0500
commit7141d5ba5a7bad1fd822ccb9055b9cb3c96b3c45 (patch)
treec2dd681794a1418d18c47240e483e25b85c37315
parent98d89eabeb07983c6db970bc795bbf32b1d16b99 (diff)
trace-view: Add getopt support to gui tools for input file
Signed-off-by: Darren Hart <dvhltc@us.ibm.com> LKML-Reference: <4B3A5AD1.8020001@us.ibm.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel-shark.c28
-rw-r--r--trace-graph-main.c28
-rw-r--r--trace-view-main.c29
3 files changed, 82 insertions, 3 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index 158b9ac..0d72459 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -18,12 +18,15 @@
18 * 18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */ 20 */
21#define _GNU_SOURCE
21#include <stdio.h> 22#include <stdio.h>
22#include <string.h> 23#include <string.h>
23#include <stdarg.h> 24#include <stdarg.h>
24#include <fcntl.h> 25#include <fcntl.h>
25#include <unistd.h> 26#include <unistd.h>
26#include <gtk/gtk.h> 27#include <gtk/gtk.h>
28#include <getopt.h>
29#include <string.h>
27 30
28#include "trace-compat.h" 31#include "trace-compat.h"
29#include "trace-cmd.h" 32#include "trace-cmd.h"
@@ -34,7 +37,15 @@
34#define TRACE_WIDTH 800 37#define TRACE_WIDTH 800
35#define TRACE_HEIGHT 600 38#define TRACE_HEIGHT 600
36 39
37#define input_file "trace.dat" 40#define default_input_file "trace.dat"
41static char *input_file = default_input_file;
42
43void usage(char *prog)
44{
45 printf("Usage: %s\n", prog);
46 printf(" -h Display this help message\n");
47 printf(" -i input_file, default is %s\n", default_input_file);
48}
38 49
39/* graph callbacks */ 50/* graph callbacks */
40 51
@@ -161,6 +172,21 @@ void kernel_shark(int argc, char **argv)
161 GtkWidget *draw; 172 GtkWidget *draw;
162 GtkWidget *label; 173 GtkWidget *label;
163 GtkWidget *spin; 174 GtkWidget *spin;
175 int c;
176
177 while ((c = getopt(argc, argv, "hi:")) != -1) {
178 switch(c) {
179 case 'h':
180 usage(basename(argv[0]));
181 return;
182 case 'i':
183 input_file = optarg;
184 break;
185 default:
186 /* assume the other options are for gtk */
187 break;
188 }
189 }
164 190
165 info = g_new0(typeof(*info), 1); 191 info = g_new0(typeof(*info), 1);
166 if (!info) 192 if (!info)
diff --git a/trace-graph-main.c b/trace-graph-main.c
index 4eb257f..54194e1 100644
--- a/trace-graph-main.c
+++ b/trace-graph-main.c
@@ -1,4 +1,7 @@
1#define _GNU_SOURCE
1#include <gtk/gtk.h> 2#include <gtk/gtk.h>
3#include <getopt.h>
4#include <string.h>
2 5
3#include "trace-cmd.h" 6#include "trace-cmd.h"
4#include "trace-graph.h" 7#include "trace-graph.h"
@@ -7,10 +10,18 @@
7 10
8#define TRACE_WIDTH 800 11#define TRACE_WIDTH 800
9#define TRACE_HEIGHT 600 12#define TRACE_HEIGHT 600
10#define input_file "trace.dat"
11 13
14#define default_input_file "trace.dat"
15static char *input_file = default_input_file;
12static struct graph_info *ginfo; 16static struct graph_info *ginfo;
13 17
18void usage(char *prog)
19{
20 printf("Usage: %s\n", prog);
21 printf(" -h Display this help message\n");
22 printf(" -i input_file, default is %s\n", default_input_file);
23}
24
14/* Callback for the clicked signal of the Exit button */ 25/* Callback for the clicked signal of the Exit button */
15static void 26static void
16exit_clicked (GtkWidget *widget, gpointer data) 27exit_clicked (GtkWidget *widget, gpointer data)
@@ -42,6 +53,21 @@ void trace_graph(int argc, char **argv)
42 GtkWidget *sub_item; 53 GtkWidget *sub_item;
43 GtkWidget *scrollwin; 54 GtkWidget *scrollwin;
44 GtkWidget *draw; 55 GtkWidget *draw;
56 int c;
57
58 while ((c = getopt(argc, argv, "hi:")) != -1) {
59 switch(c) {
60 case 'h':
61 usage(basename(argv[0]));
62 return;
63 case 'i':
64 input_file = optarg;
65 break;
66 default:
67 /* assume the other options are for gtk */
68 break;
69 }
70 }
45 71
46 handle = tracecmd_open(input_file); 72 handle = tracecmd_open(input_file);
47 73
diff --git a/trace-view-main.c b/trace-view-main.c
index c0eb716..5b6eb7b 100644
--- a/trace-view-main.c
+++ b/trace-view-main.c
@@ -1,4 +1,7 @@
1#define _GNU_SOURCE
1#include <gtk/gtk.h> 2#include <gtk/gtk.h>
3#include <getopt.h>
4#include <string.h>
2 5
3#include "trace-cmd.h" 6#include "trace-cmd.h"
4#include "trace-view.h" 7#include "trace-view.h"
@@ -7,11 +10,20 @@
7 10
8#define TRACE_WIDTH 800 11#define TRACE_WIDTH 800
9#define TRACE_HEIGHT 600 12#define TRACE_HEIGHT 600
10#define input_file "trace.dat" 13
14#define default_input_file "trace.dat"
15static char *input_file = default_input_file;
11 16
12GtkWidget *trace_tree; 17GtkWidget *trace_tree;
13static struct tracecmd_input *handle; 18static struct tracecmd_input *handle;
14 19
20void usage(char *prog)
21{
22 printf("Usage: %s\n", prog);
23 printf(" -h Display this help message\n");
24 printf(" -i input_file, default is %s\n", default_input_file);
25}
26
15/* Callback for the clicked signal of the Exit button */ 27/* Callback for the clicked signal of the Exit button */
16static void 28static void
17exit_clicked (GtkWidget *widget, gpointer data) 29exit_clicked (GtkWidget *widget, gpointer data)
@@ -76,6 +88,21 @@ void trace_view(int argc, char **argv)
76 GtkWidget *scrollwin; 88 GtkWidget *scrollwin;
77 GtkWidget *label; 89 GtkWidget *label;
78 GtkWidget *spin; 90 GtkWidget *spin;
91 int c;
92
93 while ((c = getopt(argc, argv, "hi:")) != -1) {
94 switch(c) {
95 case 'h':
96 usage(basename(argv[0]));
97 return;
98 case 'i':
99 input_file = optarg;
100 break;
101 default:
102 /* assume the other options are for gtk */
103 break;
104 }
105 }
79 106
80 handle = tracecmd_open(input_file); 107 handle = tracecmd_open(input_file);
81 108