aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-10-13 21:17:31 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-10-13 21:17:31 -0400
commitc7532db6549208d00c7a2555769296182a0cbe0d (patch)
tree473eabeef45ef3c67414fa5c331bc088762c08de
parent21a1b1ac8d57c64e67809727b54d0e8c6112d877 (diff)
add way to enable options in recording
Although most of the options are for print output, that does not even affect the report function. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/trace-cmd.c b/trace-cmd.c
index ad45081..759b6fa 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -374,6 +374,42 @@ static void set_plugin(const char *name)
374 fclose(fp); 374 fclose(fp);
375} 375}
376 376
377static void show_options(void)
378{
379 char buf[BUFSIZ];
380 char *path;
381 FILE *fp;
382 size_t n;
383
384 path = get_tracing_file("trace_options");
385 fp = fopen(path, "r");
386 if (!fp)
387 die("reading %s", path);
388 put_tracing_file(path);
389
390 do {
391 n = fread(buf, 1, BUFSIZ, fp);
392 if (n > 0)
393 fwrite(buf, 1, n, stdout);
394 } while (n > 0);
395 fclose(fp);
396}
397
398static void set_option(const char *option)
399{
400 FILE *fp;
401 char *path;
402
403 path = get_tracing_file("trace_options");
404 fp = fopen(path, "w");
405 if (!fp)
406 die("writing to '%s'", path);
407 put_tracing_file(path);
408
409 fwrite(option, 1, strlen(option), fp);
410 fclose(fp);
411}
412
377static void enable_event(const char *name) 413static void enable_event(const char *name)
378{ 414{
379 FILE *fp; 415 FILE *fp;
@@ -1033,11 +1069,12 @@ void usage(char **argv)
1033 1069
1034 printf("\n" 1070 printf("\n"
1035 "%s version %s\n\n" 1071 "%s version %s\n\n"
1036 "usage: %s record [-e event][-p plugin] [-d] [-o file] command ...\n" 1072 "usage: %s record [-e event][-p plugin] [-d] [-o file] [-O option ] command ...\n"
1037 " -e run command with event enabled\n" 1073 " -e run command with event enabled\n"
1038 " -p run command with plugin enabled\n" 1074 " -p run command with plugin enabled\n"
1039 " -d disable function tracer when running\n" 1075 " -d disable function tracer when running\n"
1040 " -o data output file [default trace.dat]\n" 1076 " -o data output file [default trace.dat]\n"
1077 " -O option to enable (or disable)\n"
1041 "\n" 1078 "\n"
1042 " %s report [-i file] [--cpu cpu] [-e][-f]\n" 1079 " %s report [-i file] [--cpu cpu] [-e][-f]\n"
1043 " -i input file [default trace.dat]\n" 1080 " -i input file [default trace.dat]\n"
@@ -1049,6 +1086,7 @@ void usage(char **argv)
1049 " %s list [-e][-p]\n" 1086 " %s list [-e][-p]\n"
1050 " -e list available events\n" 1087 " -e list available events\n"
1051 " -p list available plugins\n" 1088 " -p list available plugins\n"
1089 " -o list available options\n"
1052 "\n", p, VERSION, p, p, p); 1090 "\n", p, VERSION, p, p, p);
1053 exit(-1); 1091 exit(-1);
1054} 1092}
@@ -1057,10 +1095,12 @@ int main (int argc, char **argv)
1057{ 1095{
1058 const char *plugin = NULL; 1096 const char *plugin = NULL;
1059 const char *output = NULL; 1097 const char *output = NULL;
1098 const char *option;
1060 struct event_list *event; 1099 struct event_list *event;
1061 int disable = 0; 1100 int disable = 0;
1062 int plug = 0; 1101 int plug = 0;
1063 int events = 0; 1102 int events = 0;
1103 int options = 0;
1064 1104
1065 int c; 1105 int c;
1066 1106
@@ -1074,7 +1114,7 @@ int main (int argc, char **argv)
1074 exit(0); 1114 exit(0);
1075 } else if (strcmp(argv[1], "record") == 0) { 1115 } else if (strcmp(argv[1], "record") == 0) {
1076 1116
1077 while ((c = getopt(argc-1, argv+1, "+he:p:do:")) >= 0) { 1117 while ((c = getopt(argc-1, argv+1, "+he:p:do:O:")) >= 0) {
1078 switch (c) { 1118 switch (c) {
1079 case 'h': 1119 case 'h':
1080 usage(argv); 1120 usage(argv);
@@ -1099,12 +1139,17 @@ int main (int argc, char **argv)
1099 if (output) 1139 if (output)
1100 die("only one output file allowed"); 1140 die("only one output file allowed");
1101 output = optarg; 1141 output = optarg;
1142 break;
1143 case 'O':
1144 option = optarg;
1145 set_option(option);
1146 break;
1102 } 1147 }
1103 } 1148 }
1104 1149
1105 } else if (strcmp(argv[1], "list") == 0) { 1150 } else if (strcmp(argv[1], "list") == 0) {
1106 1151
1107 while ((c = getopt(argc-1, argv+1, "+hep")) >= 0) { 1152 while ((c = getopt(argc-1, argv+1, "+hepo")) >= 0) {
1108 switch (c) { 1153 switch (c) {
1109 case 'h': 1154 case 'h':
1110 usage(argv); 1155 usage(argv);
@@ -1115,6 +1160,9 @@ int main (int argc, char **argv)
1115 case 'p': 1160 case 'p':
1116 plug = 1; 1161 plug = 1;
1117 break; 1162 break;
1163 case 'o':
1164 options = 1;
1165 break;
1118 default: 1166 default:
1119 usage(argv); 1167 usage(argv);
1120 } 1168 }
@@ -1126,11 +1174,16 @@ int main (int argc, char **argv)
1126 if (plug) 1174 if (plug)
1127 show_plugins(); 1175 show_plugins();
1128 1176
1129 if (!events && !plug) { 1177 if (options)
1178 show_options();
1179
1180 if (!events && !plug && !options) {
1130 printf("events:\n"); 1181 printf("events:\n");
1131 show_events(); 1182 show_events();
1132 printf("\nplugins:\n"); 1183 printf("\nplugins:\n");
1133 show_plugins(); 1184 show_plugins();
1185 printf("\noptions:\n");
1186 show_options();
1134 } 1187 }
1135 1188
1136 exit(0); 1189 exit(0);