struct list_head node;
};
+struct lttng_kprobe {
+ struct kprobe kp;
+ char *symbol_name;
+};
+
enum lttng_syscall_entryexit {
LTTNG_SYSCALL_ENTRY,
LTTNG_SYSCALL_EXIT,
struct lttng_ctx *ctx;
enum lttng_kernel_instrumentation instrumentation;
union {
- struct {
- struct kprobe kp;
- char *symbol_name;
- } kprobe;
+ struct lttng_kprobe kprobe;
struct {
struct lttng_krp *lttng_krp;
char *symbol_name;
extern int lttng_statedump_start(struct lttng_session *session);
#ifdef CONFIG_KPROBES
-int lttng_kprobes_register(const char *name,
+int lttng_kprobes_register_event(const char *name,
const char *symbol_name,
uint64_t offset,
uint64_t addr,
struct lttng_event *event);
-void lttng_kprobes_unregister(struct lttng_event *event);
-void lttng_kprobes_destroy_private(struct lttng_event *event);
+void lttng_kprobes_unregister_event(struct lttng_event *event);
+void lttng_kprobes_destroy_event_private(struct lttng_event *event);
#else
static inline
-int lttng_kprobes_register(const char *name,
+int lttng_kprobes_register_event(const char *name,
const char *symbol_name,
uint64_t offset,
uint64_t addr,
}
static inline
-void lttng_kprobes_unregister(struct lttng_event *event)
+void lttng_kprobes_unregister_event(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_kprobes_destroy_event_private(struct lttng_event *event)
{
}
* registration.
*/
smp_wmb();
- ret = lttng_kprobes_register(event_name,
+ ret = lttng_kprobes_register_event(event_name,
event_param->u.kprobe.symbol_name,
event_param->u.kprobe.offset,
event_param->u.kprobe.addr,
event);
break;
case LTTNG_KERNEL_KPROBE:
- lttng_kprobes_unregister(event);
+ lttng_kprobes_unregister_event(event);
ret = 0;
break;
case LTTNG_KERNEL_KRETPROBE:
break;
case LTTNG_KERNEL_KPROBE:
module_put(event->desc->owner);
- lttng_kprobes_destroy_private(event);
+ lttng_kprobes_destroy_event_private(event);
break;
case LTTNG_KERNEL_KRETPROBE:
module_put(event->desc->owner);
#include <blacklist/kprobes.h>
static
-int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs)
+int lttng_kprobes_event_handler_pre(struct kprobe *p, struct pt_regs *regs)
{
struct lttng_event *event =
container_of(p, struct lttng_event, u.kprobe.kp);
return ret;
}
-int lttng_kprobes_register(const char *name,
- const char *symbol_name,
+static
+int _lttng_kprobes_register(const char *symbol_name,
uint64_t offset,
uint64_t addr,
- struct lttng_event *event)
+ struct lttng_kprobe *lttng_kp,
+ kprobe_pre_handler_t pre_handler)
{
int ret;
if (symbol_name[0] == '\0')
symbol_name = NULL;
- ret = lttng_create_kprobe_event(name, event);
- if (ret)
- goto error;
- memset(&event->u.kprobe.kp, 0, sizeof(event->u.kprobe.kp));
- event->u.kprobe.kp.pre_handler = lttng_kprobes_handler_pre;
+ memset(<tng_kp->kp, 0, sizeof(lttng_kp->kp));
+ lttng_kp->kp.pre_handler = pre_handler;
+
if (symbol_name) {
- event->u.kprobe.symbol_name =
+ lttng_kp->symbol_name =
kzalloc(LTTNG_KERNEL_SYM_NAME_LEN * sizeof(char),
GFP_KERNEL);
- if (!event->u.kprobe.symbol_name) {
+ if (!lttng_kp->symbol_name) {
ret = -ENOMEM;
goto name_error;
}
- memcpy(event->u.kprobe.symbol_name, symbol_name,
+ memcpy(lttng_kp->symbol_name, symbol_name,
LTTNG_KERNEL_SYM_NAME_LEN * sizeof(char));
- event->u.kprobe.kp.symbol_name =
- event->u.kprobe.symbol_name;
+ lttng_kp->kp.symbol_name = lttng_kp->symbol_name;
}
- event->u.kprobe.kp.offset = offset;
- event->u.kprobe.kp.addr = (void *) (unsigned long) addr;
+
+ lttng_kp->kp.offset = offset;
+ lttng_kp->kp.addr = (void *) (unsigned long) addr;
/*
* Ensure the memory we just allocated don't trigger page faults.
*/
wrapper_vmalloc_sync_mappings();
- ret = register_kprobe(&event->u.kprobe.kp);
+ ret = register_kprobe(<tng_kp->kp);
if (ret)
goto register_error;
+
return 0;
register_error:
- kfree(event->u.kprobe.symbol_name);
+ kfree(lttng_kp->symbol_name);
name_error:
+ return ret;
+}
+
+int lttng_kprobes_register_event(const char *name,
+ const char *symbol_name,
+ uint64_t offset,
+ uint64_t addr,
+ struct lttng_event *event)
+{
+ int ret;
+
+ ret = lttng_create_kprobe_event(name, event);
+ if (ret)
+ goto error;
+
+ ret = _lttng_kprobes_register(symbol_name, offset, addr,
+ &event->u.kprobe, lttng_kprobes_event_handler_pre);
+ if (ret)
+ goto register_error;
+
+ return 0;
+
+register_error:
kfree(event->desc->fields);
kfree(event->desc->name);
kfree(event->desc);
error:
return ret;
}
-EXPORT_SYMBOL_GPL(lttng_kprobes_register);
+EXPORT_SYMBOL_GPL(lttng_kprobes_register_event);
-void lttng_kprobes_unregister(struct lttng_event *event)
+void lttng_kprobes_unregister_event(struct lttng_event *event)
{
unregister_kprobe(&event->u.kprobe.kp);
}
-EXPORT_SYMBOL_GPL(lttng_kprobes_unregister);
+EXPORT_SYMBOL_GPL(lttng_kprobes_unregister_event);
-void lttng_kprobes_destroy_private(struct lttng_event *event)
+void lttng_kprobes_destroy_event_private(struct lttng_event *event)
{
kfree(event->u.kprobe.symbol_name);
kfree(event->desc->fields);
kfree(event->desc->name);
kfree(event->desc);
}
-EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_private);
+EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_event_private);
MODULE_LICENSE("GPL and additional rights");
MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");