Fix metadata, change ABI (for better future extensibility)
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 21 May 2011 20:42:36 +0000 (16:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 21 May 2011 20:42:36 +0000 (16:42 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/lttng.h
ltt-debugfs-abi.c
ltt-debugfs-abi.h
ltt-events.c
ltt-events.h

index 690b5df727dd337be38183a00561ef1af5756dee..2d40188a644199a7fa1e5105da2faba7d1aca82d 100644 (file)
@@ -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("")
index 046fca43cc4ee987ff2ee59a42d19296e0e7b190..4f283a1835a33475254bb330c79c90a1bda68c46 100644 (file)
@@ -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;
 }
 
index 85e689c88705928579383d4ad9ff1fd4b5f91ac3..d7d68926960d3a51a030d5179f83a4c063ed3436 100644 (file)
@@ -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 {
index 98cdf01f9d912071a38470ee602d954adf364c00..28d17fc772af2a89566468a992a73e1b494d5765 100644 (file)
@@ -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"
index d07f1c879d2d44e4a1fa76cf6da372e723d7b527..5fd0b67a0c5137cbbd0e68ad67fd1c3254e61302 100644 (file)
@@ -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);
 
This page took 0.030974 seconds and 4 git commands to generate.