aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaibhav Nagarnaik <vnagarnaik@google.com>2011-08-11 15:37:38 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-08-18 21:37:56 -0400
commit2f9502685d7938128e51b13154fc8a84b80d3fb6 (patch)
tree4464c4362ab010f7a140a6aae9670aab56d083bf
parent72a8ce0acbe2c51b2a7e9f04f1b47057ba01d62b (diff)
trace-cmd: Add --check-events to report
Add a new option --check-events to the report target which makes sure that the event formats in the trace data file can be parsed correctly on the machine that trace-cmd is running on. It returns EINVAL(22) for parsing failures and 0 for success. Cc: Michael Rubin <mrubin@google.com> Cc: David Sharp <dhsharp@google.com> Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com> Link: http://lkml.kernel.org/r/1313091459-12049-4-git-send-email-vnagarnaik@google.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-input.c16
-rw-r--r--trace-read.c20
-rw-r--r--trace-usage.c1
3 files changed, 29 insertions, 8 deletions
diff --git a/trace-input.c b/trace-input.c
index 723d47f..8c2b858 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -342,10 +342,12 @@ static int read_ftrace_file(struct tracecmd_input *handle,
342 return -1; 342 return -1;
343 } 343 }
344 344
345 if (print) 345 if (print) {
346 printf("%.*s\n", (int)size, buf); 346 printf("%.*s\n", (int)size, buf);
347 else 347 } else {
348 pevent_parse_event(pevent, buf, size, "ftrace"); 348 if (pevent_parse_event(pevent, buf, size, "ftrace"))
349 pevent->parsing_failures = 1;
350 }
349 free(buf); 351 free(buf);
350 352
351 return 0; 353 return 0;
@@ -367,10 +369,12 @@ static int read_event_file(struct tracecmd_input *handle,
367 return -1; 369 return -1;
368 } 370 }
369 371
370 if (print) 372 if (print) {
371 printf("%.*s\n", (int)size, buf); 373 printf("%.*s\n", (int)size, buf);
372 else 374 } else {
373 pevent_parse_event(pevent, buf, size, system); 375 if (pevent_parse_event(pevent, buf, size, system))
376 pevent->parsing_failures = 1;
377 }
374 free(buf); 378 free(buf);
375 379
376 return 0; 380 return 0;
diff --git a/trace-read.c b/trace-read.c
index 38e3534..2e45bff 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -826,6 +826,7 @@ static void process_plugin_option(char *option)
826} 826}
827 827
828enum { 828enum {
829 OPT_check_event_parsing = 252,
829 OPT_kallsyms = 253, 830 OPT_kallsyms = 253,
830 OPT_events = 254, 831 OPT_events = 254,
831 OPT_cpu = 255, 832 OPT_cpu = 255,
@@ -848,6 +849,8 @@ void trace_report (int argc, char **argv)
848 int test_filters = 0; 849 int test_filters = 0;
849 int raw = 0; 850 int raw = 0;
850 int neg = 0; 851 int neg = 0;
852 int ret = 0;
853 int check_event_parsing = 0;
851 int c; 854 int c;
852 855
853 list_head_init(&handle_list); 856 list_head_init(&handle_list);
@@ -868,6 +871,8 @@ void trace_report (int argc, char **argv)
868 {"events", no_argument, NULL, OPT_events}, 871 {"events", no_argument, NULL, OPT_events},
869 {"filter-test", no_argument, NULL, 'T'}, 872 {"filter-test", no_argument, NULL, 'T'},
870 {"kallsyms", required_argument, NULL, OPT_kallsyms}, 873 {"kallsyms", required_argument, NULL, OPT_kallsyms},
874 {"check-events", no_argument, NULL,
875 OPT_check_event_parsing},
871 {"help", no_argument, NULL, '?'}, 876 {"help", no_argument, NULL, '?'},
872 {NULL, 0, NULL, 0} 877 {NULL, 0, NULL, 0}
873 }; 878 };
@@ -948,6 +953,9 @@ void trace_report (int argc, char **argv)
948 case OPT_kallsyms: 953 case OPT_kallsyms:
949 functions = optarg; 954 functions = optarg;
950 break; 955 break;
956 case OPT_check_event_parsing:
957 check_event_parsing = 1;
958 break;
951 default: 959 default:
952 usage(argv); 960 usage(argv);
953 } 961 }
@@ -1005,8 +1013,16 @@ void trace_report (int argc, char **argv)
1005 return; 1013 return;
1006 } 1014 }
1007 1015
1008 if (tracecmd_read_headers(handle) < 0) 1016 ret = tracecmd_read_headers(handle);
1009 return; 1017 if (check_event_parsing) {
1018 if (ret || pevent->parsing_failures)
1019 exit(EINVAL);
1020 else
1021 exit(0);
1022 } else {
1023 if (ret)
1024 return;
1025 }
1010 1026
1011 if (show_funcs) { 1027 if (show_funcs) {
1012 pevent_print_funcs(pevent); 1028 pevent_print_funcs(pevent);
diff --git a/trace-usage.c b/trace-usage.c
index 7314657..0e2194e 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -91,6 +91,7 @@ static struct usage_help usage_help[] = {
91 " -w show wakeup latencies\n" 91 " -w show wakeup latencies\n"
92 " -l show latency format (default with latency tracers)\n" 92 " -l show latency format (default with latency tracers)\n"
93 " -O plugin option -O [plugin:]var[=val]\n" 93 " -O plugin option -O [plugin:]var[=val]\n"
94 " --check-events return whether all event formats can be parsed\n"
94 }, 95 },
95 { 96 {
96 "split", 97 "split",