{
struct ltt_channel *channel = channel_file->private_data;
char *event_name = "lttng_metadata";
- const struct lttng_event_desc *event_desc;
struct ltt_event *event;
int ret;
- event_desc = ltt_event_get(event_name);
- if (!event_desc) {
- ret = -ENOENT;
- goto get_error;
- }
/*
* We tolerate no failure path after event creation. It will stay
* invariant for the rest of the session.
*/
event = ltt_event_create(channel, event_name, LTTNG_KERNEL_TRACEPOINTS,
- event_desc, NULL);
+ NULL);
if (!event) {
goto create_error;
ret = -EEXIST;
return;
create_error:
- ltt_event_put(event_desc);
-get_error:
WARN_ON(1);
return; /* not allowed to return error */
}
struct lttng_kernel_event __user *uevent_param)
{
struct ltt_channel *channel = channel_file->private_data;
- const struct lttng_event_desc *event_desc;
struct ltt_event *event;
char *event_name;
struct lttng_kernel_event event_param;
goto name_error;
}
event_name[PATH_MAX - 1] = '\0';
+ event_param.u.kprobe.symbol_name[LTTNG_KPROBE_SYM_NAME_LEN - 1] = '\0';
- event_desc = ltt_event_get(event_name);
- if (!event_desc) {
- ret = -ENOENT;
- goto get_error;
- }
event_fd = get_unused_fd();
if (event_fd < 0) {
ret = event_fd;
* We tolerate no failure path after event creation. It will stay
* invariant for the rest of the session.
*/
- event = ltt_event_create(channel, event_name, &event_param,
- event_desc, NULL);
+ event = ltt_event_create(channel, event_name, &event_param, NULL);
if (!event) {
ret = -EEXIST;
goto event_error;
file_error:
put_unused_fd(event_fd);
fd_error:
- ltt_event_put(event_desc);
-get_error:
name_error:
kfree(event_name);
return ret;
*/
struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
struct lttng_kernel_event *event_param,
- const struct lttng_event_desc *event_desc,
void *filter)
{
struct ltt_event *event;
if (!event)
goto cache_error;
event->chan = chan;
- event->desc = event_desc;
event->filter = filter;
event->id = chan->free_event_id++;
event->instrumentation = event_param->instrumentation;
smp_wmb();
switch (event_param->instrumentation) {
case LTTNG_KERNEL_TRACEPOINTS:
- ret = tracepoint_probe_register(name, event_desc->probe_callback,
- event);
+ event->desc = ltt_event_get(name);
+ if (!event->desc)
+ goto register_error;
+ ret = tracepoint_probe_register(name,
+ event->desc->probe_callback,
+ event);
if (ret)
goto register_error;
break;
return event;
statedump_error:
- WARN_ON_ONCE(tracepoint_probe_unregister(name, event_desc->probe_callback,
- event));
+ WARN_ON_ONCE(tracepoint_probe_unregister(name,
+ event->desc->probe_callback,
+ event));
+ ltt_event_put(event->desc);
register_error:
kmem_cache_free(event_cache, event);
cache_error:
event);
if (ret)
return ret;
+ ltt_event_put(event->desc);
break;
case LTTNG_KERNEL_KPROBES:
lttng_kprobes_unregister(event);
struct ltt_event {
unsigned int id;
struct ltt_channel *chan;
- struct lttng_event_desc *desc;
+ const struct lttng_event_desc *desc;
void *filter;
enum lttng_kernel_instrumentation instrumentation;
union {
struct ltt_event *ltt_event_create(struct ltt_channel *chan,
char *name,
struct lttng_kernel_event *event_param,
- const struct lttng_event_desc *event_desc,
void *filter);
int ltt_event_unregister(struct ltt_event *event);
int lttng_create_kprobe_event(const char *name, struct ltt_event *event)
{
struct lttng_event_field *field;
+ struct lttng_event_desc *desc;
int ret;
- event->desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
- if (!event->desc)
+ desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+ if (!desc)
return -ENOMEM;
- event->desc->name = kstrdup(name, GFP_KERNEL);
- if (!event->desc->name) {
+ desc->name = kstrdup(name, GFP_KERNEL);
+ if (!desc->name) {
ret = -ENOMEM;
goto error_str;
}
- event->desc->nr_fields = 1;
- event->desc->fields = field =
+ desc->nr_fields = 1;
+ desc->fields = field =
kzalloc(1 * sizeof(struct lttng_event_field), GFP_KERNEL);
field->name = "ip";
field->type.atype = atype_integer;
field->type.u.basic.integer.alignment = ltt_alignof(unsigned long);
field->type.u.basic.integer.signedness = 0;
field->type.u.basic.integer.reverse_byte_order = 0;
+ event->desc = desc;
return 0;
error_str:
- kfree(event->desc);
+ kfree(desc);
return ret;
}