Skip to contentSkip to conversation

trace-cmd,libtraceevent: Rework of plugin options APIs

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 8 messages Jan 22, 2020

lore
Share & tools
lore
#0 lore raw

cover trace-cmd,libtraceevent: Rework of plugin options APIs

In order to simplify libtracevents APIs, logic related to plugins and plugin options is reworked:
- Complex and not used APIs are removed.
- Logic for printing various information for plugins and plugin options is moved from the library to the application.
- Additional checks are added when loading new plugins and options, to avoid duplications.

Tzvetomir Stoyanov (VMware) (7):
trace-cmd,libtraceevent: Plugin options rework trace-cmd,libtraceevent: Remove TEP_PLUGIN_OPTIONS trace-cmd,libtraceevent: Check for plugin options duplication trace-cmd,libtraceevent: Check for plugin duplication trace-cmd,libtraceevent: Remove API for plugin options print trace-cmd,libtraceevent: Remove API for plugin print trace-cmd, kernelshark, libtraceevent: Changed tep_plugin_add_option()
API

 include/traceevent/event-parse.h         |  50 +---
 kernel-shark/src/libkshark.c             |   4 +-
 lib/trace-cmd/trace-ftrace.c             |   4 +-
 lib/trace-cmd/trace-plugin.c             |   5 -
 lib/traceevent/event-plugin.c            | 279 ++++++++++-------------
 lib/traceevent/plugins/plugin_function.c |   6 +-
 tracecmd/trace-list.c                    |  55 ++++-
 tracecmd/trace-read.c                    |   2 +-
 8 files changed, 188 insertions(+), 217 deletions(-)
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/7 trace-cmd,libtraceevent: Plugin options rework

When registering a plugin option, the current API allows to set an alias to the option's plugin. This logic complicates the implementation, but is not used by any existing plugin.
In order to simplify the libtracevent API, these changes are introduced, related to plugin options:
- Removed "plugin_alias" from options and all logic associated with it.
- Renamed "file" field to "plugin", the new name describes more closely its purpose.

---
 include/traceevent/event-parse.h         | 13 +-------
 lib/trace-cmd/trace-ftrace.c             |  4 +--
 lib/trace-cmd/trace-plugin.c             |  5 ---
 lib/traceevent/event-plugin.c            | 41 +++++++-----------------
 lib/traceevent/plugins/plugin_function.c |  6 ++--
 5 files changed, 17 insertions(+), 52 deletions(-)
