Implement enable all vs enable tracepoints vs enable syscalls
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 30 Sep 2011 15:23:32 +0000 (11:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 30 Sep 2011 15:23:32 +0000 (11:23 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/quickstart.txt
include/lttng-kernel.h
include/lttng/lttng.h
ltt-sessiond/event.c
ltt-sessiond/event.h
ltt-sessiond/main.c
ltt-sessiond/trace-kernel.c
lttng/commands/enable_events.c
lttng/commands/list.c

index 5ba0cc54e247e7430cf849e8dc49d9e37cdc7f51..34f7e2059fbbc6ed6d00071bcbb0fe825c755897 100644 (file)
@@ -78,7 +78,7 @@ This is a new feature made possible by the new LTTng 2.0 kernel tracer. You can
 enable a dynamic probe and data will be output in the trace along side with
 your tracing data.
 
-# lttng enable-event aname -k --probe symbol+0xffff7260695
+# lttng enable-event aname -k --probe symbol+0x0
 
 or
 
index 475cde8cfd82dd267cc9e0fb98636d85a964af57..a62207209f6d8bba8f6215c46444b0d96782795c 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 enum lttng_kernel_instrumentation {
+       LTTNG_KERNEL_ALL           = -1,        /* Used within lttng-tools */
        LTTNG_KERNEL_TRACEPOINT    = 0,
        LTTNG_KERNEL_KPROBE        = 1,
        LTTNG_KERNEL_FUNCTION      = 2,
index bde46fa60337fb8ff07b2410e92478c5b167d5db..84f814793cf74352a992abc195b227620267df01 100644 (file)
@@ -61,12 +61,13 @@ enum lttng_domain_type {
  * Instrumentation type of tracing event.
  */
 enum lttng_event_type {
-       LTTNG_EVENT_TRACEPOINT,
-       LTTNG_EVENT_PROBE,
-       LTTNG_EVENT_FUNCTION,
-       LTTNG_EVENT_FUNCTION_ENTRY,
-       LTTNG_EVENT_NOOP,
-       LTTNG_EVENT_SYSCALL,
+       LTTNG_EVENT_ALL                       = -1,
+       LTTNG_EVENT_TRACEPOINT                = 0,
+       LTTNG_EVENT_PROBE                     = 1,
+       LTTNG_EVENT_FUNCTION                  = 2,
+       LTTNG_EVENT_FUNCTION_ENTRY            = 3,
+       LTTNG_EVENT_NOOP                      = 4,
+       LTTNG_EVENT_SYSCALL                   = 5,
 };
 
 /*
index dfafd88e8b2dc1625daae860a03aceafb811d20a..e8f54504cd1c7081e0b8fcce8fa5cec8a1075e70 100644 (file)
@@ -39,9 +39,9 @@ static void init_syscalls_kernel_event(struct lttng_event *event)
 }
 
 /*
- * Disable kernel event for a channel from the kernel session.
+ * Disable kernel tracepoint event for a channel from the kernel session.
  */
-int event_kernel_disable(struct ltt_kernel_session *ksession,
+int event_kernel_disable_tracepoint(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, char *event_name)
 {
        int ret;
@@ -69,9 +69,9 @@ error:
 }
 
 /*
- * Disable all kernel event for a channel from the kernel session.
+ * Disable kernel tracepoint events for a channel from the kernel session.
  */
-int event_kernel_disable_all(struct ltt_kernel_session *ksession,
+int event_kernel_disable_all_tracepoints(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan)
 {
        int ret;
@@ -85,16 +85,39 @@ int event_kernel_disable_all(struct ltt_kernel_session *ksession,
                        continue;
                }
        }
-
        ret = LTTCOMM_OK;
+       return ret;
+}
+
+/*
+ * Disable kernel syscall events for a channel from the kernel session.
+ */
+int event_kernel_disable_all_syscalls(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan)
+{
+       ERR("Cannot disable syscall tracing for existing session. Please destroy session instead.");
+       return LTTCOMM_OK;      /* Return OK so disable all succeeds */
+}
 
+/*
+ * Disable all kernel event for a channel from the kernel session.
+ */
+int event_kernel_disable_all(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan)
+{
+       int ret;
+
+       ret = event_kernel_disable_all_tracepoints(ksession, kchan);
+       if (ret != LTTCOMM_OK)
+               return ret;
+       ret = event_kernel_disable_all_syscalls(ksession, kchan);
        return ret;
 }
 
 /*
- * Enable kernel event for a channel from the kernel session.
+ * Enable kernel tracepoint event for a channel from the kernel session.
  */
-int event_kernel_enable(struct ltt_kernel_session *ksession,
+int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, struct lttng_event *event)
 {
        int ret;
@@ -105,26 +128,24 @@ int event_kernel_enable(struct ltt_kernel_session *ksession,
                ret = kernel_create_event(event, kchan);
                if (ret < 0) {
                        ret = LTTCOMM_KERN_ENABLE_FAIL;
-                       goto error;
+                       goto end;
                }
        } else if (kevent->enabled == 0) {
                ret = kernel_enable_event(kevent);
                if (ret < 0) {
                        ret = LTTCOMM_KERN_ENABLE_FAIL;
-                       goto error;
+                       goto end;
                }
        }
-
        ret = LTTCOMM_OK;
-
-error:
+end:
        return ret;
 }
 
 /*
- * Enable all kernel event of a channel of the kernel session.
+ * Enable all kernel tracepoint events of a channel of the kernel session.
  */
-int event_kernel_enable_all(struct ltt_kernel_session *ksession,
+int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
 {
        int size, i, ret;
@@ -143,7 +164,7 @@ int event_kernel_enable_all(struct ltt_kernel_session *ksession,
        size = kernel_list_events(kernel_tracer_fd, &event_list);
        if (size < 0) {
                ret = LTTCOMM_KERN_LIST_FAIL;
-               goto error;
+               goto end;
        }
 
        for (i = 0; i < size; i++) {
@@ -158,25 +179,17 @@ int event_kernel_enable_all(struct ltt_kernel_session *ksession,
                        }
                }
        }
-
        free(event_list);
-
-       /* Also enable syscalls when enabling all events */
-       ret = event_kernel_enable_syscalls(ksession, kchan, kernel_tracer_fd);
-       if (ret < 0) {
-               goto error;
-       }
-
        ret = LTTCOMM_OK;
-
-error:
+end:
        return ret;
+
 }
 
 /*
- * Enable all kernel syscalls tracing.
+ * Enable all kernel tracepoint events of a channel of the kernel session.
  */
-int event_kernel_enable_syscalls(struct ltt_kernel_session *ksession,
+int event_kernel_enable_all_syscalls(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
 {
        int ret;
@@ -188,11 +201,26 @@ int event_kernel_enable_syscalls(struct ltt_kernel_session *ksession,
 
        ret = kernel_create_event(&event, kchan);
        if (ret < 0) {
-               goto error;
+               goto end;
        }
-
        ret = LTTCOMM_OK;
+end:
+       return ret;
+}
 
-error:
+/*
+ * Enable all kernel events of a channel of the kernel session.
+ */
+int event_kernel_enable_all(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
+{
+       int ret;
+
+       ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+       if (ret != LTTCOMM_OK) {
+               goto end;
+       }
+       ret = event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+end:
        return ret;
 }
index 0ef52fe7b272eb76993e2e9cea8a00f1627b3858..38768c51a9a66d242c754b1efc684de80ee6202e 100644 (file)
 
 #include "trace-kernel.h"
 
-int event_kernel_disable(struct ltt_kernel_session *ksession,
+int event_kernel_disable_tracepoint(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, char *event_name);
+int event_kernel_disable_all_syscalls(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan);
+int event_kernel_disable_all_tracepoints(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan);
 int event_kernel_disable_all(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan);
-int event_kernel_enable(struct ltt_kernel_session *ksession,
+
+int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, struct lttng_event *event);
-int event_kernel_enable_all(struct ltt_kernel_session *ksession,
+int event_kernel_enable_all_tracepoints(struct ltt_kernel_session *ksession,
+               struct ltt_kernel_channel *kchan, int kernel_tracer_fd);
+int event_kernel_enable_all_syscalls(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd);
-int event_kernel_enable_syscalls(struct ltt_kernel_session *ksession,
+int event_kernel_enable_all(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd);
 
 #endif /* _LTT_EVENT_H */
index e1bf1e416b49be23b8ca860d21062249b70a01df..7532e2c3bdde96e18c6d82772bf2b9ae3fbb146c 100644 (file)
@@ -1739,6 +1739,9 @@ static void list_lttng_events(struct ltt_kernel_channel *kchan,
                        case LTTNG_KERNEL_SYSCALL:
                                events[i].type = LTTNG_EVENT_SYSCALL;
                                break;
+                       case LTTNG_KERNEL_ALL:
+                               assert(0);
+                               break;
                }
                i++;
        }
@@ -1910,7 +1913,7 @@ static int cmd_disable_event(struct ltt_session *session, int domain,
                        goto error;
                }
 
-               ret = event_kernel_disable(session->kernel_session, kchan, event_name);
+               ret = event_kernel_disable_tracepoint(session->kernel_session, kchan, event_name);
                if (ret != LTTCOMM_OK) {
                        goto error;
                }
@@ -2027,7 +2030,7 @@ static int cmd_enable_event(struct ltt_session *session, int domain,
                        goto error;
                }
 
-               ret = event_kernel_enable(session->kernel_session, kchan, event);
+               ret = event_kernel_enable_tracepoint(session->kernel_session, kchan, event);
                if (ret != LTTCOMM_OK) {
                        goto error;
                }
@@ -2077,18 +2080,28 @@ static int cmd_enable_event_all(struct ltt_session *session, int domain,
                        goto error;
                }
 
-               if (event_type == LTTNG_KERNEL_SYSCALL) {
-                       ret = event_kernel_enable_syscalls(session->kernel_session,
+               switch (event_type) {
+               case LTTNG_KERNEL_SYSCALL:
+                       ret = event_kernel_enable_all_syscalls(session->kernel_session,
                                        kchan, kernel_tracer_fd);
-               } else {
+                       break;
+               case LTTNG_KERNEL_TRACEPOINT:
                        /*
-                        * This call enables all LTTNG_KERNEL_TRACEPOINTS and events
-                        * already registered to the channel.
+                        * This call enables all LTTNG_KERNEL_TRACEPOINTS and
+                        * events already registered to the channel.
                         */
+                       ret = event_kernel_enable_all_tracepoints(session->kernel_session,
+                                       kchan, kernel_tracer_fd);
+                       break;
+               case LTTNG_KERNEL_ALL:
+                       /* Enable syscalls and tracepoints */
                        ret = event_kernel_enable_all(session->kernel_session,
                                        kchan, kernel_tracer_fd);
+                       break;
+               default:
+                       ret = LTTCOMM_KERN_ENABLE_FAIL;
+                       goto error;
                }
-
                if (ret != LTTCOMM_OK) {
                        goto error;
                }
index 37d9d143a17c6439345c28ac97e976a8a2e2c575..fa3ba692c828669e3d1edfa37a9645074602437a 100644 (file)
@@ -207,6 +207,9 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev)
        case LTTNG_EVENT_SYSCALL:
                attr->instrumentation = LTTNG_KERNEL_SYSCALL;
                break;
+       case LTTNG_EVENT_ALL:
+               attr->instrumentation = LTTNG_KERNEL_ALL;
+               break;
        default:
                ERR("Unknown kernel instrumentation type (%d)", ev->type);
                goto error;
index 78227be1fdcff05cf2102a468b62404913390d52..fbcd40dafac36d388e79fa2bc6f34d3194bac468 100644 (file)
@@ -225,7 +225,7 @@ static int enable_events(char *session_name)
                switch (opt_event_type) {
                case LTTNG_EVENT_TRACEPOINT:
                        if (opt_kernel) {
-                               MSG("All kernel events are enabled in channel %s",
+                               MSG("All kernel tracepoints are enabled in channel %s",
                                                channel_name);
                        }
                        break;
@@ -235,6 +235,12 @@ static int enable_events(char *session_name)
                                                channel_name);
                        }
                        break;
+               case LTTNG_EVENT_ALL:
+                       if (opt_kernel) {
+                               MSG("All kernel events are enabled in channel %s",
+                                               channel_name);
+                       }
+                       break;
                default:
                        /*
                         * We should not be here since lttng_enable_event should had failed
@@ -260,6 +266,9 @@ static int enable_events(char *session_name)
                        ev.type = opt_event_type;
 
                        switch (opt_event_type) {
+                       case LTTNG_EVENT_ALL:   /* Default behavior is tracepoint */
+                               ev.type = LTTNG_EVENT_TRACEPOINT;
+                               /* Fall-through */
                        case LTTNG_EVENT_TRACEPOINT:
                                break;
                        case LTTNG_EVENT_PROBE:
@@ -340,7 +349,7 @@ int cmd_enable_events(int argc, const char **argv)
        poptReadDefaultConfig(pc, 0);
 
        /* Default event type */
-       opt_event_type = LTTNG_EVENT_TRACEPOINT;
+       opt_event_type = LTTNG_EVENT_ALL;
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
                switch (opt) {
index c73ea74dc457f504775abede040a1a3cceb7aec4..6afec1876c23b01ec24a878b724d0f8a0c2a5e08 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include "../cmd.h"
 
@@ -185,6 +186,10 @@ static int list_events(const char *channel_name)
                                MSG("%s (type: noop) [enabled: %d]", indent6,
                                                events[i].enabled);
                                break;
+                       case LTTNG_EVENT_ALL:
+                               /* We should never have "all" events in list. */
+                               assert(0);
+                               break;
                }
        }
 
This page took 0.033754 seconds and 4 git commands to generate.