aboutsummaryrefslogtreecommitdiffstats
path: root/trace-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-util.c')
-rw-r--r--trace-util.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/trace-util.c b/trace-util.c
index 04cb087..de59a3f 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -61,6 +61,18 @@ struct plugin_list {
61 void *handle; 61 void *handle;
62}; 62};
63 63
64static void update_option(const char *file, struct plugin_option *option);
65
66void trace_util_ftrace_options(void)
67{
68 struct plugin_option *options = trace_ftrace_options;
69
70 while (options->name) {
71 update_option("ftrace", options);
72 options++;
73 }
74}
75
64void trace_util_add_option(const char *name, const char *val) 76void trace_util_add_option(const char *name, const char *val)
65{ 77{
66 struct trace_plugin_options *option; 78 struct trace_plugin_options *option;
@@ -909,12 +921,28 @@ struct plugin_option_read {
909 struct plugin_option *options; 921 struct plugin_option *options;
910}; 922};
911 923
924static void append_option(struct plugin_option_read *options,
925 struct plugin_option *option,
926 const char *alias, void *handle)
927{
928 struct plugin_option *op;
929
930 while (option->name) {
931 op = malloc_or_die(sizeof(*op));
932 *op = *option;
933 op->next = options->options;
934 options->options = op;
935 op->file = strdup(alias);
936 op->handle = handle;
937 option++;
938 }
939}
940
912static void read_options(struct pevent *pevent, const char *path, 941static void read_options(struct pevent *pevent, const char *path,
913 const char *file, void *data) 942 const char *file, void *data)
914{ 943{
915 struct plugin_option_read *option = data; 944 struct plugin_option_read *options = data;
916 struct plugin_option *options; 945 struct plugin_option *option;
917 struct plugin_option *op;
918 const char *alias; 946 const char *alias;
919 int unload = 0; 947 int unload = 0;
920 char *plugin; 948 char *plugin;
@@ -937,21 +965,13 @@ static void read_options(struct pevent *pevent, const char *path,
937 if (!alias) 965 if (!alias)
938 alias = file; 966 alias = file;
939 967
940 options = dlsym(handle, PEVENT_PLUGIN_OPTIONS_NAME); 968 option = dlsym(handle, PEVENT_PLUGIN_OPTIONS_NAME);
941 if (!options) { 969 if (!option) {
942 unload = 1; 970 unload = 1;
943 goto out_unload; 971 goto out_unload;
944 } 972 }
945 973
946 while (options->name) { 974 append_option(options, option, alias, handle);
947 op = malloc_or_die(sizeof(*op));
948 *op = *options;
949 op->next = option->options;
950 option->options = op;
951 op->file = strdup(alias);
952 op->handle = handle;
953 options++;
954 }
955 975
956 out_unload: 976 out_unload:
957 if (unload) 977 if (unload)
@@ -966,6 +986,8 @@ struct plugin_option *trace_util_read_plugin_options(void)
966 .options = NULL, 986 .options = NULL,
967 }; 987 };
968 988
989 append_option(&option, trace_ftrace_options, "ftrace", NULL);
990
969 trace_util_load_plugins(NULL, ".so", read_options, &option); 991 trace_util_load_plugins(NULL, ".so", read_options, &option);
970 992
971 return option.options; 993 return option.options;