From: Mathieu Desnoyers Date: Fri, 16 Sep 2011 23:33:28 +0000 (-0400) Subject: Add support for --syscalls X-Git-Tag: v2.0-pre14~25 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0133c1990185d0374ec06a751da23b7a84c54d78;p=lttng-tools.git Add support for --syscalls Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng-kernel.h b/include/lttng-kernel.h index 394962054..20b788fc1 100644 --- a/include/lttng-kernel.h +++ b/include/lttng-kernel.h @@ -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 { diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 3e5b05562..efb67fa69 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -65,6 +65,8 @@ enum lttng_event_type { LTTNG_EVENT_PROBE, LTTNG_EVENT_FUNCTION, LTTNG_EVENT_FUNCTION_ENTRY, + LTTNG_EVENT_NOOP, + LTTNG_EVENT_SYSCALLS, }; /* diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index 4b803dc5b..26b721e99 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -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 { diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 97569f6d1..5a0ad0b8a 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -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++; } diff --git a/ltt-sessiond/trace-kernel.c b/ltt-sessiond/trace-kernel.c index 57a9eb42d..b84021262 100644 --- a/ltt-sessiond/trace-kernel.c +++ b/ltt-sessiond/trace-kernel.c @@ -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; diff --git a/lttng/commands/calibrate.c b/lttng/commands/calibrate.c index b4d0fe045..bcddc5e8b 100644 --- a/lttng/commands/calibrate.c +++ b/lttng/commands/calibrate.c @@ -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; diff --git a/lttng/commands/enable_events.c b/lttng/commands/enable_events.c index f6bca6e94..0d47b6291 100644 --- a/lttng/commands/enable_events.c +++ b/lttng/commands/enable_events.c @@ -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; diff --git a/lttng/commands/list.c b/lttng/commands/list.c index f0c8c880f..f4636985f 100644 --- a/lttng/commands/list.c +++ b/lttng/commands/list.c @@ -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; } }