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 trace_uprobe_filter filter;
55 struct uprobe_consumer consumer;
60 struct trace_probe tp;
63 #define SIZEOF_TRACE_UPROBE(n) \
64 (offsetof(struct trace_uprobe, tp.args) + \
65 (sizeof(struct probe_arg) * (n)))
67 static int register_uprobe_event(struct trace_uprobe *tu);
68 static int unregister_uprobe_event(struct trace_uprobe *tu);
70 static DEFINE_MUTEX(uprobe_lock);
71 static LIST_HEAD(uprobe_list);
73 static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs);
74 static int uretprobe_dispatcher(struct uprobe_consumer *con,
75 unsigned long func, struct pt_regs *regs);
77 /* Fetch type information table */
78 const struct fetch_type uprobes_fetch_type_table[] = {
80 [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string,
81 sizeof(u32), 1, "__data_loc char[]"),
82 [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32,
83 string_size, sizeof(u32), 0, "u32"),
85 ASSIGN_FETCH_TYPE(u8, u8, 0),
86 ASSIGN_FETCH_TYPE(u16, u16, 0),
87 ASSIGN_FETCH_TYPE(u32, u32, 0),
88 ASSIGN_FETCH_TYPE(u64, u64, 0),
89 ASSIGN_FETCH_TYPE(s8, u8, 1),
90 ASSIGN_FETCH_TYPE(s16, u16, 1),
91 ASSIGN_FETCH_TYPE(s32, u32, 1),
92 ASSIGN_FETCH_TYPE(s64, u64, 1),
97 static inline void init_trace_uprobe_filter(struct trace_uprobe_filter *filter)
99 rwlock_init(&filter->rwlock);
100 filter->nr_systemwide = 0;
101 INIT_LIST_HEAD(&filter->perf_events);
104 static inline bool uprobe_filter_is_empty(struct trace_uprobe_filter *filter)
106 return !filter->nr_systemwide && list_empty(&filter->perf_events);
109 static inline bool is_ret_probe(struct trace_uprobe *tu)
111 return tu->consumer.ret_handler != NULL;
115 * Allocate new trace_uprobe and initialize it (including uprobes).
117 static struct trace_uprobe *
118 alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
120 struct trace_uprobe *tu;
122 if (!event || !is_good_name(event))
123 return ERR_PTR(-EINVAL);
125 if (!group || !is_good_name(group))
126 return ERR_PTR(-EINVAL);
128 tu = kzalloc(SIZEOF_TRACE_UPROBE(nargs), GFP_KERNEL);
130 return ERR_PTR(-ENOMEM);
132 tu->tp.call.class = &tu->tp.class;
133 tu->tp.call.name = kstrdup(event, GFP_KERNEL);
134 if (!tu->tp.call.name)
137 tu->tp.class.system = kstrdup(group, GFP_KERNEL);
138 if (!tu->tp.class.system)
141 INIT_LIST_HEAD(&tu->list);
142 tu->consumer.handler = uprobe_dispatcher;
144 tu->consumer.ret_handler = uretprobe_dispatcher;
145 init_trace_uprobe_filter(&tu->filter);
146 tu->tp.call.flags |= TRACE_EVENT_FL_USE_CALL_FILTER;
150 kfree(tu->tp.call.name);
153 return ERR_PTR(-ENOMEM);
156 static void free_trace_uprobe(struct trace_uprobe *tu)
160 for (i = 0; i < tu->tp.nr_args; i++)
161 traceprobe_free_probe_arg(&tu->tp.args[i]);
164 kfree(tu->tp.call.class->system);
165 kfree(tu->tp.call.name);
170 static struct trace_uprobe *find_probe_event(const char *event, const char *group)
172 struct trace_uprobe *tu;
174 list_for_each_entry(tu, &uprobe_list, list)
175 if (strcmp(tu->tp.call.name, event) == 0 &&
176 strcmp(tu->tp.call.class->system, group) == 0)
182 /* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
183 static int unregister_trace_uprobe(struct trace_uprobe *tu)
187 ret = unregister_uprobe_event(tu);
192 free_trace_uprobe(tu);
196 /* Register a trace_uprobe and probe_event */
197 static int register_trace_uprobe(struct trace_uprobe *tu)
199 struct trace_uprobe *old_tu;
202 mutex_lock(&uprobe_lock);
204 /* register as an event */
205 old_tu = find_probe_event(tu->tp.call.name, tu->tp.call.class->system);
207 /* delete old event */
208 ret = unregister_trace_uprobe(old_tu);
213 ret = register_uprobe_event(tu);
215 pr_warning("Failed to register probe event(%d)\n", ret);
219 list_add_tail(&tu->list, &uprobe_list);
222 mutex_unlock(&uprobe_lock);
229 * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS]
231 * - Remove uprobe: -:[GRP/]EVENT
233 static int create_trace_uprobe(int argc, char **argv)
235 struct trace_uprobe *tu;
237 char *arg, *event, *group, *filename;
238 char buf[MAX_EVENT_NAME_LEN];
240 unsigned long offset;
241 bool is_delete, is_return;
251 /* argc must be >= 1 */
252 if (argv[0][0] == '-')
254 else if (argv[0][0] == 'r')
256 else if (argv[0][0] != 'p') {
257 pr_info("Probe definition must be started with 'p', 'r' or '-'.\n");
261 if (argv[0][1] == ':') {
263 arg = strchr(event, '/');
270 if (strlen(group) == 0) {
271 pr_info("Group name is not specified\n");
275 if (strlen(event) == 0) {
276 pr_info("Event name is not specified\n");
281 group = UPROBE_EVENT_SYSTEM;
287 pr_info("Delete command needs an event name.\n");
290 mutex_lock(&uprobe_lock);
291 tu = find_probe_event(event, group);
294 mutex_unlock(&uprobe_lock);
295 pr_info("Event %s/%s doesn't exist.\n", group, event);
298 /* delete an event */
299 ret = unregister_trace_uprobe(tu);
300 mutex_unlock(&uprobe_lock);
305 pr_info("Probe point is not specified.\n");
308 if (isdigit(argv[1][0])) {
309 pr_info("probe point must be have a filename.\n");
312 arg = strchr(argv[1], ':');
315 goto fail_address_parse;
320 ret = kern_path(filename, LOOKUP_FOLLOW, &path);
322 goto fail_address_parse;
324 inode = igrab(path.dentry->d_inode);
327 if (!inode || !S_ISREG(inode->i_mode)) {
329 goto fail_address_parse;
332 ret = kstrtoul(arg, 0, &offset);
334 goto fail_address_parse;
344 tail = kstrdup(kbasename(filename), GFP_KERNEL);
347 goto fail_address_parse;
350 ptr = strpbrk(tail, ".-_");
354 snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_0x%lx", 'p', tail, offset);
359 tu = alloc_trace_uprobe(group, event, argc, is_return);
361 pr_info("Failed to allocate trace_uprobe.(%d)\n", (int)PTR_ERR(tu));
363 goto fail_address_parse;
367 tu->filename = kstrdup(filename, GFP_KERNEL);
370 pr_info("Failed to allocate filename.\n");
375 /* parse arguments */
377 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
378 struct probe_arg *parg = &tu->tp.args[i];
380 /* Increment count for freeing args in error case */
383 /* Parse argument name */
384 arg = strchr(argv[i], '=');
387 parg->name = kstrdup(argv[i], GFP_KERNEL);
390 /* If argument name is omitted, set "argN" */
391 snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1);
392 parg->name = kstrdup(buf, GFP_KERNEL);
396 pr_info("Failed to allocate argument[%d] name.\n", i);
401 if (!is_good_name(parg->name)) {
402 pr_info("Invalid argument[%d] name: %s\n", i, parg->name);
407 if (traceprobe_conflict_field_name(parg->name, tu->tp.args, i)) {
408 pr_info("Argument[%d] name '%s' conflicts with "
409 "another field.\n", i, argv[i]);
414 /* Parse fetch argument */
415 ret = traceprobe_parse_probe_arg(arg, &tu->tp.size, parg,
418 pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
423 ret = register_trace_uprobe(tu);
429 free_trace_uprobe(tu);
436 pr_info("Failed to parse address or file.\n");
441 static int cleanup_all_probes(void)
443 struct trace_uprobe *tu;
446 mutex_lock(&uprobe_lock);
447 while (!list_empty(&uprobe_list)) {
448 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
449 ret = unregister_trace_uprobe(tu);
453 mutex_unlock(&uprobe_lock);
457 /* Probes listing interfaces */
458 static void *probes_seq_start(struct seq_file *m, loff_t *pos)
460 mutex_lock(&uprobe_lock);
461 return seq_list_start(&uprobe_list, *pos);
464 static void *probes_seq_next(struct seq_file *m, void *v, loff_t *pos)
466 return seq_list_next(v, &uprobe_list, pos);
469 static void probes_seq_stop(struct seq_file *m, void *v)
471 mutex_unlock(&uprobe_lock);
474 static int probes_seq_show(struct seq_file *m, void *v)
476 struct trace_uprobe *tu = v;
477 char c = is_ret_probe(tu) ? 'r' : 'p';
480 seq_printf(m, "%c:%s/%s", c, tu->tp.call.class->system, tu->tp.call.name);
481 seq_printf(m, " %s:0x%p", tu->filename, (void *)tu->offset);
483 for (i = 0; i < tu->tp.nr_args; i++)
484 seq_printf(m, " %s=%s", tu->tp.args[i].name, tu->tp.args[i].comm);
490 static const struct seq_operations probes_seq_op = {
491 .start = probes_seq_start,
492 .next = probes_seq_next,
493 .stop = probes_seq_stop,
494 .show = probes_seq_show
497 static int probes_open(struct inode *inode, struct file *file)
501 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
502 ret = cleanup_all_probes();
507 return seq_open(file, &probes_seq_op);
510 static ssize_t probes_write(struct file *file, const char __user *buffer,
511 size_t count, loff_t *ppos)
513 return traceprobe_probes_write(file, buffer, count, ppos, create_trace_uprobe);
516 static const struct file_operations uprobe_events_ops = {
517 .owner = THIS_MODULE,
521 .release = seq_release,
522 .write = probes_write,
525 /* Probes profiling interfaces */
526 static int probes_profile_seq_show(struct seq_file *m, void *v)
528 struct trace_uprobe *tu = v;
530 seq_printf(m, " %s %-44s %15lu\n", tu->filename, tu->tp.call.name, tu->nhit);
534 static const struct seq_operations profile_seq_op = {
535 .start = probes_seq_start,
536 .next = probes_seq_next,
537 .stop = probes_seq_stop,
538 .show = probes_profile_seq_show
541 static int profile_open(struct inode *inode, struct file *file)
543 return seq_open(file, &profile_seq_op);
546 static const struct file_operations uprobe_profile_ops = {
547 .owner = THIS_MODULE,
548 .open = profile_open,
551 .release = seq_release,
554 static void uprobe_trace_print(struct trace_uprobe *tu,
555 unsigned long func, struct pt_regs *regs)
557 struct uprobe_trace_entry_head *entry;
558 struct ring_buffer_event *event;
559 struct ring_buffer *buffer;
562 struct ftrace_event_call *call = &tu->tp.call;
564 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
565 event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
566 size + tu->tp.size, 0, 0);
570 entry = ring_buffer_event_data(event);
571 if (is_ret_probe(tu)) {
572 entry->vaddr[0] = func;
573 entry->vaddr[1] = instruction_pointer(regs);
574 data = DATAOF_TRACE_ENTRY(entry, true);
576 entry->vaddr[0] = instruction_pointer(regs);
577 data = DATAOF_TRACE_ENTRY(entry, false);
580 for (i = 0; i < tu->tp.nr_args; i++) {
581 call_fetch(&tu->tp.args[i].fetch, regs,
582 data + tu->tp.args[i].offset);
585 if (!call_filter_check_discard(call, entry, buffer, event))
586 trace_buffer_unlock_commit(buffer, event, 0, 0);
590 static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
592 if (!is_ret_probe(tu))
593 uprobe_trace_print(tu, 0, regs);
597 static void uretprobe_trace_func(struct trace_uprobe *tu, unsigned long func,
598 struct pt_regs *regs)
600 uprobe_trace_print(tu, func, regs);
603 /* Event entry printers */
604 static enum print_line_t
605 print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *event)
607 struct uprobe_trace_entry_head *entry;
608 struct trace_seq *s = &iter->seq;
609 struct trace_uprobe *tu;
613 entry = (struct uprobe_trace_entry_head *)iter->ent;
614 tu = container_of(event, struct trace_uprobe, tp.call.event);
616 if (is_ret_probe(tu)) {
617 if (!trace_seq_printf(s, "%s: (0x%lx <- 0x%lx)", tu->tp.call.name,
618 entry->vaddr[1], entry->vaddr[0]))
620 data = DATAOF_TRACE_ENTRY(entry, true);
622 if (!trace_seq_printf(s, "%s: (0x%lx)", tu->tp.call.name,
625 data = DATAOF_TRACE_ENTRY(entry, false);
628 for (i = 0; i < tu->tp.nr_args; i++) {
629 struct probe_arg *parg = &tu->tp.args[i];
631 if (!parg->type->print(s, parg->name, data + parg->offset, entry))
635 if (trace_seq_puts(s, "\n"))
636 return TRACE_TYPE_HANDLED;
639 return TRACE_TYPE_PARTIAL_LINE;
642 typedef bool (*filter_func_t)(struct uprobe_consumer *self,
643 enum uprobe_filter_ctx ctx,
644 struct mm_struct *mm);
647 probe_event_enable(struct trace_uprobe *tu, int flag, filter_func_t filter)
651 if (trace_probe_is_enabled(&tu->tp))
654 WARN_ON(!uprobe_filter_is_empty(&tu->filter));
656 tu->tp.flags |= flag;
657 tu->consumer.filter = filter;
658 ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
660 tu->tp.flags &= ~flag;
665 static void probe_event_disable(struct trace_uprobe *tu, int flag)
667 if (!trace_probe_is_enabled(&tu->tp))
670 WARN_ON(!uprobe_filter_is_empty(&tu->filter));
672 uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
673 tu->tp.flags &= ~flag;
676 static int uprobe_event_define_fields(struct ftrace_event_call *event_call)
679 struct uprobe_trace_entry_head field;
680 struct trace_uprobe *tu = event_call->data;
682 if (is_ret_probe(tu)) {
683 DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_FUNC, 0);
684 DEFINE_FIELD(unsigned long, vaddr[1], FIELD_STRING_RETIP, 0);
685 size = SIZEOF_TRACE_ENTRY(true);
687 DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_IP, 0);
688 size = SIZEOF_TRACE_ENTRY(false);
690 /* Set argument names as fields */
691 for (i = 0; i < tu->tp.nr_args; i++) {
692 struct probe_arg *parg = &tu->tp.args[i];
694 ret = trace_define_field(event_call, parg->type->fmttype,
695 parg->name, size + parg->offset,
696 parg->type->size, parg->type->is_signed,
705 #ifdef CONFIG_PERF_EVENTS
707 __uprobe_perf_filter(struct trace_uprobe_filter *filter, struct mm_struct *mm)
709 struct perf_event *event;
711 if (filter->nr_systemwide)
714 list_for_each_entry(event, &filter->perf_events, hw.tp_list) {
715 if (event->hw.tp_target->mm == mm)
723 uprobe_filter_event(struct trace_uprobe *tu, struct perf_event *event)
725 return __uprobe_perf_filter(&tu->filter, event->hw.tp_target->mm);
728 static int uprobe_perf_open(struct trace_uprobe *tu, struct perf_event *event)
732 write_lock(&tu->filter.rwlock);
733 if (event->hw.tp_target) {
735 * event->parent != NULL means copy_process(), we can avoid
736 * uprobe_apply(). current->mm must be probed and we can rely
737 * on dup_mmap() which preserves the already installed bp's.
739 * attr.enable_on_exec means that exec/mmap will install the
740 * breakpoints we need.
742 done = tu->filter.nr_systemwide ||
743 event->parent || event->attr.enable_on_exec ||
744 uprobe_filter_event(tu, event);
745 list_add(&event->hw.tp_list, &tu->filter.perf_events);
747 done = tu->filter.nr_systemwide;
748 tu->filter.nr_systemwide++;
750 write_unlock(&tu->filter.rwlock);
753 uprobe_apply(tu->inode, tu->offset, &tu->consumer, true);
758 static int uprobe_perf_close(struct trace_uprobe *tu, struct perf_event *event)
762 write_lock(&tu->filter.rwlock);
763 if (event->hw.tp_target) {
764 list_del(&event->hw.tp_list);
765 done = tu->filter.nr_systemwide ||
766 (event->hw.tp_target->flags & PF_EXITING) ||
767 uprobe_filter_event(tu, event);
769 tu->filter.nr_systemwide--;
770 done = tu->filter.nr_systemwide;
772 write_unlock(&tu->filter.rwlock);
775 uprobe_apply(tu->inode, tu->offset, &tu->consumer, false);
780 static bool uprobe_perf_filter(struct uprobe_consumer *uc,
781 enum uprobe_filter_ctx ctx, struct mm_struct *mm)
783 struct trace_uprobe *tu;
786 tu = container_of(uc, struct trace_uprobe, consumer);
787 read_lock(&tu->filter.rwlock);
788 ret = __uprobe_perf_filter(&tu->filter, mm);
789 read_unlock(&tu->filter.rwlock);
794 static void uprobe_perf_print(struct trace_uprobe *tu,
795 unsigned long func, struct pt_regs *regs)
797 struct ftrace_event_call *call = &tu->tp.call;
798 struct uprobe_trace_entry_head *entry;
799 struct hlist_head *head;
803 size = SIZEOF_TRACE_ENTRY(is_ret_probe(tu));
804 size = ALIGN(size + tu->tp.size + sizeof(u32), sizeof(u64)) - sizeof(u32);
807 head = this_cpu_ptr(call->perf_events);
808 if (hlist_empty(head))
811 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
815 if (is_ret_probe(tu)) {
816 entry->vaddr[0] = func;
817 entry->vaddr[1] = instruction_pointer(regs);
818 data = DATAOF_TRACE_ENTRY(entry, true);
820 entry->vaddr[0] = instruction_pointer(regs);
821 data = DATAOF_TRACE_ENTRY(entry, false);
824 for (i = 0; i < tu->tp.nr_args; i++) {
825 struct probe_arg *parg = &tu->tp.args[i];
827 call_fetch(&parg->fetch, regs, data + parg->offset);
830 perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
835 /* uprobe profile handler */
836 static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
838 if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
839 return UPROBE_HANDLER_REMOVE;
841 if (!is_ret_probe(tu))
842 uprobe_perf_print(tu, 0, regs);
846 static void uretprobe_perf_func(struct trace_uprobe *tu, unsigned long func,
847 struct pt_regs *regs)
849 uprobe_perf_print(tu, func, regs);
851 #endif /* CONFIG_PERF_EVENTS */
854 int trace_uprobe_register(struct ftrace_event_call *event, enum trace_reg type, void *data)
856 struct trace_uprobe *tu = event->data;
859 case TRACE_REG_REGISTER:
860 return probe_event_enable(tu, TP_FLAG_TRACE, NULL);
862 case TRACE_REG_UNREGISTER:
863 probe_event_disable(tu, TP_FLAG_TRACE);
866 #ifdef CONFIG_PERF_EVENTS
867 case TRACE_REG_PERF_REGISTER:
868 return probe_event_enable(tu, TP_FLAG_PROFILE, uprobe_perf_filter);
870 case TRACE_REG_PERF_UNREGISTER:
871 probe_event_disable(tu, TP_FLAG_PROFILE);
874 case TRACE_REG_PERF_OPEN:
875 return uprobe_perf_open(tu, data);
877 case TRACE_REG_PERF_CLOSE:
878 return uprobe_perf_close(tu, data);
887 static int uprobe_dispatcher(struct uprobe_consumer *con, struct pt_regs *regs)
889 struct trace_uprobe *tu;
892 tu = container_of(con, struct trace_uprobe, consumer);
895 if (tu->tp.flags & TP_FLAG_TRACE)
896 ret |= uprobe_trace_func(tu, regs);
898 #ifdef CONFIG_PERF_EVENTS
899 if (tu->tp.flags & TP_FLAG_PROFILE)
900 ret |= uprobe_perf_func(tu, regs);
905 static int uretprobe_dispatcher(struct uprobe_consumer *con,
906 unsigned long func, struct pt_regs *regs)
908 struct trace_uprobe *tu;
910 tu = container_of(con, struct trace_uprobe, consumer);
912 if (tu->tp.flags & TP_FLAG_TRACE)
913 uretprobe_trace_func(tu, func, regs);
915 #ifdef CONFIG_PERF_EVENTS
916 if (tu->tp.flags & TP_FLAG_PROFILE)
917 uretprobe_perf_func(tu, func, regs);
922 static struct trace_event_functions uprobe_funcs = {
923 .trace = print_uprobe_event
926 static int register_uprobe_event(struct trace_uprobe *tu)
928 struct ftrace_event_call *call = &tu->tp.call;
931 /* Initialize ftrace_event_call */
932 INIT_LIST_HEAD(&call->class->fields);
933 call->event.funcs = &uprobe_funcs;
934 call->class->define_fields = uprobe_event_define_fields;
936 if (set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0)
939 ret = register_ftrace_event(&call->event);
941 kfree(call->print_fmt);
945 call->class->reg = trace_uprobe_register;
947 ret = trace_add_event_call(call);
950 pr_info("Failed to register uprobe event: %s\n", call->name);
951 kfree(call->print_fmt);
952 unregister_ftrace_event(&call->event);
958 static int unregister_uprobe_event(struct trace_uprobe *tu)
962 /* tu->event is unregistered in trace_remove_event_call() */
963 ret = trace_remove_event_call(&tu->tp.call);
966 kfree(tu->tp.call.print_fmt);
967 tu->tp.call.print_fmt = NULL;
971 /* Make a trace interface for controling probe points */
972 static __init int init_uprobe_trace(void)
974 struct dentry *d_tracer;
976 d_tracer = tracing_init_dentry();
980 trace_create_file("uprobe_events", 0644, d_tracer,
981 NULL, &uprobe_events_ops);
982 /* Profile interface */
983 trace_create_file("uprobe_profile", 0444, d_tracer,
984 NULL, &uprobe_profile_ops);
988 fs_initcall(init_uprobe_trace);