aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-11 13:43:52 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-11 13:43:52 -0500
commitf226e2a601d2ef2b74f7c937743ef97519a3be6e (patch)
treea605ebe722419ae8e5f7a0c7ff321395e2adb91e
parent60ee8880f2b030053e8a4d7aa4a140ef9b6b0a8b (diff)
Have trace-cmd record not need a command
Currently trace-cmd record requires a command to exec. This patch will just record what is happening if no command is given and will stop when the user hits Ctrl^C. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-cmd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/trace-cmd.c b/trace-cmd.c
index 26fd883..aca6f90 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -1106,7 +1106,7 @@ void usage(char **argv)
1106 printf("\n" 1106 printf("\n"
1107 "%s version %s\n\n" 1107 "%s version %s\n\n"
1108 "usage:\n" 1108 "usage:\n"
1109 " %s record [-e event][-p plugin] [-d] [-o file] [-O option ] command ...\n" 1109 " %s record [-e event][-p plugin] [-d] [-o file] [-O option ] [command ...]\n"
1110 " -e run command with event enabled\n" 1110 " -e run command with event enabled\n"
1111 " -p run command with plugin enabled\n" 1111 " -p run command with plugin enabled\n"
1112 " -d disable function tracer when running\n" 1112 " -d disable function tracer when running\n"
@@ -1152,6 +1152,7 @@ int main (int argc, char **argv)
1152 int events = 0; 1152 int events = 0;
1153 int options = 0; 1153 int options = 0;
1154 int record = 0; 1154 int record = 0;
1155 int run_command = 0;
1155 int fset; 1156 int fset;
1156 1157
1157 int c; 1158 int c;
@@ -1257,12 +1258,12 @@ int main (int argc, char **argv)
1257 usage(argv); 1258 usage(argv);
1258 } 1259 }
1259 1260
1260 if ((argc - optind) < 2) { 1261 if ((argc - optind) >= 2) {
1261 if (record) 1262 if (!record)
1262 usage(argv); 1263 die("Command start does not take any commands\n"
1263 } else if (!record) 1264 "Did you mean 'record'?");
1264 die("Command start does not take any commands\n" 1265 run_command = 1;
1265 "Did you mean 'record'?"); 1266 }
1266 1267
1267 if (!events && !plugin) 1268 if (!events && !plugin)
1268 die("no event or plugin was specified... aborting"); 1269 die("no event or plugin was specified... aborting");
@@ -1308,7 +1309,15 @@ int main (int argc, char **argv)
1308 if (!record) 1309 if (!record)
1309 exit(0); 1310 exit(0);
1310 1311
1311 run_cmd((argc - optind) - 1, &argv[optind + 1]); 1312 if (run_command)
1313 run_cmd((argc - optind) - 1, &argv[optind + 1]);
1314 else {
1315 /* sleep till we are woken with Ctrl^C */
1316 printf("Hit Ctrl^C to stop recording\n");
1317 while (!finished)
1318 sleep(10);
1319
1320 }
1312 1321
1313 disable_tracing(); 1322 disable_tracing();
1314 1323