Add support for --syscalls
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 16 Sep 2011 23:33:28 +0000 (19:33 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 16 Sep 2011 23:33:28 +0000 (19:33 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng-kernel.h
include/lttng/lttng.h
liblttngctl/lttngctl.c
ltt-sessiond/main.c
ltt-sessiond/trace-kernel.c
lttng/commands/calibrate.c
lttng/commands/enable_events.c
lttng/commands/list.c

index 394962054877f751a653050013a7b448e64a70b1..20b788fc17dc6db1ffe87036861c675ad40df4ee 100644 (file)
@@ -38,6 +38,8 @@ enum lttng_kernel_instrumentation {
        LTTNG_KERNEL_KPROBE        = 1,
        LTTNG_KERNEL_FUNCTION      = 2,
        LTTNG_KERNEL_KRETPROBE     = 3,
+       LTTNG_KERNEL_NOOP          = 4,    /* not hooked */
+       LTTNG_KERNEL_SYSCALLS      = 5,
 };
 
 enum lttng_kernel_context_type {
index 3e5b055625b332772b502160a248b96ea7c01ccb..efb67fa697c5578af761ff2ee9e16b4274fc0c34 100644 (file)
@@ -65,6 +65,8 @@ enum lttng_event_type {
        LTTNG_EVENT_PROBE,
        LTTNG_EVENT_FUNCTION,
        LTTNG_EVENT_FUNCTION_ENTRY,
+       LTTNG_EVENT_NOOP,
+       LTTNG_EVENT_SYSCALLS,
 };
 
 /*
index 4b803dc5b06e4ee76a56caf388d6af3b7911cd18..26b721e9928e469dd57e6ba09a696542c87fd799 100644 (file)
@@ -506,7 +506,7 @@ int lttng_enable_event(struct lttng_handle *handle,
 
        copy_lttng_domain(&lsm.domain, &handle->domain);
 
-       if (ev) {
+       if (ev || ev->name[0] != '\0') {
                lsm.cmd_type = LTTNG_ENABLE_EVENT;
                memcpy(&lsm.u.enable.event, ev, sizeof(lsm.u.enable.event));
        } else {
index 97569f6d1179a4dd13a6470eff04e4380fea8dc4..5a0ad0b8aaaca228b3cb27efaedbd881fe8a1210 100644 (file)
@@ -1713,6 +1713,12 @@ static void list_lttng_events(struct ltt_kernel_channel *kchan,
                                memcpy(&events[i].attr.ftrace, &event->event->u.ftrace,
                                                sizeof(struct lttng_kernel_function));
                                break;
+                       case LTTNG_KERNEL_NOOP:
+                               events[i].type = LTTNG_EVENT_NOOP;
+                               break;
+                       case LTTNG_KERNEL_SYSCALLS:
+                               events[i].type = LTTNG_EVENT_SYSCALLS;
+                               break;
                }
                i++;
        }
index 57a9eb42dffae62be66c6ef0286219dd50bc8b1b..b84021262af7bbf88eec46f5a0df96b788274fb6 100644 (file)
@@ -204,6 +204,9 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev)
        case LTTNG_EVENT_TRACEPOINT:
                attr->instrumentation = LTTNG_KERNEL_TRACEPOINT;
                break;
+       case LTTNG_EVENT_SYSCALLS:
+               attr->instrumentation = LTTNG_KERNEL_SYSCALLS;
+               break;
        default:
                ERR("Unknown kernel instrumentation type (%d)", ev->type);
                goto error;
index b4d0fe04537c8be1cb1212b34ae5aca8bf739381..bcddc5e8bfefb9f674d6009c60809851260e980c 100644 (file)
@@ -47,6 +47,7 @@ enum {
        OPT_PROBE,
        OPT_FUNCTION,
        OPT_FUNCTION_ENTRY,
+       OPT_SYSCALLS,
 };
 
 static struct lttng_handle *handle;
@@ -63,6 +64,7 @@ static struct poptOption long_options[] = {
        {"probe",          0,   POPT_ARG_NONE, 0, OPT_PROBE, 0, 0},
        {"function",       0,   POPT_ARG_NONE, 0, OPT_FUNCTION, 0, 0},
        {"function:entry", 0,   POPT_ARG_NONE, 0, OPT_FUNCTION_ENTRY, 0, 0},
+       {"syscalls",       0,   POPT_ARG_NONE, 0, OPT_SYSCALLS, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -87,6 +89,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "                           Dynamic function entry/return probe.\n");
        fprintf(ofp, "    --function:entry symbol\n");
        fprintf(ofp, "                           Function tracer event\n");
+       fprintf(ofp, "    --syscalls             System calls\n");
        fprintf(ofp, "    --marker               User-space marker (deprecated)\n");
        fprintf(ofp, "\n");
 }
@@ -130,6 +133,9 @@ static int calibrate_lttng(void)
                case LTTNG_EVENT_FUNCTION_ENTRY:
                        DBG("Calibrating kernel function entry");
                        break;
+               case LTTNG_EVENT_SYSCALLS:
+                       DBG("Calibrating kernel syscalls");
+                       break;
                default:
                        ret = CMD_NOT_IMPLEMENTED;
                        goto end;
@@ -194,6 +200,9 @@ int cmd_calibrate(int argc, const char **argv)
                case OPT_FUNCTION_ENTRY:
                        ret = CMD_NOT_IMPLEMENTED;
                        break;
+               case OPT_SYSCALLS:
+                       ret = CMD_NOT_IMPLEMENTED;
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index f6bca6e94823fd28e997614ba55bf67b499b7ba7..0d47b6291cec082cd469011157294dcda8ab107d 100644 (file)
@@ -53,6 +53,7 @@ enum {
        OPT_PROBE,
        OPT_FUNCTION,
        OPT_FUNCTION_ENTRY,
+       OPT_SYSCALLS,
 };
 
 static struct lttng_handle *handle;
@@ -72,6 +73,7 @@ static struct poptOption long_options[] = {
        {"probe",         0,   POPT_ARG_STRING, 0, OPT_PROBE, 0, 0},
        {"function",       0,   POPT_ARG_STRING, 0, OPT_FUNCTION, 0, 0},
        {"function:entry", 0,   POPT_ARG_STRING, 0, OPT_FUNCTION_ENTRY, 0, 0},
+       {"syscalls",     0,     POPT_ARG_NONE, 0, OPT_SYSCALLS, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
 };
 
@@ -103,6 +105,7 @@ static void usage(FILE *ofp)
        fprintf(ofp, "                           decimal (NNN...) or hexadecimal (0xNNN...)\n");
        fprintf(ofp, "    --function:entry symbol\n");
        fprintf(ofp, "                           Function tracer event\n");
+       fprintf(ofp, "    --syscalls             System calls\n");
        fprintf(ofp, "    --marker               User-space marker (deprecated)\n");
        fprintf(ofp, "\n");
 }
@@ -210,15 +213,33 @@ static int enable_events(char *session_name)
        }
 
        if (opt_enable_all) {
-               if (opt_kernel) {
-                       ret = lttng_enable_event(handle, NULL, channel_name);
-                       if (ret == 0) {
-                               MSG("All kernel events are enabled in channel %s", channel_name);
+               switch (opt_event_type) {
+               case LTTNG_EVENT_TRACEPOINT:
+                       if (opt_kernel) {
+                               ret = lttng_enable_event(handle, NULL, channel_name);
+                               if (ret == 0) {
+                                       MSG("All kernel events are enabled in channel %s", channel_name);
+                               }
+                               goto error;
+                       }
+                       /* TODO: User-space tracer */
+                       break;
+               case LTTNG_EVENT_SYSCALLS:
+                       if (opt_kernel) {
+                               ev.name[0] = '\0';
+                               ev.type = opt_event_type;
+
+                               ret = lttng_enable_event(handle, &ev, channel_name);
+                               if (ret == 0) {
+                                       MSG("All kernel system calls are enabled in channel %s", channel_name);
+                               }
+                               goto error;
                        }
+                       break;
+               default:
+                       MSG("Enable all not supported for this instrumentation type.");
                        goto error;
                }
-
-               /* TODO: User-space tracer */
        }
 
        /* Strip event list */
@@ -258,6 +279,10 @@ static int enable_events(char *session_name)
                                        LTTNG_SYMBOL_NAME_LEN);
                                ev.attr.ftrace.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                                break;
