X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fdisable_events.c;h=9ab8bf0b2972f244a4e9223105e7543b0c8025cf;hp=63e5f47418964b876cd2077f6ce1b0833b0aec3c;hb=6c1c0768320135c6936c371b09731851b508c023;hpb=e4d484a59932224af0be4ee7b7b23a383163493d diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c index 63e5f4741..9ab8bf0b2 100644 --- a/src/bin/lttng/commands/disable_events.c +++ b/src/bin/lttng/commands/disable_events.c @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -36,6 +37,9 @@ static char *opt_session_name; static int opt_userspace; static int opt_disable_all; static int opt_jul; +static int opt_log4j; +static int opt_python; +static int opt_event_type; #if 0 /* Not implemented yet */ static char *opt_cmd_name; @@ -45,6 +49,7 @@ static pid_t opt_pid; enum { OPT_HELP = 1, OPT_USERSPACE, + OPT_SYSCALL, OPT_LIST_OPTIONS, }; @@ -58,7 +63,10 @@ static struct poptOption long_options[] = { {"all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0}, {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0}, {"jul", 'j', POPT_ARG_VAL, &opt_jul, 1, 0, 0}, + {"log4j", 'l', POPT_ARG_VAL, &opt_log4j, 1, 0, 0}, + {"python", 'p', POPT_ARG_VAL, &opt_python, 1, 0, 0}, {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0}, + {"syscall", 0, POPT_ARG_NONE, 0, OPT_SYSCALL, 0, 0}, #if 0 /* Not implemented yet */ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0}, @@ -86,6 +94,11 @@ static void usage(FILE *ofp) fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n"); fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); fprintf(ofp, " -j, --jul Apply for Java application using JUL\n"); + fprintf(ofp, " -l, --log4j Apply to Java application using LOG4j\n"); + fprintf(ofp, " -p, --python Apply to Python application using logging\n"); + fprintf(ofp, "\n"); + fprintf(ofp, "Event options:\n"); + fprintf(ofp, " --syscall System call event\n"); fprintf(ofp, "\n"); } @@ -156,6 +169,7 @@ static int disable_events(char *session_name) int enabled = 1, success = 1; char *event_name, *channel_name = NULL; struct lttng_domain dom; + struct lttng_event event; memset(&dom, 0, sizeof(dom)); @@ -166,6 +180,10 @@ static int disable_events(char *session_name) dom.type = LTTNG_DOMAIN_UST; } else if (opt_jul) { dom.type = LTTNG_DOMAIN_JUL; + } else if (opt_log4j) { + dom.type = LTTNG_DOMAIN_LOG4J; + } else if (opt_python) { + dom.type = LTTNG_DOMAIN_PYTHON; } else { print_missing_domain(); ret = CMD_ERROR; @@ -203,8 +221,18 @@ static int disable_events(char *session_name) } } + memset(&event, 0, sizeof(event)); + switch (opt_event_type) { + case LTTNG_EVENT_SYSCALL: + event.type = LTTNG_EVENT_SYSCALL; + break; + default: + event.type = LTTNG_EVENT_ALL; + break; + } + if (opt_disable_all) { - command_ret = lttng_disable_event(handle, NULL, channel_name); + command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL); if (command_ret < 0) { ERR("%s", lttng_strerror(command_ret)); enabled = 1; @@ -213,8 +241,10 @@ static int disable_events(char *session_name) } else { enabled = 0; success = 1; - MSG("All %s events are disabled in channel %s", - get_domain_str(dom.type), print_channel_name(channel_name)); + MSG("All %s %s are disabled in channel %s", + get_domain_str(dom.type), + opt_event_type == LTTNG_EVENT_SYSCALL ? "system calls" : "events", + print_channel_name(channel_name)); } if (lttng_opt_mi) { @@ -230,9 +260,13 @@ static int disable_events(char *session_name) while (event_name != NULL) { DBG("Disabling event %s", event_name); - command_ret = lttng_disable_event(handle, event_name, channel_name); + strncpy(event.name, event_name, sizeof(event.name)); + event.name[sizeof(event.name) - 1] = '\0'; + command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL); if (command_ret < 0) { - ERR("Event %s: %s (channel %s, session %s)", event_name, + ERR("%s %s: %s (channel %s, session %s)", + opt_event_type == LTTNG_EVENT_SYSCALL ? "System call" : "Event", + event_name, lttng_strerror(command_ret), command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ? print_raw_channel_name(channel_name) @@ -241,13 +275,15 @@ static int disable_events(char *session_name) warn = 1; success = 0; /* - * If an error occurred we assume that - * the event is still enabled. + * If an error occurred we assume that the event is still + * enabled. */ enabled = 1; } else { - MSG("%s event %s disabled in channel %s for session %s", - get_domain_str(dom.type), event_name, + MSG("%s %s %s disabled in channel %s for session %s", + get_domain_str(dom.type), + opt_event_type == LTTNG_EVENT_SYSCALL ? "system call" : "event", + event_name, print_channel_name(channel_name), session_name); success = 1; @@ -298,10 +334,14 @@ int cmd_disable_events(int argc, const char **argv) int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1; static poptContext pc; char *session_name = NULL; + int event_type = -1; pc = poptGetContext(NULL, argc, argv, long_options, 0); poptReadDefaultConfig(pc, 0); + /* Default event type */ + opt_event_type = LTTNG_EVENT_ALL; + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_HELP: @@ -310,6 +350,9 @@ int cmd_disable_events(int argc, const char **argv) case OPT_USERSPACE: opt_userspace = 1; break; + case OPT_SYSCALL: + opt_event_type = LTTNG_EVENT_SYSCALL; + break; case OPT_LIST_OPTIONS: list_cmd_options(stdout, long_options); goto end; @@ -318,6 +361,17 @@ int cmd_disable_events(int argc, const char **argv) ret = CMD_UNDEFINED; goto end; } + + /* Validate event type. Multiple event type are not supported. */ + if (event_type == -1) { + event_type = opt_event_type; + } else { + if (event_type != opt_event_type) { + ERR("Multiple event type not supported."); + ret = CMD_ERROR; + goto end; + } + } } opt_event_list = (char*) poptGetArg(pc);