@@ -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),
@@ -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;
}
@@ -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;
@@ -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,
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. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- 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(-)