Fix tracing events data structure
authorDavid Goulet <david.goulet@polymtl.ca>
Mon, 18 Jul 2011 14:37:48 +0000 (10:37 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Mon, 18 Jul 2011 14:41:32 +0000 (10:41 -0400)
Make lttng_kernel_output generic to user-space and kernel becoming
lttng_event_output.

Renaming enum to fit kernel ABI.

Add comments.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
include/lttng-kernel.h
include/lttng-share.h
include/lttng/lttng.h
ltt-sessiond/main.c
ltt-sessiond/trace.c
lttng/commands/enable_events.c

index 6fa4e3925e562726c3ec184405ea4df4ff693398..3259bff84d8b8821b42e0a978a030ff3b1cb8920 100644 (file)
 #define LTTNG_SYM_NAME_LEN  128
 
 enum lttng_kernel_instrumentation {
-       LTTNG_KERNEL_TRACEPOINTS,
-       LTTNG_KERNEL_KPROBES,
-       LTTNG_KERNEL_FUNCTION,
+       LTTNG_KERNEL_TRACEPOINT    = 0,
+       LTTNG_KERNEL_KPROBE        = 1,
+       LTTNG_KERNEL_FUNCTION      = 2,
+};
+
+/*
+ * LTTng consumer mode
+ */
+enum lttng_kernel_output {
+       LTTNG_KERNEL_SPLICE       = 0,
+       LTTNG_KERNEL_MMAP         = 1,
 };
 
 /*
index 825456c563cc11077e2c9b88ecc95010f8a9b564..30aa23cd36bce080538f3c2c86248ab0dbaf07fe 100644 (file)
@@ -38,9 +38,12 @@ typedef __s64 s64;
 #define DEFAULT_CHANNEL_SUBBUF_NUM          8
 #define DEFAULT_CHANNEL_SWITCH_TIMER        0       /* usec */
 #define DEFAULT_CHANNEL_READ_TIMER          200     /* usec */
-/* See lttng.h enum lttng_kernel_output for channel output */
+/* See lttng-kernel.h enum lttng_kernel_output for channel output */
 #define DEFAULT_KERNEL_CHANNEL_OUTPUT       LTTNG_KERNEL_SPLICE
+
+/* == NOT IMPLEMENTED ==
 #define DEFAULT_UST_CHANNEL_OUTPUT          LTTNG_UST_MMAP
+*/
 
 /*
  * lttng user-space instrumentation type
index b5b799fc60c32e965f72b027e52d6c248a1f1723..448bd9fdcf944f432a757a7622286a3c3323bdaf 100644 (file)
 #define LTTNG_DEFAULT_TRACE_DIR_NAME "lttng-traces"
 
 /*
- * Event symbol length.
+ * Event symbol length. Copied from LTTng kernel ABI.
  */
 #define LTTNG_SYMBOL_NAME_LEN 128
 
+/*
+ * Every lttng_event_* structure both apply to kernel event and user-space
+ * event.
+ *
+ * Every lttng_kernel_* is copied from the LTTng kernel ABI.
+ */
+
 enum lttng_event_type {
-       LTTNG_EVENT_TRACEPOINTS,
-       LTTNG_EVENT_KPROBES,
+       LTTNG_EVENT_TRACEPOINT,
+       LTTNG_EVENT_KPROBE,
        LTTNG_EVENT_FUNCTION,
 };
 
+/*
+ * LTTng consumer mode
+ */
+enum lttng_event_output {
+       /* Using splice(2) */
+       LTTNG_EVENT_SPLICE       = 0,
+       /* Using mmap(2) */
+       LTTNG_EVENT_MMAP         = 1,
+};
+
 /* Kernel context possible type */
 enum lttng_kernel_context_type {
        LTTNG_KERNEL_CONTEXT_PID                = 0,
@@ -76,14 +93,6 @@ struct lttng_kernel_context {
        } u;
 };
 
-/*
- * LTTng consumer mode
- */
-enum lttng_kernel_output {
-       LTTNG_KERNEL_SPLICE       = 0,
-       LTTNG_KERNEL_MMAP         = 1,
-};
-
 /*
  * Either addr is used or symbol_name and offset.
  */
@@ -114,28 +123,37 @@ struct lttng_event {
        } attr;
 };
 
-/* Tracer channel attributes */
+/*
+ * Tracer channel attributes. For both kernel and user-space.
+ */
 struct lttng_channel_attr {
        int overwrite;                      /* 1: overwrite, 0: discard */
        uint64_t subbuf_size;               /* bytes */
        uint64_t num_subbuf;                /* power of 2 */
        unsigned int switch_timer_interval; /* usec */
        unsigned int read_timer_interval;   /* usec */
-       enum lttng_kernel_output output;    /* splice, mmap */
+       enum lttng_event_output output;    /* splice, mmap */
 };
 
 /*
- * Basic session information.
+ * Channel information structure. For both kernel and user-space.
  */
