2 * uprobes-based tracing events
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Copyright (C) IBM Corporation, 2010-2012
18 * Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
21 #include <linux/module.h>
22 #include <linux/uaccess.h>
23 #include <linux/uprobes.h>
24 #include <linux/namei.h>
25 #include <linux/string.h>
27 #include "trace_probe.h"
29 #define UPROBE_EVENT_SYSTEM "uprobes"
31 struct uprobe_trace_entry_head {
32 struct trace_entry ent;
33 unsigned long vaddr[];
36 #define SIZEOF_TRACE_ENTRY(is_return) \
37 (sizeof(struct uprobe_trace_entry_head) + \
38 sizeof(unsigned long) * (is_return ? 2 : 1))
40 #define DATAOF_TRACE_ENTRY(entry, is_return) \
41 ((void*)(entry) + SIZEOF_TRACE_ENTRY(is_return))
43 struct trace_uprobe_filter {
46 struct list_head perf_events;
50 * uprobe event core functions
53 struct list_head list;
54 struct ftrace_event_class class;
55 struct ftrace_event_call call;
56 struct trace_uprobe_filter filter;
57 struct uprobe_consumer consumer;
62 unsigned int flags; /* For TP_FLAG_* */
63 ssize_t size; /* trace entry size */
65 struct probe_arg args[];
68 #define SIZEOF_TRACE_UPROBE(n) \
69 (offsetof(struct trace_uprobe, args) + \
70 (sizeof(struct probe_arg) * (n)))
72 static int register_uprobe_event(struct trace_uprobe *tu);
73 static void unregister_uprobe_event(struct trace_uprobe *tu);
75 static DEFINE_MUTEX(uprobe_lock);
76 static LIST_HEAD(uprobe_list);
78 static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs);
79 static int uretprobe_dispatcher(struct uprobe_consumer *con,
80 unsigned long func, struct pt_regs *regs);
82 static inline void init_trace_uprobe_filter(struct trace_uprobe_filter *filter)
84 rwlock_init(&filter->rwlock);
85 filter->nr_systemwide = 0;
86 INIT_LIST_HEAD(&filter->perf_events);
89 static inline bool uprobe_filter_is_empty(struct trace_uprobe_filter *filter)
91 return !filter->nr_systemwide && list_empty(&filter->perf_events);
94 static inline bool is_ret_probe(struct trace_uprobe *tu)
96 return tu->consumer.ret_handler != NULL;
100 * Allocate new trace_uprobe and initialize it (including uprobes).
102 static struct trace_uprobe *
103 alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
105 struct trace_uprobe *tu;
107 if (!event || !is_good_name(event))
108 return ERR_PTR(-EINVAL);
110 if (!group || !is_good_name(group))
111 return ERR_PTR(-EINVAL);
113 tu = kzalloc(SIZEOF_TRACE_UPROBE(nargs), GFP_KERNEL);
115 return ERR_PTR(-ENOMEM);
117 tu->call.class = &tu->class;
118 tu->call.name = kstrdup(event, GFP_KERNEL);
122 tu->class.system = kstrdup(group, GFP_KERNEL);
123 if (!tu->class.system)
126 INIT_LIST_HEAD(&tu->list);
127 tu->consumer.handler = uprobe_dispatcher;
129 tu->consumer.ret_handler = uretprobe_dispatcher;
130 init_trace_uprobe_filter(&tu->filter);
134 kfree(tu->call.name);
137 return ERR_PTR(-ENOMEM);
140 static void free_trace_uprobe(struct trace_uprobe *tu)
144 for (i = 0; i < tu->nr_args; i++)
145 traceprobe_free_probe_arg(&tu->args[i]);
148 kfree(tu->call.class->system);
149 kfree(tu->call.name);
154 static struct trace_uprobe *find_probe_event(const char *event, const char *group)
156 struct trace_uprobe *tu;
158 list_for_each_entry(tu, &uprobe_list, list)
159 if (strcmp(tu->call.name, event) == 0 &&
160 strcmp(tu->call.class->system, group) == 0)
166 /* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
167 static void unregister_trace_uprobe(struct trace_uprobe *tu)
170 unregister_uprobe_event(tu);
171 free_trace_uprobe(tu);
174 /* Register a trace_uprobe and probe_event */
175 static int register_trace_uprobe(struct trace_uprobe *tu)
177 struct trace_uprobe *old_tp;
180 mutex_lock(&uprobe_lock);
182 /* register as an event */
183 old_tp = find_probe_event(tu->call.name, tu->call.class->system);
185 /* delete old event */
186 unregister_trace_uprobe(old_tp);
188 ret = register_uprobe_event(tu);
190 pr_warning("Failed to register probe event(%d)\n", ret);
194 list_add_tail(&tu->list, &uprobe_list);
197 mutex_unlock(&uprobe_lock);
204 * - Add uprobe: p|r[:[GRP/]EVENT] PATH:SYMBOL [FETCHARGS]
206 * - Remove uprobe: -:[GRP/]EVENT
208 static int create_trace_uprobe(int argc, char **argv)
210 struct trace_uprobe *tu;
212 char *arg, *event, *group, *filename;
213 char buf[MAX_EVENT_NAME_LEN];
215 unsigned long offset;
216 bool is_delete, is_return;
226 /* argc must be >= 1 */
227 if (argv[0][0] == '-')
229 else if (argv[0][0] == 'r')
231 else if (argv[0][0] != 'p') {
232 pr_info("Probe definition must be started with 'p', 'r' or '-'.\n");
236 if (argv[0][1] == ':') {
238 arg = strchr(event, '/');
245 if (strlen(group) == 0) {
246 pr_info("Group name is not specified\n");
250 if (strlen(event) == 0) {
251 pr_info("Event name is not specified\n");
256 group = UPROBE_EVENT_SYSTEM;
260 pr_info("Delete command needs an event name.\n");
263 mutex_lock(&uprobe_lock);
264 tu = find_probe_event(event, group);
267 mutex_unlock(&uprobe_lock);
268 pr_info("Event %s/%s doesn't exist.\n", group, event);
271 /* delete an event */
272 unregister_trace_uprobe(tu);
273 mutex_unlock(&uprobe_lock);
278 pr_info("Probe point is not specified.\n");
281 if (isdigit(argv[1][0])) {
282 pr_info("probe point must be have a filename.\n");
285 arg = strchr(argv[1], ':');
287 goto fail_address_parse;
291 ret = kern_path(filename, LOOKUP_FOLLOW, &path);
293 goto fail_address_parse;
295 inode = igrab(path.dentry->d_inode);
298 if (!inode || !S_ISREG(inode->i_mode)) {
300 goto fail_address_parse;
303 ret = kstrtoul(arg, 0, &offset);
305 goto fail_address_parse;
315 tail = kstrdup(kbasename(filename), GFP_KERNEL);
318 goto fail_address_parse;
321 ptr = strpbrk(tail, ".-_");
325 snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_0x%lx", 'p', tail, offset);
330 tu = alloc_trace_uprobe(group, event, argc, is_return);
332 pr_info("Failed to allocate trace_uprobe.(%d)\n", (int)PTR_ERR(tu));
334 goto fail_address_parse;
338 tu->filename = kstrdup(filename, GFP_KERNEL);
341 pr_info("Failed to allocate filename.\n");
346 /* parse arguments */
348 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
349 /* Increment count for freeing args in error case */
352 /* Parse argument name */
353 arg = strchr(argv[i], '=');
356 tu->args[i].name = kstrdup(argv[i], GFP_KERNEL);
359 /* If argument name is omitted, set "argN" */
360 snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1);
361 tu->args[i].name = kstrdup(buf, GFP_KERNEL);
364 if (!tu->args[i].name) {
365 pr_info("Failed to allocate argument[%d] name.\n", i);
370 if (!is_good_name(tu->args[i].name)) {
371 pr_info("Invalid argument[%d] name: %s\n", i, tu->args[i].name);
376 if (traceprobe_conflict_field_name(tu->args[i].name, tu->args, i)) {
377 pr_info("Argument[%d] name '%s' conflicts with "
378 "another field.\n", i, argv[i]);
383 /* Parse fetch argument */
384 ret = traceprobe_parse_probe_arg(arg, &tu->size, &tu->args[i], false, false);
386 pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
391 ret = register_trace_uprobe(tu);
397 free_trace_uprobe(tu);
404 pr_info("Failed to parse address or file.\n");
409 static void cleanup_all_probes(void)
411 struct trace_uprobe *tu;
413 mutex_lock(&uprobe_lock);
414 while (!list_empty(&uprobe_list)) {
415 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
416 unregister_trace_uprobe(tu);
418 mutex_unlock(&uprobe_lock);
421 /* Probes listing interfaces */
422 static void *probes_seq_start(struct seq_file *m, loff_t *pos)
424 mutex_lock(&uprobe_lock);
425 return seq_list_start(&uprobe_list, *pos);
428 static void *probes_seq_next(struct seq_file *m, void *v, loff_t *pos)
430 return seq_list_next(v, &uprobe_list, pos);
433 static void probes_seq_stop(struct seq_file *m, void *v)
435 mutex_unlock(&uprobe_lock);
438 static int probes_seq_show(struct seq_file *m, void *v)
440 struct trace_uprobe *tu = v;
441 char c = is_ret_probe(tu) ? 'r' : 'p';
444 seq_printf(m, "%c:%s/%s", c, tu->call.class->system, tu->call.name);
445 seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset);
447 for (i = 0; i < tu->nr_args; i++)
448 seq_printf(m, " %s=%s", tu->args[i].name, tu->args[i].comm);
454 static const struct seq_operations probes_seq_op = {
455 .start = probes_seq_start,
456 .next = probes_seq_next,
457 .stop = probes_seq_stop,
458 .show = probes_seq_show
461 static int probes_open(struct inode *inode, struct file *file)
463 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC))
464 cleanup_all_probes();
466 return seq_open(file, &probes_seq_op);
469 static ssize_t probes_write(struct file *file, const char __user *buffer,
470 size_t count, loff_t *ppos)
472 return traceprobe_probes_write(file, buffer, count, ppos, create_trace_uprobe);
475 static const struct file_operations uprobe_events_ops = {
476 .owner = THIS_MODULE,
480 .release = seq_release,
481 .write = probes_write,
484 /* Probes profiling interfaces */
485 static int probes_profile_seq_show(struct seq_file *m, void *v)
487 struct trace_uprobe *tu = v;
489 seq_printf(m, " %s %-44s %15lu\n", tu->filename, tu->call.name, tu->nhit);
493 static const struct seq_operations profile_seq_op = {
494 .start = probes_seq_start,
495 .next = probes_seq_next,
496 .stop = probes_seq_stop,
497 .show = probes_profile_seq_show
500 static int profile_open(struct inode *inode, struct file *file)
502 return seq_open(file, &profile_seq_op);
505 static const struct file_operations uprobe_profile_ops = {
506 .owner = THIS_MODULE,
507 .open = profile_open,
510 .release = seq_release,
513 static void uprobe_trace_print(struct trace_uprobe *tu,
514 unsigned long func, struct pt_regs *regs)
516 struct uprobe_trace_entry_head *entry;
517 struct ring_buffer_event *event;
518 struct ring_buffer *buffer;
521 struct ftrace_event_call *call = &tu->call;
523 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
524 event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
525 size + tu->size, 0, 0);
529 entry = ring_buffer_event_data(event);
530 if (is_ret_probe(tu)) {
531 entry->vaddr[0] = func;
532 entry->vaddr[1] = instruction_pointer(regs);
533 data = DATAOF_TRACE_ENTRY(entry, true);
535 entry->vaddr[0] = instruction_pointer(regs);
536 data = DATAOF_TRACE_ENTRY(entry, false);
539 for (i = 0; i < tu->nr_args; i++)
540 call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
542 if (!filter_current_check_discard(buffer, call, entry, event))
543 trace_buffer_unlock_commit(buffer, event, 0, 0);
547 static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
549 if (!is_ret_probe(tu))
550 uprobe_trace_print(tu, 0, regs);
554 static void uretprobe_trace_func(struct trace_uprobe *tu, unsigned long func,
555 struct pt_regs *regs)
557 uprobe_trace_print(tu, func, regs);
560 /* Event entry printers */
561 static enum print_line_t
562 print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *event)
564 struct uprobe_trace_entry_head *entry;
565 struct trace_seq *s = &iter->seq;
566 struct trace_uprobe *tu;
570 entry = (struct uprobe_trace_entry_head *)iter->ent;
571 tu = container_of(event, struct trace_uprobe, call.event);
573 if (is_ret_probe(tu)) {
574 if (!trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", tu->call.name,
575 entry->vaddr[1], entry->vaddr[0]))
577 data = DATAOF_TRACE_ENTRY(entry, true);
579 if (!trace_seq_printf(s, "%s: (0x%lx)", tu->call.name,
582 data = DATAOF_TRACE_ENTRY(entry, false);
585 for (i = 0; i < tu->nr_args; i++) {
586 if (!tu->args[i].type->print(s, tu->args[i].name,
587 data + tu->args[i].offset, entry))
591 if (trace_seq_puts(s, "\n"))
592 return TRACE_TYPE_HANDLED;
595 return TRACE_TYPE_PARTIAL_LINE;
598 static inline bool is_trace_uprobe_enabled(struct trace_uprobe *tu)
600 return tu->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE);
603 typedef bool (*filter_func_t)(struct uprobe_consumer *self,
604 enum uprobe_filter_ctx ctx,
605 struct mm_struct *mm);
608 probe_event_enable(struct trace_uprobe *tu, int flag, filter_func_t filter)
612 if (is_trace_uprobe_enabled(tu))
615 WARN_ON(!uprobe_filter_is_empty(&tu->filter));
618 tu->consumer.filter = filter;
619 ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
626 static void probe_event_disable(struct trace_uprobe *tu, int flag)
628 if (!is_trace_uprobe_enabled(tu))
631 WARN_ON(!uprobe_filter_is_empty(&tu->filter));
633 uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
637 static int uprobe_event_define_fields(struct ftrace_event_call *event_call)
640 struct uprobe_trace_entry_head field;
641 struct trace_uprobe *tu = event_call->data;
643 if (is_ret_probe(tu)) {
644 DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_FUNC, 0);
645 DEFINE_FIELD(unsigned long, vaddr[1], FIELD_STRING_RETIP, 0);
646 size = SIZEOF_TRACE_ENTRY(true);
648 DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_IP, 0);
649 size = SIZEOF_TRACE_ENTRY(false);
651 /* Set argument names as fields */
652 for (i = 0; i < tu->nr_args; i++) {
653 ret = trace_define_field(event_call, tu->args[i].type->fmttype,
655 size + tu->args[i].offset,
656 tu->args[i].type->size,
657 tu->args[i].type->is_signed,
666 #define LEN_OR_ZERO (len ? len - pos : 0)
667 static int __set_print_fmt(struct trace_uprobe *tu, char *buf, int len)
669 const char *fmt, *arg;
673 if (is_ret_probe(tu)) {
674 fmt = "(%lx <- %lx)";
675 arg = "REC->" FIELD_STRING_FUNC ", REC->" FIELD_STRING_RETIP;
678 arg = "REC->" FIELD_STRING_IP;
681 /* When len=0, we just calculate the needed length */
683 pos += snprintf(buf + pos, LEN_OR_ZERO, "\"%s", fmt);
685 for (i = 0; i < tu->nr_args; i++) {
686 pos += snprintf(buf + pos, LEN_OR_ZERO, " %s=%s",
687 tu->args[i].name, tu->args[i].type->fmt);
690 pos += snprintf(buf + pos, LEN_OR_ZERO, "\", %s", arg);
692 for (i = 0; i < tu->nr_args; i++) {
693 pos += snprintf(buf + pos, LEN_OR_ZERO, ", REC->%s",
697 return pos; /* return the length of print_fmt */
701 static int set_print_fmt(struct trace_uprobe *tu)
706 /* First: called with 0 length to calculate the needed length */
707 len = __set_print_fmt(tu, NULL, 0);
708 print_fmt = kmalloc(len + 1, GFP_KERNEL);
712 /* Second: actually write the @print_fmt */
713 __set_print_fmt(tu, print_fmt, len + 1);
714 tu->call.print_fmt = print_fmt;
719 #ifdef CONFIG_PERF_EVENTS
721 __uprobe_perf_filter(struct trace_uprobe_filter *filter, struct mm_struct *mm)
723 struct perf_event *event;
725 if (filter->nr_systemwide)
728 list_for_each_entry(event, &filter->perf_events, hw.tp_list) {
729 if (event->hw.tp_target->mm == mm)
737 uprobe_filter_event(struct trace_uprobe *tu, struct perf_event *event)
739 return __uprobe_perf_filter(&tu->filter, event->hw.tp_target->mm);
742 static int uprobe_perf_open(struct trace_uprobe *tu, struct perf_event *event)
746 write_lock(&tu->filter.rwlock);
747 if (event->hw.tp_target) {
749 * event->parent != NULL means copy_process(), we can avoid
750 * uprobe_apply(). current->mm must be probed and we can rely
751 * on dup_mmap() which preserves the already installed bp's.
753 * attr.enable_on_exec means that exec/mmap will install the
754 * breakpoints we need.
756 done = tu->filter.nr_systemwide ||
757 event->parent || event->attr.enable_on_exec ||
758 uprobe_filter_event(tu, event);
759 list_add(&event->hw.tp_list, &tu->filter.perf_events);
761 done = tu->filter.nr_systemwide;
762 tu->filter.nr_systemwide++;
764 write_unlock(&tu->filter.rwlock);
767 uprobe_apply(tu->inode, tu->offset, &tu->consumer, true);
772 static int uprobe_perf_close(struct trace_uprobe *tu, struct perf_event *event)
776 write_lock(&tu->filter.rwlock);
777 if (event->hw.tp_target) {
778 list_del(&event->hw.tp_list);
779 done = tu->filter.nr_systemwide ||
780 (event->hw.tp_target->flags & PF_EXITING) ||
781 uprobe_filter_event(tu, event);
783 tu->filter.nr_systemwide--;
784 done = tu->filter.nr_systemwide;
786 write_unlock(&tu->filter.rwlock);
789 uprobe_apply(tu->inode, tu->offset, &tu->consumer, false);
794 static bool uprobe_perf_filter(struct uprobe_consumer *uc,
795 enum uprobe_filter_ctx ctx, struct mm_struct *mm)
797 struct trace_uprobe *tu;
800 tu = container_of(uc, struct trace_uprobe, consumer);
801 read_lock(&tu->filter.rwlock);
802 ret = __uprobe_perf_filter(&tu->filter, mm);
803 read_unlock(&tu->filter.rwlock);
808 static void uprobe_perf_print(struct trace_uprobe *tu,
809 unsigned long func, struct pt_regs *regs)
811 struct ftrace_event_call *call = &tu->call;
812 struct uprobe_trace_entry_head *entry;
813 struct hlist_head *head;
817 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
818 size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
819 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
823 head = this_cpu_ptr(call->perf_events);
824 if (hlist_empty(head))
827 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
831 if (is_ret_probe(tu)) {
832 entry->vaddr[0] = func;
833 entry->vaddr[1] = instruction_pointer(regs);
834 data = DATAOF_TRACE_ENTRY(entry, true);
836 entry->vaddr[0] = instruction_pointer(regs);
837 data = DATAOF_TRACE_ENTRY(entry, false);
840 for (i = 0; i < tu->nr_args; i++)
841 call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);
843 perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
848 /* uprobe profile handler */
849 static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
851 if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
852 return UPROBE_HANDLER_REMOVE;
854 if (!is_ret_probe(tu))
855 uprobe_perf_print(tu, 0, regs);
859 static void uretprobe_perf_func(struct trace_uprobe *tu, unsigned long func,
860 struct pt_regs *regs)
862 uprobe_perf_print(tu, func, regs);
864 #endif /* CONFIG_PERF_EVENTS */
867 int trace_uprobe_register(struct ftrace_event_call *event, enum trace_reg type, void *data)
869 struct trace_uprobe *tu = event->data;
872 case TRACE_REG_REGISTER:
873 return probe_event_enable(tu, TP_FLAG_TRACE, NULL);
875 case TRACE_REG_UNREGISTER:
876 probe_event_disable(tu, TP_FLAG_TRACE);
879 #ifdef CONFIG_PERF_EVENTS
880 case TRACE_REG_PERF_REGISTER:
881 return probe_event_enable(tu, TP_FLAG_PROFILE, uprobe_perf_filter);
883 case TRACE_REG_PERF_UNREGISTER:
884 probe_event_disable(tu, TP_FLAG_PROFILE);
887 case TRACE_REG_PERF_OPEN:
888 return uprobe_perf_open(tu, data);
890 case TRACE_REG_PERF_CLOSE:
891 return uprobe_perf_close(tu, data);
900 static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
902 struct trace_uprobe *tu;
905 tu = container_of(con, struct trace_uprobe, consumer);
908 if (tu->flags & TP_FLAG_TRACE)
909 ret |= uprobe_trace_func(tu, regs);
911 #ifdef CONFIG_PERF_EVENTS
912 if (tu->flags & TP_FLAG_PROFILE)
913 ret |= uprobe_perf_func(tu, regs);
918 static int uretprobe_dispatcher(struct uprobe_consumer *con,
919 unsigned long func, struct pt_regs *regs)
921 struct trace_uprobe *tu;
923 tu = container_of(con, struct trace_uprobe, consumer);
925 if (tu->flags & TP_FLAG_TRACE)
926 uretprobe_trace_func(tu, func, regs);
928 #ifdef CONFIG_PERF_EVENTS
929 if (tu->flags & TP_FLAG_PROFILE)
930 uretprobe_perf_func(tu, func, regs);
935 static struct trace_event_functions uprobe_funcs = {
936 .trace = print_uprobe_event
939 static int register_uprobe_event(struct trace_uprobe *tu)
941 struct ftrace_event_call *call = &tu->call;
944 /* Initialize ftrace_event_call */
945 INIT_LIST_HEAD(&call->class->fields);
946 call->event.funcs = &uprobe_funcs;
947 call->class->define_fields = uprobe_event_define_fields;
949 if (set_print_fmt(tu) < 0)
952 ret = register_ftrace_event(&call->event);
954 kfree(call->print_fmt);
958 call->class->reg = trace_uprobe_register;
960 ret = trace_add_event_call(call);
963 pr_info("Failed to register uprobe event: %s\n", call->name);
964 kfree(call->print_fmt);
965 unregister_ftrace_event(&call->event);
971 static void unregister_uprobe_event(struct trace_uprobe *tu)
973 /* tu->event is unregistered in trace_remove_event_call() */
974 trace_remove_event_call(&tu->call);
975 kfree(tu->call.print_fmt);
976 tu->call.print_fmt = NULL;
979 /* Make a trace interface for controling probe points */
980 static __init int init_uprobe_trace(void)
982 struct dentry *d_tracer;
984 d_tracer = tracing_init_dentry();
988 trace_create_file("uprobe_events", 0644, d_tracer,
989 NULL, &uprobe_events_ops);
990 /* Profile interface */
991 trace_create_file("uprobe_profile", 0444, d_tracer,
992 NULL, &uprobe_profile_ops);
996 fs_initcall(init_uprobe_trace);