diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2009-12-09 21:11:28 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-09 21:11:28 -0500 |
| commit | 96de171c7597161a3da63dc078d1f94d695bce34 (patch) | |
| tree | 0c9bd868fd963ca92b8f860bb8b75511e0db7ac4 | |
| parent | a4619e35c7667fd5a502ec41c2fff88296c93e64 (diff) | |
Added trace-cmd start, stop and reset
Sometimes it is nice to just kick off the tracer without having to
record it into a trace data file. Instead of having to always
echo the commands into the tracing debugfs directory, this patch adds
the trace-cmd start, which acts like the trace-cmd record, but does
not start a command or record the trace via splice. It simply enables
the tracer.
trace-cmd stop - will stop tracing (echo 0 > tracing_on)
trace-cmd reset - will reset the tracer (echo nop > current_tracer)
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-cmd.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 6719fc3..22441b8 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
| @@ -1105,13 +1105,26 @@ void usage(char **argv) | |||
| 1105 | 1105 | ||
| 1106 | printf("\n" | 1106 | printf("\n" |
| 1107 | "%s version %s\n\n" | 1107 | "%s version %s\n\n" |
| 1108 | "usage: %s record [-e event][-p plugin] [-d] [-o file] [-O option ] command ...\n" | 1108 | "usage:\n" |
| 1109 | " %s record [-e event][-p plugin] [-d] [-o file] [-O option ] command ...\n" | ||
| 1109 | " -e run command with event enabled\n" | 1110 | " -e run command with event enabled\n" |
| 1110 | " -p run command with plugin enabled\n" | 1111 | " -p run command with plugin enabled\n" |
| 1111 | " -d disable function tracer when running\n" | 1112 | " -d disable function tracer when running\n" |
| 1112 | " -o data output file [default trace.dat]\n" | 1113 | " -o data output file [default trace.dat]\n" |
| 1113 | " -O option to enable (or disable)\n" | 1114 | " -O option to enable (or disable)\n" |
| 1114 | "\n" | 1115 | "\n" |
| 1116 | " %s start [-e event][-p plugin] [-d] [-O option ]\n" | ||
| 1117 | " Uses same options as record, but does not run a command.\n" | ||
| 1118 | " It only enables the tracing and exits\n" | ||
| 1119 | "\n" | ||
| 1120 | " %s stop\n" | ||
| 1121 | " Stops the tracer from recording more data.\n" | ||
| 1122 | " Used in conjunction with start\n" | ||
| 1123 | "\n" | ||
| 1124 | " %s reset\n" | ||
| 1125 | " Disables the tracer (may reset trace file)\n" | ||
| 1126 | " Used in conjunction with start\n" | ||
| 1127 | "\n" | ||
| 1115 | " %s report [-i file] [--cpu cpu] [-e][-f][-l][-P][-E]\n" | 1128 | " %s report [-i file] [--cpu cpu] [-e][-f][-l][-P][-E]\n" |
| 1116 | " -i input file [default trace.dat]\n" | 1129 | " -i input file [default trace.dat]\n" |
| 1117 | " -e show file endianess\n" | 1130 | " -e show file endianess\n" |
| @@ -1124,7 +1137,7 @@ void usage(char **argv) | |||
| 1124 | " -e list available events\n" | 1137 | " -e list available events\n" |
| 1125 | " -p list available plugins\n" | 1138 | " -p list available plugins\n" |
| 1126 | " -o list available options\n" | 1139 | " -o list available options\n" |
| 1127 | "\n", p, VERSION, p, p, p); | 1140 | "\n", p, VERSION, p, p, p, p, p, p); |
| 1128 | exit(-1); | 1141 | exit(-1); |
| 1129 | } | 1142 | } |
| 1130 | 1143 | ||
| @@ -1138,6 +1151,7 @@ int main (int argc, char **argv) | |||
| 1138 | int plug = 0; | 1151 | int plug = 0; |
| 1139 | int events = 0; | 1152 | int events = 0; |
| 1140 | int options = 0; | 1153 | int options = 0; |
| 1154 | int record = 0; | ||
| 1141 | int fset; | 1155 | int fset; |
| 1142 | 1156 | ||
| 1143 | int c; | 1157 | int c; |
| @@ -1150,7 +1164,8 @@ int main (int argc, char **argv) | |||
| 1150 | if (strcmp(argv[1], "report") == 0) { | 1164 | if (strcmp(argv[1], "report") == 0) { |
| 1151 | trace_report(argc, argv); | 1165 | trace_report(argc, argv); |
| 1152 | exit(0); | 1166 | exit(0); |
| 1153 | } else if (strcmp(argv[1], "record") == 0) { | 1167 | } else if ((record = (strcmp(argv[1], "record") == 0)) || |
| 1168 | (strcmp(argv[1], "start") == 0)) { | ||
| 1154 | 1169 | ||
| 1155 | while ((c = getopt(argc-1, argv+1, "+he:p:do:O:")) >= 0) { | 1170 | while ((c = getopt(argc-1, argv+1, "+he:p:do:O:")) >= 0) { |
| 1156 | switch (c) { | 1171 | switch (c) { |
| @@ -1174,6 +1189,9 @@ int main (int argc, char **argv) | |||
| 1174 | disable = 1; | 1189 | disable = 1; |
| 1175 | break; | 1190 | break; |
| 1176 | case 'o': | 1191 | case 'o': |
| 1192 | if (!record) | ||
| 1193 | die("start does not take output\n" | ||
| 1194 | "Did you mean 'record'?\n"); | ||
| 1177 | if (output) | 1195 | if (output) |
| 1178 | die("only one output file allowed"); | 1196 | die("only one output file allowed"); |
| 1179 | output = optarg; | 1197 | output = optarg; |
| @@ -1185,6 +1203,14 @@ int main (int argc, char **argv) | |||
| 1185 | } | 1203 | } |
| 1186 | } | 1204 | } |
| 1187 | 1205 | ||
| 1206 | } else if (strcmp(argv[1], "stop") == 0) { | ||
| 1207 | disable_tracing(); | ||
| 1208 | exit(0); | ||
| 1209 | |||
| 1210 | } else if (strcmp(argv[1], "reset") == 0) { | ||
| 1211 | disable_all(); | ||
| 1212 | exit(0); | ||
| 1213 | |||
| 1188 | } else if (strcmp(argv[1], "list") == 0) { | 1214 | } else if (strcmp(argv[1], "list") == 0) { |
| 1189 | 1215 | ||
| 1190 | while ((c = getopt(argc-1, argv+1, "+hepo")) >= 0) { | 1216 | while ((c = getopt(argc-1, argv+1, "+hepo")) >= 0) { |
| @@ -1231,21 +1257,26 @@ int main (int argc, char **argv) | |||
| 1231 | usage(argv); | 1257 | usage(argv); |
| 1232 | } | 1258 | } |
| 1233 | 1259 | ||
| 1234 | if ((argc - optind) < 2) | 1260 | if ((argc - optind) < 2) { |
| 1235 | usage(argv); | 1261 | if (record) |
| 1262 | usage(argv); | ||
| 1263 | } else if (!record) | ||
| 1264 | die("Command start does not take any commands\n" | ||
| 1265 | "Did you mean 'record'?"); | ||
| 1236 | 1266 | ||
| 1237 | if (output) | 1267 | if (record) { |
| 1238 | output_file = output; | 1268 | if (output) |
| 1269 | output_file = output; | ||
| 1239 | 1270 | ||
| 1240 | read_tracing_data(); | 1271 | read_tracing_data(); |
| 1241 | 1272 | ||
| 1242 | fset = set_ftrace(!disable); | 1273 | fset = set_ftrace(!disable); |
| 1243 | 1274 | ||
| 1244 | disable_all(); | 1275 | start_threads(); |
| 1245 | 1276 | signal(SIGINT, finish); | |
| 1246 | start_threads(); | 1277 | } |
| 1247 | 1278 | ||
| 1248 | signal(SIGINT, finish); | 1279 | disable_all(); |
| 1249 | 1280 | ||
| 1250 | if (events) | 1281 | if (events) |
| 1251 | enable_events(); | 1282 | enable_events(); |
| @@ -1260,7 +1291,8 @@ int main (int argc, char **argv) | |||
| 1260 | strcmp(plugin, "wakeup") == 0 || | 1291 | strcmp(plugin, "wakeup") == 0 || |
| 1261 | strcmp(plugin, "wakeup_rt") == 0) { | 1292 | strcmp(plugin, "wakeup_rt") == 0) { |
| 1262 | latency = 1; | 1293 | latency = 1; |
| 1263 | stop_threads(); | 1294 | if (record) |
| 1295 | stop_threads(); | ||
| 1264 | reset_max_latency(); | 1296 | reset_max_latency(); |
| 1265 | } | 1297 | } |
| 1266 | if (fset < 0 && (strcmp(plugin, "function") == 0 || | 1298 | if (fset < 0 && (strcmp(plugin, "function") == 0 || |
| @@ -1271,6 +1303,9 @@ int main (int argc, char **argv) | |||
| 1271 | 1303 | ||
| 1272 | enable_tracing(); | 1304 | enable_tracing(); |
| 1273 | 1305 | ||
| 1306 | if (!record) | ||
| 1307 | exit(0); | ||
| 1308 | |||
| 1274 | run_cmd((argc - optind) - 1, &argv[optind + 1]); | 1309 | run_cmd((argc - optind) - 1, &argv[optind + 1]); |
| 1275 | 1310 | ||
| 1276 | disable_tracing(); | 1311 | disable_tracing(); |
