tracing/probe: Add trace_probe init and free functions
Add common trace_probe init and cleanup function in trace_probe.c, and use it from trace_kprobe.c and trace_uprobe.c Link: http://lkml.kernel.org/r/155931582664.28323.5934870189034740822.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:

committed by
Steven Rostedt (VMware)

parent
b4d4b96be8
commit
455b289973
@@ -884,3 +884,39 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void trace_probe_cleanup(struct trace_probe *tp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tp->nr_args; i++)
|
||||
traceprobe_free_probe_arg(&tp->args[i]);
|
||||
|
||||
kfree(tp->call.class->system);
|
||||
kfree(tp->call.name);
|
||||
kfree(tp->call.print_fmt);
|
||||
}
|
||||
|
||||
int trace_probe_init(struct trace_probe *tp, const char *event,
|
||||
const char *group)
|
||||
{
|
||||
if (!event || !group)
|
||||
return -EINVAL;
|
||||
|
||||
tp->call.class = &tp->class;
|
||||
tp->call.name = kstrdup(event, GFP_KERNEL);
|
||||
if (!tp->call.name)
|
||||
return -ENOMEM;
|
||||
|
||||
tp->class.system = kstrdup(group, GFP_KERNEL);
|
||||
if (!tp->class.system) {
|
||||
kfree(tp->call.name);
|
||||
tp->call.name = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
INIT_LIST_HEAD(&tp->files);
|
||||
INIT_LIST_HEAD(&tp->class.fields);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user