1LIBTRACEEVENT(3) libtraceevent Manual LIBTRACEEVENT(3)
2
3
4
6 tep_load_plugins, tep_unload_plugins, tep_load_plugins_hook,
7 tep_add_plugin_path, tep_plugin_add_option - Load / unload traceevent
8 plugins.
9
11 #include <event-parse.h>
12
13 struct tep_plugin_list *tep_load_plugins(struct tep_handle *tep);
14 void tep_unload_plugins(struct tep_plugin_list *plugin_list, struct tep_handle *tep);
15 void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix,
16 void (*load_plugin)(struct tep_handle *tep,
17 const char *path,
18 const char *name,
19 void *data),
20 void *data);
21 int tep_add_plugin_path(struct tep_handle *tep, char *path,
22 enum tep_plugin_load_priority prio);
23 int tep_plugin_add_option(const char *name, const char *val);
24
26 The tep_load_plugins() function loads all plugins, located in the
27 plugin directories. The tep argument is trace event parser context. The
28 plugin directories are :
29
30 - Directories, specified in tep→plugins_dir with priority TEP_PLUGIN_FIRST
31 - System’s plugin directory, defined at the library compile time. It
32 depends on the library installation prefix and usually is
33 (install_preffix)/lib/traceevent/plugins
34 - Directory, defined by the environment variable TRACEEVENT_PLUGIN_DIR
35 - User’s plugin directory, located at ~/.local/lib/traceevent/plugins
36 - Directories, specified in tep→plugins_dir with priority TEP_PLUGIN_LAST
37
38 Loading of plugins can be controlled by the tep_flags, using the
39 tep_set_flag() API:
40
41 TEP_DISABLE_SYS_PLUGINS - do not load plugins, located in
42 the system’s plugin directory.
43 TEP_DISABLE_PLUGINS - do not load any plugins.
44
45 The tep_set_flag() API needs to be called before tep_load_plugins(), if
46 loading of all plugins is not the desired case.
47
48 The tep_unload_plugins() function unloads the plugins, previously
49 loaded by tep_load_plugins(). The tep argument is trace event parser
50 context. The plugin_list is the list of loaded plugins, returned by the
51 tep_load_plugins() function.
52
53 The tep_load_plugins_hook() function walks through all directories with
54 plugins and calls user specified load_plugin() hook for each plugin
55 file. Only files with given suffix are considered to be plugins. The
56 data is a user specified context, passed to load_plugin(). Directories
57 and the walk order are the same as in tep_load_plugins() API.
58
59 The tep_add_plugin_path() functions adds additional directories with
60 plugins in the tep→plugins_dir list. It must be called before
61 tep_load_plugins() in order for the plugins from the new directories to
62 be loaded. The tep argument is the trace event parser context. The path
63 is the full path to the new plugin directory. The prio argument
64 specifies the loading priority order for the new directory of plugins.
65 The loading priority is important in case of different versions of the
66 same plugin located in multiple plugin directories.The last loaded
67 plugin wins. The priority can be:
68
69 TEP_PLUGIN_FIRST - Load plugins from this directory first
70 TEP_PLUGIN_LAST - Load plugins from this directory last
71
72 Where the plugins in TEP_PLUGIN_LAST" will take precedence over the
73 plugins in the other directories.
74
75 The tep_plugin_add_option() sets options defined by a plugin. The name
76 is the name of the option to set to val. Plugins can add options to
77 change its behavior and tep_plugin_add_option() is used by the
78 application to make those modifications.
79
81 The tep_load_plugins() function returns a list of successfully loaded
82 plugins, or NULL in case no plugins are loaded. The
83 tep_add_plugin_path() function returns -1 in case of an error, 0
84 otherwise.
85
87 #include <event-parse.h>
88 ...
89 struct tep_handle *tep = tep_alloc();
90 ...
91 tep_add_plugin_path(tep, "~/dev_plugins", TEP_PLUGIN_LAST);
92 ...
93 struct tep_plugin_list *plugins = tep_load_plugins(tep);
94 if (plugins == NULL) {
95 /* no plugins are loaded */
96 }
97 ...
98 tep_unload_plugins(plugins, tep);
99 ...
100 void print_plugin(struct tep_handle *tep, const char *path,
101 const char *name, void *data)
102 {
103 pritnf("Found libtraceevent plugin %s/%s\n", path, name);
104 }
105 ...
106 tep_load_plugins_hook(tep, ".so", print_plugin, NULL);
107 ...
108
110 event-parse.h
111 Header file to include in order to have access to the library APIs.
112 -ltraceevent
113 Linker switch to add when building a program that uses the library.
114
116 libtraceevent(3), trace-cmd(1), tep_set_flag(3)
117
119 Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
120 Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page.
121
123 Report bugs to <linux-trace-devel@vger.kernel.org[3]>
124
126 libtraceevent is Free Software licensed under the GNU LGPL 2.1
127
129 https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
130
132 1. rostedt@goodmis.org
133 mailto:rostedt@goodmis.org
134
135 2. tz.stoyanov@gmail.com
136 mailto:tz.stoyanov@gmail.com
137
138 3. linux-trace-devel@vger.kernel.org
139 mailto:linux-trace-devel@vger.kernel.org
140
141
142
143libtraceevent 1.7.2 07/20/2023 LIBTRACEEVENT(3)