diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-03-23 13:48:11 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-03-23 13:48:11 -0400 |
commit | bd8c4d5b44f4cef5bdad11ceba1c01b2a47d23ab (patch) | |
tree | 582e57117c3d2af5d463ca7dd7ed9732f4fc8278 | |
parent | 5990a157bac23276ce9b5cae38276a545ff76486 (diff) |
parse-events: Let function handlers be overridden
Now that plugins are in both system and user directories, the user directory
is processed after the system directory. This makes it highly likely that
a function handler may be added again. Instead of warning about it and failing
let the new function handler override the previous one.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | parse-events.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/parse-events.c b/parse-events.c index 3c2e9a0..3eb6cb1 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -79,6 +79,8 @@ static unsigned long long | |||
79 | process_defined_func(struct trace_seq *s, void *data, int size, | 79 | process_defined_func(struct trace_seq *s, void *data, int size, |
80 | struct event_format *event, struct print_arg *arg); | 80 | struct event_format *event, struct print_arg *arg); |
81 | 81 | ||
82 | static void free_func_handle(struct pevent_function_handler *func); | ||
83 | |||
82 | /** | 84 | /** |
83 | * pevent_buffer_init - init buffer for parsing | 85 | * pevent_buffer_init - init buffer for parsing |
84 | * @buf: buffer to parse | 86 | * @buf: buffer to parse |
@@ -2254,6 +2256,22 @@ find_func_handler(struct pevent *pevent, char *func_name) | |||
2254 | return func; | 2256 | return func; |
2255 | } | 2257 | } |
2256 | 2258 | ||
2259 | static void remove_func_handler(struct pevent *pevent, char *func_name) | ||
2260 | { | ||
2261 | struct pevent_function_handler *func; | ||
2262 | struct pevent_function_handler **next; | ||
2263 | |||
2264 | next = &pevent->func_handlers; | ||
2265 | while ((func = *next)) { | ||
2266 | if (strcmp(func->name, func_name) == 0) { | ||
2267 | *next = func->next; | ||
2268 | free_func_handle(func); | ||
2269 | break; | ||
2270 | } | ||
2271 | next = &func->next; | ||
2272 | } | ||
2273 | } | ||
2274 | |||
2257 | static enum event_type | 2275 | static enum event_type |
2258 | process_func_handler(struct event_format *event, struct pevent_function_handler *func, | 2276 | process_func_handler(struct event_format *event, struct pevent_function_handler *func, |
2259 | struct print_arg *arg, char **tok) | 2277 | struct print_arg *arg, char **tok) |
@@ -4246,8 +4264,13 @@ int pevent_register_print_function(struct pevent *pevent, | |||
4246 | 4264 | ||
4247 | func_handle = find_func_handler(pevent, name); | 4265 | func_handle = find_func_handler(pevent, name); |
4248 | if (func_handle) { | 4266 | if (func_handle) { |
4249 | warning("function helper '%s' already defined", name); | 4267 | /* |
4250 | return -1; | 4268 | * This is most like caused by the users own |
4269 | * plugins updating the function. This overrides the | ||
4270 | * system defaults. | ||
4271 | */ | ||
4272 | pr_stat("override of function helper '%s'", name); | ||
4273 | remove_func_handler(pevent, name); | ||
4251 | } | 4274 | } |
4252 | 4275 | ||
4253 | func_handle = malloc_or_die(sizeof(*func_handle)); | 4276 | func_handle = malloc_or_die(sizeof(*func_handle)); |