| 1 | /* |
| 2 | * (C) Copyright 2009-2011 - |
| 3 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | * |
| 5 | * LTTng kprobes integration module. |
| 6 | * |
| 7 | * Dual LGPL v2.1/GPL v2 license. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/kprobes.h> |
| 12 | #include "../ltt-events.h" |
| 13 | #include "../wrapper/ringbuffer/frontend_types.h" |
| 14 | #include "../ltt-tracer.h" |
| 15 | |
| 16 | void lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs) |
| 17 | { |
| 18 | struct ltt_event *event = |
| 19 | container_of(p, struct ltt_event, u.kprobe.kp); |
| 20 | struct ltt_channel *chan = event->chan; |
| 21 | struct lib_ring_buffer_ctx ctx; |
| 22 | int ret; |
| 23 | unsigned long data = (unsigned long) p->addr; |
| 24 | |
| 25 | if (!ACCESS_ONCE(chan->session->active)) |
| 26 | return; |
| 27 | lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, sizeof(data), |
| 28 | ltt_alignof(data), -1); |
| 29 | ret = chan->ops->event_reserve(&ctx); |
| 30 | if (ret < 0) |
| 31 | return; |
| 32 | lib_ring_buffer_align_ctx(&ctx, ltt_alignof(data)); |
| 33 | chan->ops->event_write(&ctx, &data, sizeof(data)); |
| 34 | chan->ops->event_commit(&ctx); |
| 35 | } |
| 36 | EXPORT_SYMBOL_GPL(lttng_kprobes_handler_pre); |
| 37 | |
| 38 | MODULE_LICENSE("GPL and additional rights"); |
| 39 | MODULE_AUTHOR("Mathieu Desnoyers"); |
| 40 | MODULE_DESCRIPTION("Linux Trace Toolkit Kprobes Support"); |