Build fix: check if have syscall tracepoint config
[lttng-modules.git] / probes / lttng-kprobes.c
index 96e7509c328bedb3211e3e3e3dfc4e4d6450f4a8..38ee4513811691273de7454f0415ee56c6da44ce 100644 (file)
@@ -25,11 +25,16 @@ int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs)
        int ret;
        unsigned long data = (unsigned long) p->addr;
 
-       if (!ACCESS_ONCE(chan->session->active))
+       if (unlikely(!ACCESS_ONCE(chan->session->active)))
                return 0;
-       lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, sizeof(data),
+       if (unlikely(!ACCESS_ONCE(chan->enabled)))
+               return 0;
+       if (unlikely(!ACCESS_ONCE(event->enabled)))
+               return 0;
+
+       lib_ring_buffer_ctx_init(&ctx, chan->chan, event, sizeof(data),
                                 ltt_alignof(data), -1);
-       ret = chan->ops->event_reserve(&ctx);
+       ret = chan->ops->event_reserve(&ctx, event->id);
        if (ret < 0)
                return 0;
        lib_ring_buffer_align_ctx(&ctx, ltt_alignof(data));
@@ -65,12 +70,13 @@ int lttng_create_kprobe_event(const char *name, struct ltt_event *event)
        }
        field->name = "ip";
        field->type.atype = atype_integer;
-       field->type.u.basic.integer.size = sizeof(unsigned long);
-       field->type.u.basic.integer.alignment = ltt_alignof(unsigned long);
-       field->type.u.basic.integer.signedness = 0;
+       field->type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       field->type.u.basic.integer.alignment = ltt_alignof(unsigned long) * CHAR_BIT;
+       field->type.u.basic.integer.signedness = is_signed_type(unsigned long);
        field->type.u.basic.integer.reverse_byte_order = 0;
        field->type.u.basic.integer.base = 16;
        field->type.u.basic.integer.encoding = lttng_encode_none;
+       desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
@@ -135,12 +141,17 @@ EXPORT_SYMBOL_GPL(lttng_kprobes_register);
 void lttng_kprobes_unregister(struct ltt_event *event)
 {
        unregister_kprobe(&event->u.kprobe.kp);
+}
+EXPORT_SYMBOL_GPL(lttng_kprobes_unregister);
+
+void lttng_kprobes_destroy_private(struct ltt_event *event)
+{
        kfree(event->u.kprobe.symbol_name);
        kfree(event->desc->fields);
        kfree(event->desc->name);
        kfree(event->desc);
 }
-EXPORT_SYMBOL_GPL(lttng_kprobes_unregister);
+EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_private);
 
 MODULE_LICENSE("GPL and additional rights");
 MODULE_AUTHOR("Mathieu Desnoyers");
This page took 0.024454 seconds and 4 git commands to generate.