• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
4  *
5  */
6 #include <stdlib.h>
7 #include <getopt.h>
8 #include <errno.h>
9 
10 #include "tracefs.h"
11 #include "trace-local.h"
12 
13 enum {
14 	OPT_verbose	= 255,
15 };
16 
trace_check_events(int argc,char ** argv)17 void trace_check_events(int argc, char **argv)
18 {
19 	const char *tracing;
20 	int ret, c;
21 	int parsing_failures = 0;
22 	struct tep_handle *pevent = NULL;
23 	struct tep_plugin_list *list = NULL;
24 	int open_flags = 0;
25 	int option_index = 0;
26 	static struct option long_options[] = {
27 		{"verbose", optional_argument, NULL, OPT_verbose},
28 		{NULL, 0, NULL, 0}
29 	};
30 
31 
32 	while ((c = getopt_long(argc-1, argv+1, "+hN", long_options, &option_index)) >= 0) {
33 		switch (c) {
34 		case 'h':
35 		default:
36 			usage(argv);
37 			break;
38 		case 'N':
39 			open_flags |= TRACECMD_FL_LOAD_NO_PLUGINS;
40 			break;
41 		case OPT_verbose:
42 			if (trace_set_verbose(optarg) < 0)
43 				die("invalid verbose level %s", optarg);
44 			break;
45 		}
46 	}
47 	tracing = tracefs_tracing_dir();
48 
49 	if (!tracing) {
50 		printf("Can not find or mount tracing directory!\n"
51 		       "Either tracing is not configured for this "
52 		       "kernel\n"
53 		       "or you do not have the proper permissions to "
54 		       "mount the directory");
55 		exit(EINVAL);
56 	}
57 
58 	pevent = tep_alloc();
59 	if (!pevent)
60 		exit(EINVAL);
61 
62 	list = trace_load_plugins(pevent, open_flags);
63 	ret = tracefs_fill_local_events(tracing, pevent, &parsing_failures);
64 	if (ret || parsing_failures)
65 		ret = EINVAL;
66 	tep_unload_plugins(list, pevent);
67 	tep_free(pevent);
68 
69 	return;
70 }
71