From: Mathieu Desnoyers Date: Sat, 21 May 2011 20:42:36 +0000 (-0400) Subject: Fix metadata, change ABI (for better future extensibility) X-Git-Tag: v2.0-pre1~124 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=30bdb6e41d33f7ce7b4eb51f363423c1dc9fd88e;p=lttng-modules.git Fix metadata, change ABI (for better future extensibility) Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/events/lttng-module/lttng.h b/instrumentation/events/lttng-module/lttng.h index 690b5df7..2d40188a 100644 --- a/instrumentation/events/lttng-module/lttng.h +++ b/instrumentation/events/lttng-module/lttng.h @@ -13,11 +13,11 @@ TRACE_EVENT(lttng_metadata, TP_ARGS(str), TP_STRUCT__entry( - __string( string, str ) + __string( str, str ) ), TP_fast_assign( - tp_strcpy(string, str) + tp_strcpy(str, str) ), TP_printk("") diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index 046fca43..4f283a18 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -146,7 +146,6 @@ void lttng_metadata_create_events(struct file *channel_file) .instrumentation = LTTNG_KERNEL_TRACEPOINTS, .name = "lttng_metadata", }; - char *event_name = "lttng_metadata"; struct ltt_event *event; int ret; @@ -154,7 +153,7 @@ void lttng_metadata_create_events(struct file *channel_file) * 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, &metadata_params, NULL); + event = ltt_event_create(channel, &metadata_params, NULL); if (!event) { goto create_error; ret = -EEXIST; @@ -355,21 +354,13 @@ int lttng_abi_create_event(struct file *channel_file, { struct ltt_channel *channel = channel_file->private_data; struct ltt_event *event; - char *event_name; struct lttng_kernel_event event_param; int event_fd, ret; struct file *event_file; if (copy_from_user(&event_param, uevent_param, sizeof(event_param))) return -EFAULT; - event_name = kmalloc(PATH_MAX, GFP_KERNEL); - if (!event_name) - return -ENOMEM; - if (strncpy_from_user(event_name, uevent_param->name, PATH_MAX) < 0) { - ret = -EFAULT; - goto name_error; - } - event_name[PATH_MAX - 1] = '\0'; + event_param.name[LTTNG_SYM_NAME_LEN - 1] = '\0'; switch (event_param.instrumentation) { case LTTNG_KERNEL_KPROBES: event_param.u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0'; @@ -396,7 +387,7 @@ int lttng_abi_create_event(struct file *channel_file, * 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, NULL); + event = ltt_event_create(channel, &event_param, NULL); if (!event) { ret = -EEXIST; goto event_error; @@ -405,7 +396,6 @@ int lttng_abi_create_event(struct file *channel_file, fd_install(event_fd, event_file); /* The event holds a reference on the channel */ atomic_long_inc(&channel_file->f_count); - kfree(event_name); return event_fd; event_error: @@ -413,8 +403,6 @@ event_error: file_error: put_unused_fd(event_fd); fd_error: -name_error: - kfree(event_name); return ret; } diff --git a/ltt-debugfs-abi.h b/ltt-debugfs-abi.h index 85e689c8..d7d68926 100644 --- a/ltt-debugfs-abi.h +++ b/ltt-debugfs-abi.h @@ -31,6 +31,9 @@ struct lttng_kernel_channel { unsigned int read_timer_interval; /* usecs */ }; +struct lttng_kernel_tracepoint { +}; + /* * Either addr is used, or symbol_name and offset. */ @@ -46,13 +49,14 @@ struct lttng_kernel_function_tracer { }; struct lttng_kernel_event { + char name[LTTNG_SYM_NAME_LEN]; /* event name */ enum lttng_kernel_instrumentation instrumentation; /* Per instrumentation type configuration */ union { + struct lttng_kernel_tracepoint tracepoint; struct lttng_kernel_kprobe kprobe; struct lttng_kernel_function_tracer ftrace; } u; - char name[]; /* event name */ }; struct lttng_kernel_tracer_version { diff --git a/ltt-events.c b/ltt-events.c index 98cdf01f..28d17fc7 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -203,7 +203,7 @@ void _ltt_channel_destroy(struct ltt_channel *chan) /* * Supports event creation while tracing session is active. */ -struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name, +struct ltt_event *ltt_event_create(struct ltt_channel *chan, struct lttng_kernel_event *event_param, void *filter) { @@ -218,7 +218,7 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name, * creation). Might require a hash if we have lots of events. */ list_for_each_entry(event, &chan->session->events, list) - if (!strcmp(event->desc->name, name)) + if (!strcmp(event->desc->name, event_param->name)) goto exist; event = kmem_cache_zalloc(event_cache, GFP_KERNEL); if (!event) @@ -231,17 +231,17 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name, smp_wmb(); switch (event_param->instrumentation) { case LTTNG_KERNEL_TRACEPOINTS: - event->desc = ltt_event_get(name); + event->desc = ltt_event_get(event_param->name); if (!event->desc) goto register_error; - ret = tracepoint_probe_register(name, + ret = tracepoint_probe_register(event_param->name, event->desc->probe_callback, event); if (ret) goto register_error; break; case LTTNG_KERNEL_KPROBES: - ret = lttng_kprobes_register(name, + ret = lttng_kprobes_register(event_param->name, event_param->u.kprobe.symbol_name, event_param->u.kprobe.offset, event_param->u.kprobe.addr, @@ -250,7 +250,7 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name, goto register_error; break; case LTTNG_KERNEL_FUNCTION_TRACER: - ret = lttng_ftrace_register(name, + ret = lttng_ftrace_register(event_param->name, event_param->u.ftrace.symbol_name, event); if (ret) @@ -267,7 +267,7 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name, return event; statedump_error: - WARN_ON_ONCE(tracepoint_probe_unregister(name, + WARN_ON_ONCE(tracepoint_probe_unregister(event_param->name, event->desc->probe_callback, event)); ltt_event_put(event->desc); @@ -642,7 +642,8 @@ int _ltt_event_header_declare(struct ltt_session *session) static int _ltt_session_metadata_statedump(struct ltt_session *session) { - char uuid_s[37]; + unsigned char *uuid_c = session->uuid.b; + unsigned char uuid_s[37]; struct ltt_channel *chan; struct ltt_event *event; int ret = 0; @@ -657,11 +658,11 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) } snprintf(uuid_s, sizeof(uuid_s), - "%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x", - uuid_s[0], uuid_s[1], uuid_s[2], uuid_s[3], - uuid_s[4], uuid_s[5], uuid_s[6], uuid_s[7], - uuid_s[8], uuid_s[9], uuid_s[10], uuid_s[11], - uuid_s[12], uuid_s[13], uuid_s[14], uuid_s[15]); + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid_c[0], uuid_c[1], uuid_c[2], uuid_c[3], + uuid_c[4], uuid_c[5], uuid_c[6], uuid_c[7], + uuid_c[8], uuid_c[9], uuid_c[10], uuid_c[11], + uuid_c[12], uuid_c[13], uuid_c[14], uuid_c[15]); ret = lttng_metadata_printf(session, "typealias integer { size = 8; align = %u; signed = false; } := uint8_t;\n" @@ -674,7 +675,7 @@ int _ltt_session_metadata_statedump(struct ltt_session *session) "trace {\n" " major = %u;\n" " minor = %u;\n" - " uuid = %s;\n" + " uuid = \"%s\";\n" " byte_order = %s;\n" " packet.header := struct {\n" " uint32_t magic;\n" diff --git a/ltt-events.h b/ltt-events.h index d07f1c87..5fd0b67a 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -50,7 +50,7 @@ struct lttng_enum_entry { .atype = atype_integer, \ .u.basic.integer = \ { \ - .size = sizeof(_type), \ + .size = sizeof(_type) * CHAR_BIT, \ .alignment = ltt_alignof(_type) * CHAR_BIT, \ .signedness = is_signed_type(_type), \ .reverse_byte_order = _byte_order != __BYTE_ORDER, \ @@ -244,7 +244,6 @@ struct ltt_channel *ltt_global_channel_create(struct ltt_session *session, unsigned int read_timer_interval); struct ltt_event *ltt_event_create(struct ltt_channel *chan, - char *name, struct lttng_kernel_event *event_param, void *filter);