include/traceevent/event-parse.h +1 -12
index 52bafa5..72f7aaf 100644
@@ -56,9 +56,8 @@ typedef int (*tep_plugin_unload_func)(struct tep_handle *tep);
 struct tep_plugin_option {
 	struct tep_plugin_option	*next;
 	void				*handle;
-	char				*file;
+	char				*plugin;
 	char				*name;
-	char				*plugin_alias;
 	char				*description;
 	const char			*value;
 	void				*priv;
@@ -84,7 +83,6 @@ struct tep_plugin_option {
  *   struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = {
  *	{
  *		.name = "option-name",
- *		.plugin_alias = "override-file-name", (optional)
  *		.description = "description of option to show users",
  *	},
  *	{
@@ -94,27 +92,18 @@ struct tep_plugin_option {
  *
  *   Array must end with .name = NULL;
  *
- *
- *   .plugin_alias is used to give a shorter name to access
- *   the vairable. Useful if a plugin handles more than one event.
- *
  *   If .value is not set, then it is considered a boolean and only
  *   .set will be processed. If .value is defined, then it is considered
  *   a string option and .set will be ignored.
- *
- * TEP_PLUGIN_ALIAS: (optional)
- *   The name to use for finding options (uses filename if not defined)
  */
 #define TEP_PLUGIN_LOADER tep_plugin_loader
 #define TEP_PLUGIN_UNLOADER tep_plugin_unloader
 #define TEP_PLUGIN_OPTIONS tep_plugin_options
-#define TEP_PLUGIN_ALIAS tep_plugin_alias
 #define _MAKE_STR(x)	#x
 #define MAKE_STR(x)	_MAKE_STR(x)
 #define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER)
 #define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER)
 #define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
-#define TEP_PLUGIN_ALIAS_NAME MAKE_STR(TEP_PLUGIN_ALIAS)
 
 enum tep_format_flags {
 	TEP_FIELD_IS_ARRAY	= 1,
lib/trace-cmd/trace-ftrace.c +2 -2
index 20bf71f..f251ad1 100644
@@ -12,14 +12,14 @@
 
 struct tep_plugin_option trace_ftrace_options[] = {
 	{
+		.plugin = "ftrace",
 		.name = "tailprint",
-		.plugin_alias = "fgraph",
 		.description =
 		"Print function name at function exit in function graph",
 	},
 	{
+		.plugin = "ftrace",
 		.name = "depth",
-		.plugin_alias = "fgraph",
 		.description =
 		"Show the depth of each entry",
 	},
lib/trace-cmd/trace-plugin.c +0 -5
index 6bec18b..ce2f062 100644
@@ -100,7 +100,6 @@ load_plugin(struct trace_plugin_context *trace, const char *path,
 	struct trace_plugin_list **plugin_list = data;
 	tracecmd_plugin_load_func func;
 	struct trace_plugin_list *list;
-	const char *alias;
 	char *plugin;
 	void *handle;
 	int ret;
@@ -118,10 +117,6 @@ load_plugin(struct trace_plugin_context *trace, const char *path,
 		goto out_free;
 	}
 
-	alias = dlsym(handle, TRACECMD_PLUGIN_ALIAS_NAME);
-	if (!alias)
-		alias = file;
-
 	func = dlsym(handle, TRACECMD_PLUGIN_LOADER_NAME);
 	if (!func) {
 		warning("could not find func '%s' in plugin '%s'\n%s\n",
lib/traceevent/event-plugin.c +11 -30

87 lines not on this page · raw message

lib/traceevent/plugins/plugin_function.c +3 -3
index 938b741..8c36920 100644
@@ -22,21 +22,21 @@ static int cpus = -1;
 struct tep_plugin_option plugin_options[] =
 {
 	{
+		.plugin = "ftrace",
 		.name = "parent",
-		.plugin_alias = "ftrace",
 		.description =
 		"Print parent of functions for function events",
 	},
 	{
+		.plugin = "ftrace",
 		.name = "indent",
-		.plugin_alias = "ftrace",
 		.description =
 		"Try to show function call indents, based on parents",
 		.set = 1,
 	},
 	{
+		.plugin = "ftrace",
 		.name = "offset",
-		.plugin_alias = "ftrace",
 		.description =
 		"Show function names as well as their offsets",
 		.set = 0,
Signature · 1 line
2.24.1
#2 lore raw

PATCH 2/7 trace-cmd,libtraceevent: Remove TEP_PLUGIN_OPTIONS

In reply to Tzvetomir Stoyanov (VMware)

When loading a plugin, the current API searches for TEP_PLUGIN_OPTIONS array in plugin's symbols and loads any options from it. This API duplicates
tep_plugin_add_options()
In order to simplify the APIs, The duplicated TEP_PLUGIN_OPTIONS is removed as an API, as it is not used by any existing plugin. The tep_plugin_add_options() API is the only way to register plugin options.

---
 include/traceevent/event-parse.h | 20 --------------------
 lib/traceevent/event-plugin.c    | 11 -----------
 2 files changed, 31 deletions(-)
include/traceevent/event-parse.h +0 -20
index 72f7aaf..cb1b46e 100644
@@ -77,33 +77,13 @@ struct tep_plugin_option {
  *
  *   int TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  *
- * TEP_PLUGIN_OPTIONS:  (optional)
- *   Plugin options that can be set before loading
- *
- *   struct tep_plugin_option TEP_PLUGIN_OPTIONS[] = {
- *	{
- *		.name = "option-name",
- *		.description = "description of option to show users",
- *	},
- *	{
- *		.name = NULL,
- *	},
- *   };
- *
- *   Array must end with .name = NULL;
- *
- *   If .value is not set, then it is considered a boolean and only
- *   .set will be processed. If .value is defined, then it is considered
- *   a string option and .set will be ignored.
  */
 #define TEP_PLUGIN_LOADER tep_plugin_loader
 #define TEP_PLUGIN_UNLOADER tep_plugin_unloader
-#define TEP_PLUGIN_OPTIONS tep_plugin_options
 #define _MAKE_STR(x)	#x
 #define MAKE_STR(x)	_MAKE_STR(x)
 #define TEP_PLUGIN_LOADER_NAME MAKE_STR(TEP_PLUGIN_LOADER)
 #define TEP_PLUGIN_UNLOADER_NAME MAKE_STR(TEP_PLUGIN_UNLOADER)
-#define TEP_PLUGIN_OPTIONS_NAME MAKE_STR(TEP_PLUGIN_OPTIONS)
 
 enum tep_format_flags {
 	TEP_FIELD_IS_ARRAY	= 1,
lib/traceevent/event-plugin.c +0 -11
index bbe87d4..8c48ccf 100644
@@ -427,7 +427,6 @@ load_plugin(struct tep_handle *tep, const char *path,
 	    const char *file, void *data)
 {
 	struct tep_plugin_list **plugin_list = data;
-	struct tep_plugin_option *options;
 	tep_plugin_load_func func;
 	struct tep_plugin_list *list;
 	char *plugin;
@@ -447,16 +446,6 @@ load_plugin(struct tep_handle *tep, const char *path,
 		goto out_free;
 	}
 
-	options = dlsym(handle, TEP_PLUGIN_OPTIONS_NAME);
-	if (options) {
-		while (options->name) {
-			ret = update_option(file, options);
-			if (ret < 0)
-				goto out_free;
-			options++;
-		}
-	}
-
 	func = dlsym(handle, TEP_PLUGIN_LOADER_NAME);
 	if (!func) {
 		warning("could not find func '%s' in plugin '%s'\n%s\n",
Signature · 1 line
2.24.1
#3 lore raw

PATCH 3/7 trace-cmd,libtraceevent: Check for plugin options duplication

In reply to Tzvetomir Stoyanov (VMware)

When loading new plugin options, check is an option with the same name and plugin is already registered. The API
tep_plugin_add_options()
is modified to return errors is these cases:
- The "plugin" field in the option's description is not set, return -EINVAL
- An option with the same name and plugin is already registered return -EBUSY

---
 lib/traceevent/event-plugin.c | 50 +++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 20 deletions(-)
lib/traceevent/event-plugin.c +30 -20
index 8c48ccf..e53b09c 100644
@@ -202,6 +202,26 @@ update_option(const char *file, struct tep_plugin_option *option)
 	return ret;
 }
 
+static struct tep_plugin_option *
+find_registered_option(const char *plugin, const char *option)
+{
+	struct registered_plugin_options *reg;
+	struct tep_plugin_option *op;
+
+	for (reg = registered_options; reg; reg = reg->next) {
+		for (op = reg->options; op->name; op++) {
+			if (plugin && strcmp(plugin, op->plugin) != 0)
+				continue;
+			if (strcmp(option, op->name) != 0)
+				continue;
+
+			return op;
+		}
+	}
+
+	return NULL;
+}
+
 /**
  * tep_plugin_add_options - Add a set of options by a plugin
  * @name: The name of the plugin adding the options
@@ -213,6 +233,16 @@ int tep_plugin_add_options(const char *name,
 			   struct tep_plugin_option *options)
 {
 	struct registered_plugin_options *reg;
+	struct tep_plugin_option *option;
+
+	option = options;
+	while (option && option->name) {
+		if (!option->plugin)
+			return -EINVAL;
+		if (find_registered_option(name, option->name))
+			return -EBUSY;
+		option++;
+	}
 
 	reg = malloc(sizeof(*reg));
 	if (!reg)
@@ -262,26 +292,6 @@ static void parse_option_name(char **option, char **plugin)
 	}
 }
 
-static struct tep_plugin_option *
-find_registered_option(const char *plugin, const char *option)
-{
-	struct registered_plugin_options *reg;
-	struct tep_plugin_option *op;
-
-	for (reg = registered_options; reg; reg = reg->next) {
-		for (op = reg->options; op->name; op++) {
-			if (plugin && strcmp(plugin, op->plugin) != 0)
-				continue;
-			if (strcmp(option, op->name) != 0)
-				continue;
-
-			return op;
-		}
-	}
-
-	return NULL;
-}
-
 static int process_option(const char *plugin, const char *option, const char *val)
 {
 	struct tep_plugin_option *op;
Signature · 1 line
2.24.1
#4 lore raw

PATCH 4/7 trace-cmd,libtraceevent: Check for plugin duplication

In reply to Tzvetomir Stoyanov (VMware)

When loading new plugin, check if plugin with the same file name is already registered. If there is such plugin, unload it and then load the new one.
In case of duplication, the last one wins.

---
 lib/traceevent/event-plugin.c | 50 +++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 5 deletions(-)
lib/traceevent/event-plugin.c +45 -5
index e53b09c..a33cf09 100644
@@ -432,16 +432,60 @@ void tep_print_plugins(struct trace_seq *s,
 	}
 }
 
+
+static void unload_plugin(void *handle, struct tep_handle *tep)
+{
+	tep_plugin_unload_func func;
+
+	if (!handle)
+		return;
+	func = dlsym(handle, TEP_PLUGIN_UNLOADER_NAME);
+	if (func)
+		func(tep);
+	dlclose(handle);
+}
+
+static struct tep_plugin_list *
+detach_plugin(const char *name, struct tep_plugin_list **plist)
+{
+	struct tep_plugin_list *plugins = *plist;
+	struct tep_plugin_list *prev = NULL;
+	char *file;
+
+	while (plugins) {
+		file = strrchr(plugins->name, '/');
+		if (file)
+			file++;
+		else
+			file = plugins->name;
+		if (!strcmp(file, name)) {
+			if (prev)
+				prev->next = plugins->next;
+			else
+				*plist = plugins->next;
+			return plugins;
+		}
+		prev = plugins;
+		plugins = plugins->next;
+	}
+
+	return NULL;
+}
+
 static void
 load_plugin(struct tep_handle *tep, const char *path,
 	    const char *file, void *data)
 {
 	struct tep_plugin_list **plugin_list = data;
+	struct tep_plugin_list *old;
 	tep_plugin_load_func func;
 	struct tep_plugin_list *list;
 	char *plugin;
 	void *handle;
 	int ret;
+	old = detach_plugin(file, plugin_list);
+	if (old)
+		unload_plugin(old->handle, tep);
 
 	ret = asprintf(&plugin, "%s/%s", path, file);
 	if (ret < 0) {
@@ -652,16 +696,12 @@ void tep_free_plugin_paths(struct tep_handle *tep)
 void
 tep_unload_plugins(struct tep_plugin_list *plugin_list, struct tep_handle *tep)
 {
-	tep_plugin_unload_func func;
 	struct tep_plugin_list *list;
 
 	while (plugin_list) {
 		list = plugin_list;
+		unload_plugin(list->handle, tep);
 		plugin_list = list->next;
-		func = dlsym(list->handle, TEP_PLUGIN_UNLOADER_NAME);
-		if (func)
-			func(tep);
-		dlclose(list->handle);
 		free(list->name);
 		free(list);
 	}
Signature · 1 line
2.24.1
#5 lore raw

PATCH 5/7 trace-cmd,libtraceevent: Remove API for plugin options print

In reply to Tzvetomir Stoyanov (VMware)

The functionality for printing registered plugin options is moved from libtraceevent to the application. A more generic walk API is introduced.

Removed APIs:
tep_plugin_list_options()
tep_plugin_free_options_list()
tep_plugin_print_options()

Added API
tep_plugin_walk_options()

---
 include/traceevent/event-parse.h |  9 ++-
 lib/traceevent/event-plugin.c    | 98 ++++----------------------------
 tracecmd/trace-list.c            | 43 +++++++++++++-
 3 files changed, 58 insertions(+), 92 deletions(-)
include/traceevent/event-parse.h +4 -5
index cb1b46e..3b4f3a5 100644
@@ -346,8 +346,6 @@ enum tep_errno {
 
 struct tep_plugin_list;
 
-#define INVALID_PLUGIN_LIST_OPTION	((char **)((unsigned long)-1))
-
 enum tep_plugin_load_priority {
 	TEP_PLUGIN_FIRST,
 	TEP_PLUGIN_LAST,
@@ -364,13 +362,14 @@ void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix,
 					       const char *name,
 					       void *data),
 			   void *data);
-char **tep_plugin_list_options(void);
-void tep_plugin_free_options_list(char **list);
 int tep_plugin_add_options(const char *name,
 			   struct tep_plugin_option *options);
 int tep_plugin_add_option(const char *name, const char *val);
 void tep_plugin_remove_options(struct tep_plugin_option *options);
-void tep_plugin_print_options(struct trace_seq *s);
+void tep_plugin_walk_options(int (*callback)(struct tep_plugin_option *op,
+					     void *context),
+			     void *context);
+
 void tep_print_plugins(struct trace_seq *s,
 			const char *prefix, const char *suffix,
 			const struct tep_plugin_list *list);
lib/traceevent/event-plugin.c +12 -86

123 lines not on this page · raw message

tracecmd/trace-list.c +42 -1

55 lines not on this page · raw message

Signature · 1 line
2.24.1
#6 lore raw

PATCH 6/7 trace-cmd,libtraceevent: Remove API for plugin print

In reply to Tzvetomir Stoyanov (VMware)

The functionality for printing registered plugins
is moved from libtraceevent to the application.
A more generic walk API is introduced.

Removed
tep_print_plugins()

Added
tep_walk_plugins()

---
 include/traceevent/event-parse.h |  8 ++++----
 lib/traceevent/event-plugin.c    | 23 +++++++++++------------
 tracecmd/trace-list.c            | 12 +++++++++---
 3 files changed, 24 insertions(+), 19 deletions(-)
include/traceevent/event-parse.h +4 -4
index 3b4f3a5..a64482d 100644
@@ -362,6 +362,10 @@ void tep_load_plugins_hook(struct tep_handle *tep, const char *suffix,
 					       const char *name,
 					       void *data),
 			   void *data);
+void tep_walk_plugins(const struct tep_plugin_list *list,
+		      int (*callback)(char *plugin_file, void *context),
+		      void *context);
+
 int tep_plugin_add_options(const char *name,
 			   struct tep_plugin_option *options);
 int tep_plugin_add_option(const char *name, const char *val);
@@ -370,10 +374,6 @@ void tep_plugin_walk_options(int (*callback)(struct tep_plugin_option *op,
 					     void *context),
 			     void *context);
 
-void tep_print_plugins(struct trace_seq *s,
-			const char *prefix, const char *suffix,
-			const struct tep_plugin_list *list);
-
 /* tep_handle */
 typedef char *(tep_func_resolver_t)(void *priv,
 				    unsigned long long *addrp, char **modp);
lib/traceevent/event-plugin.c +11 -12
index 191b27b..1ea02e6 100644
@@ -338,22 +338,21 @@ void tep_plugin_walk_options(int (*callback)(struct tep_plugin_option *op,
 }
 
 /**
- * tep_print_plugins - print out the list of plugins loaded
- * @s: the trace_seq descripter to write to
- * @prefix: The prefix string to add before listing the option name
- * @suffix: The suffix string ot append after the option name
- * @list: The list of plugins (usually returned by tep_load_plugins()
+ * tep_walk_plugins - walk through all plugins from the list
+ * @list: plugin list, returned by tep_load_plugins()
+ * @callback: a user function, called on each plugin from the list
+ * @context: user data, passed to @callback function
  *
- * Writes to the trace_seq @s the list of plugins (files) that is
- * returned by tep_load_plugins(). Use @prefix and @suffix for formating:
- * @prefix = "  ", @suffix = "\n".
+ * If the @callback returns non zero, the iteration stops.
  */
-void tep_print_plugins(struct trace_seq *s,
-		       const char *prefix, const char *suffix,
-		       const struct tep_plugin_list *list)
+void tep_walk_plugins(const struct tep_plugin_list *list,
+		      int (*callback)(char *plugin_file, void *context),
+		      void *context)
 {
+	if (!list || !callback)
+		return;
 	while (list) {
-		trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix);
+		callback(list->name, context);
 		list = list->next;
 	}
 }
tracecmd/trace-list.c +9 -3
index 496a83b..f7bef45 100644
@@ -373,6 +373,14 @@ void trace_option(int argc, char **argv)
 	show_plugin_options();
 }
 
+static int plugins_walk(char *plugin_file, void *context)
+{
+	struct trace_seq *s = (struct trace_seq *)context;
+
+	if (plugin_file)
+		trace_seq_printf(s, "  %s\n", plugin_file);
+	return 0;
+}
 
 static void show_plugins(void)
 {
@@ -387,14 +395,12 @@ static void show_plugins(void)
 	trace_seq_init(&s);
 
 	list = trace_load_plugins(pevent);
-	tep_print_plugins(&s, "  ", "\n", list);
-
+	tep_walk_plugins(list, plugins_walk, &s);
 	trace_seq_do_printf(&s);
 	tep_unload_plugins(list, pevent);
 	tep_free(pevent);
 }
 
-
 void trace_list(int argc, char **argv)
 {
 	int events = 0;
Signature · 1 line
2.24.1
#7 lore raw

PATCH 7/7 trace-cmd, kernelshark, libtraceevent: Changed tep_plugin_add_option() API

In reply to Tzvetomir Stoyanov (VMware)

The API
tep_plugin_add_option()
is renamed to
tep_plugin_set_option()

The new name describes more closely the purpose of the API - it lets us update the option's value. The logic of the API is slightly changed: If no plugin is given, all options that match the option name will be updated.

---
 include/traceevent/event-parse.h |  2 +-
 kernel-shark/src/libkshark.c     |  4 ++--
 lib/traceevent/event-plugin.c    | 30 +++++++++++++++++++++++-------
 tracecmd/trace-read.c            |  2 +-
 4 files changed, 27 insertions(+), 11 deletions(-)
include/traceevent/event-parse.h +1 -1
index a64482d..538dd94 100644
@@ -368,7 +368,7 @@ void tep_walk_plugins(const struct tep_plugin_list *list,
 
 int tep_plugin_add_options(const char *name,
 			   struct tep_plugin_option *options);
-int tep_plugin_add_option(const char *name, const char *val);
+int tep_plugin_set_option(const char *name, const char *val);
 void tep_plugin_remove_options(struct tep_plugin_option *options);
 void tep_plugin_walk_options(int (*callback)(struct tep_plugin_option *op,
 					     void *context),
kernel-shark/src/libkshark.c +2 -2
index a361578..34fa007 100644
@@ -160,8 +160,8 @@ bool kshark_open(struct kshark_context *kshark_ctx, const char *file)
 	 * Turn off function trace indent and turn on show parent
 	 * if possible.
 	 */
-	tep_plugin_add_option("ftrace:parent", "1");
-	tep_plugin_add_option("ftrace:indent", "0");
+	tep_plugin_set_option("ftrace:parent", "1");
+	tep_plugin_set_option("ftrace:indent", "0");
 
 	return true;
 }
lib/traceevent/event-plugin.c +23 -7
index 1ea02e6..4af85de 100644
@@ -219,7 +219,10 @@ static void parse_option_name(char **option, char **plugin)
 	*plugin = NULL;
 
 	if ((p = strstr(*option, ":"))) {
-		*plugin = *option;
+		if (**option == ':')
+			*plugin = NULL;
+		else
+			*plugin = *option;
 		*p = '\0';
 		*option = strdup(p + 1);
 		if (!*option)
@@ -229,25 +232,38 @@ static void parse_option_name(char **option, char **plugin)
 
 static int process_option(const char *plugin, const char *option, const char *val)
 {
+	struct registered_plugin_options *reg;
 	struct tep_plugin_option *op;
+	int ret;
 
-	op = find_registered_option(plugin, option);
-	if (!op)
-		return 0;
+	for (reg = registered_options; reg; reg = reg->next) {
+		for (op = reg->options; op->name; op++) {
+			if (plugin && strcmp(plugin, op->plugin) != 0)
+				continue;
+			if (strcmp(option, op->name) != 0)
+				continue;
 
-	return update_option_value(op, val);
+			ret = update_option_value(op, val);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
 }
 
 /**
- * tep_plugin_add_option - add an option/val pair to set plugin options
+ * tep_plugin_set_option - update the value of plugin option
  * @name: The name of the option (format: <plugin>:<option> or just <option>)
  * @val: (optiona) the value for the option
  *
  * Modify a plugin option. If @val is given than the value of the option
  * is set (note, some options just take a boolean, so @val must be either
  * "1" or "0" or "true" or "false").
+ * If there is no <plugin> in the @name, all options with name <option> will
+ * be updated.
  */
-int tep_plugin_add_option(const char *name, const char *val)
+int tep_plugin_set_option(const char *name, const char *val)
 {
 	struct trace_plugin_options *op;
 	char *option_str;
tracecmd/trace-read.c +1 -1
index c0d640d..7b41d72 100644
@@ -1381,7 +1381,7 @@ static void process_plugin_option(char *option)
 		*p = '\0';
 		val = p+1;
 	}
-	tep_plugin_add_option(name, val);
+	tep_plugin_set_option(name, val);
 }
 
 static void set_event_flags(struct tep_handle *pevent, struct event_str *list,
Signature · 1 line
2.24.1