X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fdisable_events.c;h=0bfd0c506c850e4fedca383615c13d67365a7006;hp=51bf3a1f10614c33c117d2d6f9f2f185819dbf6e;hb=1004b7191b421c7c07acf964d0110d93bb022699;hpb=7767963f3240f58fcec49bcff68950f94a27ec23 diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c index 51bf3a1f1..0bfd0c506 100644 --- a/src/bin/lttng/commands/disable_events.c +++ b/src/bin/lttng/commands/disable_events.c @@ -1,21 +1,10 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -27,6 +16,7 @@ #include #include +#include #include "../command.h" @@ -41,6 +31,12 @@ static int opt_log4j; static int opt_python; static int opt_event_type; +#ifdef LTTNG_EMBED_HELP +static const char help_msg[] = +#include +; +#endif + enum { OPT_HELP = 1, OPT_TYPE_SYSCALL, @@ -74,34 +70,6 @@ static struct poptOption long_options[] = { {0, 0, 0, 0, 0, 0, 0} }; -/* - * usage - */ -static void usage(FILE *ofp) -{ - fprintf(ofp, "usage: lttng disable-event NAME[,NAME2,...] (-k | -u | -j | -l | -p) [OPTIONS]\n"); - fprintf(ofp, "\n"); - fprintf(ofp, "Options:\n"); - fprintf(ofp, " -h, --help Show this help\n"); - fprintf(ofp, " --list-options Simple listing of options\n"); - fprintf(ofp, " -s, --session NAME Apply to session name\n"); - fprintf(ofp, " -c, --channel NAME Apply to this channel\n"); - fprintf(ofp, " -a, --all-events Disable all tracepoints\n"); - fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n"); - fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); - fprintf(ofp, " -j, --jul Apply to 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 type options (Only supported with kernel domain):\n"); - fprintf(ofp, " --all All event types (default)\n"); - fprintf(ofp, " --tracepoint Tracepoint event\n"); - fprintf(ofp, " --syscall System call event\n"); - fprintf(ofp, " --probe Probe event\n"); - fprintf(ofp, " --function Function event\n"); - fprintf(ofp, "\n"); -} - static const char *print_channel_name(const char *name) { @@ -139,7 +107,7 @@ const char *print_event_type(const enum lttng_event_type ev_type) * enabled is 0 or 1 * success is 0 or 1 */ -static int mi_print_event(char *event_name, int enabled, int success) +static int mi_print_event(const char *event_name, int enabled, int success) { int ret; @@ -259,7 +227,7 @@ static int disable_events(char *session_name) enabled = 0; success = 1; MSG("All %s events of type %s are disabled in channel %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), print_event_type(opt_event_type), print_channel_name(channel_name)); } @@ -298,7 +266,7 @@ static int disable_events(char *session_name) enabled = 1; } else { MSG("%s %s of type %s disabled in channel %s for session %s", - get_domain_str(dom.type), + lttng_domain_type_str(dom.type), event_name, print_event_type(opt_event_type), print_channel_name(channel_name), @@ -351,6 +319,7 @@ 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; + const char *leftover = NULL; int event_type = -1; pc = poptGetContext(NULL, argc, argv, long_options, 0); @@ -362,7 +331,7 @@ int cmd_disable_events(int argc, const char **argv) while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_HELP: - usage(stdout); + SHOW_HELP(); goto end; case OPT_TYPE_SYSCALL: opt_event_type = LTTNG_EVENT_SYSCALL; @@ -383,7 +352,6 @@ int cmd_disable_events(int argc, const char **argv) list_cmd_options(stdout, long_options); goto end; default: - usage(stderr); ret = CMD_UNDEFINED; goto end; } @@ -401,7 +369,9 @@ int cmd_disable_events(int argc, const char **argv) } ret = print_missing_or_multiple_domains( - opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python); + opt_kernel + opt_userspace + opt_jul + opt_log4j + + opt_python, + true); if (ret) { ret = CMD_ERROR; goto end; @@ -411,7 +381,6 @@ int cmd_disable_events(int argc, const char **argv) if ((opt_userspace || opt_jul || opt_log4j || opt_python) && opt_event_type != LTTNG_EVENT_ALL) { ERR("Disabling userspace and agent (-j | -l | -p) event(s) based on instrumentation type is not supported.\n"); - usage(stderr); ret = CMD_ERROR; goto end; } @@ -419,7 +388,13 @@ int cmd_disable_events(int argc, const char **argv) opt_event_list = (char*) poptGetArg(pc); if (opt_event_list == NULL && opt_disable_all == 0) { ERR("Missing event name(s).\n"); - usage(stderr); + ret = CMD_ERROR; + goto end; + } + + leftover = poptGetArg(pc); + if (leftover) { + ERR("Unknown argument: %s", leftover); ret = CMD_ERROR; goto end; } @@ -499,7 +474,7 @@ end: ret = ret ? ret : LTTNG_ERR_MI_IO_FAIL; } - /* Overwrite ret if an error occured in disable_events */ + /* Overwrite ret if an error occurred in disable_events */ ret = command_ret ? command_ret : ret; poptFreeContext(pc);