+                       case LTTNG_EVENT_SYSCALLS:
+                               MSG("per-syscall selection not supported yet. Use \"-a\" for all syscalls.");
+                               ret = CMD_NOT_IMPLEMENTED;
+                               goto error;
                        default:
                                ret = CMD_NOT_IMPLEMENTED;
                                goto error;
@@ -339,6 +364,9 @@ int cmd_enable_events(int argc, const char **argv)
                        opt_event_type = LTTNG_EVENT_FUNCTION_ENTRY;
                        opt_function_entry_symbol = poptGetOptArg(pc);
                        break;
+               case OPT_SYSCALLS:
+                       opt_event_type = LTTNG_EVENT_SYSCALLS;
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index f0c8c880f536e0b23742bdc0160f54c8fd2a294b..f4636985f0911193c4c9fee712992307684159fa 100644 (file)
@@ -177,6 +177,14 @@ static int list_events(const char *channel_name)
                                                events[i].name, events[i].enabled);
                                MSG("%ssymbol: \"%s\"", indent8, events[i].attr.ftrace.symbol_name);
                                break;
+                       case LTTNG_EVENT_SYSCALLS:
+                               MSG("%s (type: syscalls) [enabled: %d]", indent6,
+                                               events[i].enabled);
+                               break;
+                       case LTTNG_EVENT_NOOP:
+                               MSG("%s (type: noop) [enabled: %d]", indent6,
+                                               events[i].enabled);
+                               break;
                }
        }
 
This page took 0.034271 seconds and 4 git commands to generate.