-struct lttng_session {
+struct lttng_channel {
        char name[NAME_MAX];
-       char path[PATH_MAX];
+       struct lttng_channel_attr attr;
 };
 
-/* Channel information structure */
-struct lttng_channel {
+/*
+ * Basic session information.
+ *
+ * This is an 'output data' meaning that it only comes *from* the session
+ * daemon *to* the lttng client. It's basically a 'human' representation of
+ * tracing entities (here a session).
+ */
+struct lttng_session {
        char name[NAME_MAX];
-       struct lttng_channel_attr attr;
+       /* The path where traces are written */
+       char path[PATH_MAX];
 };
 
 /*
@@ -149,7 +167,9 @@ extern int lttng_destroy_session(char *name);
 
 extern int lttng_disconnect_sessiond(void);
 
-/* Return an allocated array of lttng_session */
+/*
+ * Return a "lttng_session" array. Caller must free(3) the returned data.
+ */
 extern int lttng_list_sessions(struct lttng_session **sessions);
 
 extern int lttng_session_daemon_alive(void);
@@ -165,8 +185,6 @@ extern int lttng_start_tracing(char *session_name);
 
 extern int lttng_stop_tracing(char *session_name);
 
-//extern int lttng_ust_list_traceable_apps(pid_t **pids);
-
 /*
  * LTTng Kernel tracer control
  */
@@ -189,4 +207,6 @@ extern int lttng_kernel_list_events(char **event_list);
  * LTTng User-space tracer control
  */
 
+//extern int lttng_ust_list_traceable_apps(pid_t **pids);
+
 #endif /* _LTTNG_H */
index f99513a2bf60b0f7c2a67308ce4041e1ccbe11d6..39dfbc41d9254e27dd3a3ea4262e78608ce82126 100644 (file)
@@ -1663,7 +1663,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                        if (ev == NULL) {
                                strncpy(ev_attr.name, event, LTTNG_SYM_NAME_LEN);
                                /* Default event type for enable all */
-                               ev_attr.type = LTTNG_EVENT_TRACEPOINTS;
+                               ev_attr.type = LTTNG_EVENT_TRACEPOINT;
                                /* Enable each single tracepoint event */
                                ret = kernel_create_event(&ev_attr, chan);
                                if (ret < 0) {
index 25276696a87bcb3ba5300d98a161ae37b66e7153..e0aeac685e28a312b71fc773fa4ab05ca3eccb89 100644 (file)
@@ -175,8 +175,8 @@ struct ltt_kernel_event *trace_create_kernel_event(struct lttng_event *ev)
        }
 
        switch (ev->type) {
-       case LTTNG_EVENT_KPROBES:
-               attr->instrumentation = LTTNG_KERNEL_KPROBES;
+       case LTTNG_EVENT_KPROBE:
+               attr->instrumentation = LTTNG_KERNEL_KPROBE;
                attr->u.kprobe.addr = ev->attr.kprobe.addr;
                attr->u.kprobe.offset = ev->attr.kprobe.offset;
                strncpy(attr->u.kprobe.symbol_name,
@@ -187,8 +187,8 @@ struct ltt_kernel_event *trace_create_kernel_event(struct lttng_event *ev)
                strncpy(attr->u.ftrace.symbol_name,
                                ev->attr.ftrace.symbol_name, LTTNG_SYM_NAME_LEN);
                break;
-       case LTTNG_EVENT_TRACEPOINTS:
-               attr->instrumentation = LTTNG_KERNEL_TRACEPOINTS;
+       case LTTNG_EVENT_TRACEPOINT:
+               attr->instrumentation = LTTNG_KERNEL_TRACEPOINT;
                break;
        default:
                ERR("Unknown kernel instrumentation type (%d)", ev->type);
index ce8d6024155e6dea7c7a2b696ac60cf521e48fe0..65bd19575950be32af3ec3154857ff16b784fe2c 100644 (file)
@@ -191,13 +191,13 @@ static int enable_events(void)
                        ev.type = opt_event_type;
 
                        switch (opt_event_type) {
-                       case LTTNG_EVENT_TRACEPOINTS:
+                       case LTTNG_EVENT_TRACEPOINT:
                                ret = lttng_kernel_enable_event(&ev, channel_name);
                                if (ret < 0) {
                                        ERR("Unable to find event %s", ev.name);
                                }
                                break;
-                       case LTTNG_EVENT_KPROBES:
+                       case LTTNG_EVENT_KPROBE:
                                ret = parse_kprobe_opts(&ev, opt_kprobe);
                                if (ret < 0) {
                                        ERR("Unable to parse kprobe options");
@@ -258,7 +258,7 @@ int cmd_enable_events(int argc, const char **argv)
        poptReadDefaultConfig(pc, 0);
 
        /* Default event type */
-       opt_event_type = LTTNG_KERNEL_TRACEPOINTS;
+       opt_event_type = LTTNG_EVENT_TRACEPOINT;
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
@@ -271,13 +271,13 @@ int cmd_enable_events(int argc, const char **argv)
                        opt_cmd_name = poptGetOptArg(pc);
                        break;
                case OPT_TRACEPOINT:
-                       opt_event_type = LTTNG_EVENT_TRACEPOINTS;
+                       opt_event_type = LTTNG_EVENT_TRACEPOINT;
                        break;
                case OPT_MARKER:
                        ret = CMD_NOT_IMPLEMENTED;
                        goto end;
                case OPT_KPROBE:
-                       opt_event_type = LTTNG_EVENT_KPROBES;
+                       opt_event_type = LTTNG_EVENT_KPROBE;
                        opt_kprobe = poptGetOptArg(pc);
                        break;
                case OPT_FUNCTION:
This page took 0.030018 seconds and 4 git commands to generate.