From: Mathieu Desnoyers Date: Fri, 30 Sep 2011 15:23:32 +0000 (-0400) Subject: Implement enable all vs enable tracepoints vs enable syscalls X-Git-Tag: v2.0-pre14~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7a3d132871a4414b6cd232e7f41e6a1f50d9bf16;p=lttng-tools.git Implement enable all vs enable tracepoints vs enable syscalls Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/quickstart.txt b/doc/quickstart.txt index 5ba0cc54e..34f7e2059 100644 --- a/doc/quickstart.txt +++ b/doc/quickstart.txt @@ -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 diff --git a/include/lttng-kernel.h b/include/lttng-kernel.h index 475cde8cf..a62207209 100644 --- a/include/lttng-kernel.h +++ b/include/lttng-kernel.h @@ -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, diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index bde46fa60..84f814793 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -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, }; /* diff --git a/ltt-sessiond/event.c b/ltt-sessiond/event.c index dfafd88e8..e8f54504c 100644 --- a/ltt-sessiond/event.c +++ b/ltt-sessiond/event.c @@ -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; } diff --git a/ltt-sessiond/event.h b/ltt-sessiond/event.h index 0ef52fe7b..38768c51a 100644 --- a/ltt-sessiond/event.h +++ b/ltt-sessiond/event.h @@ -22,15 +22,22 @@ #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 */ diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index e1bf1e416..7532e2c3b 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -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; } diff --git a/ltt-sessiond/trace-kernel.c b/ltt-sessiond/trace-kernel.c index 37d9d143a..fa3ba692c 100644 --- a/ltt-sessiond/trace-kernel.c +++ b/ltt-sessiond/trace-kernel.c @@ -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; diff --git a/lttng/commands/enable_events.c b/lttng/commands/enable_events.c index 78227be1f..fbcd40daf 100644 --- a/lttng/commands/enable_events.c +++ b/lttng/commands/enable_events.c @@ -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) { diff --git a/lttng/commands/list.c b/lttng/commands/list.c index c73ea74dc..6afec1876 100644 --- a/lttng/commands/list.c +++ b/lttng/commands/list.c @@ -22,6 +22,7 @@ #include #include #include +#include #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; } }