From 7f66d5e774d49f60c22d7fea34c41bd58797803a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 14 Jun 2016 12:42:01 -0400 Subject: [PATCH] Add --omit-name and --omit-output options to the save command MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng/commands/save.c | 46 ++++++++++++++++++++++++++ src/common/config/config-session-abi.h | 2 ++ src/common/config/session-config.c | 2 ++ src/common/mi-lttng-3.0.xsd | 2 ++ 4 files changed, 52 insertions(+) diff --git a/src/bin/lttng/commands/save.c b/src/bin/lttng/commands/save.c index ee3e17c66..7370af01e 100644 --- a/src/bin/lttng/commands/save.c +++ b/src/bin/lttng/commands/save.c @@ -31,6 +31,8 @@ static char *opt_output_path; static bool opt_force; static bool opt_save_all; +static bool opt_omit_name; +static bool opt_omit_output; static struct mi_writer *writer; enum { @@ -38,6 +40,8 @@ enum { OPT_ALL, OPT_FORCE, OPT_LIST_OPTIONS, + OPT_OMIT_NAME, + OPT_OMIT_OUTPUT, }; static struct poptOption save_opts[] = { @@ -47,6 +51,8 @@ static struct poptOption save_opts[] = { {"output-path", 'o', POPT_ARG_STRING, &opt_output_path, 0, NULL, NULL}, {"force", 'f', POPT_ARG_NONE, NULL, OPT_FORCE, NULL, NULL}, {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, + {"omit-name", 0, POPT_ARG_NONE, NULL, OPT_OMIT_NAME, NULL, NULL}, + {"omit-output", 0, POPT_ARG_NONE, NULL, OPT_OMIT_OUTPUT, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -108,6 +114,26 @@ static int mi_save_print(const char *session_name) } } + /* Omit session name. */ + if (opt_omit_name) { + /* Only print if true; assume default value otherwise. */ + ret = mi_lttng_writer_write_element_bool(writer, + config_element_omit_name, opt_omit_name); + if (ret) { + goto end; + } + } + + /* Omit session output. */ + if (opt_omit_output) { + /* Only print if true; assume default value otherwise. */ + ret = mi_lttng_writer_write_element_bool(writer, + config_element_omit_output, opt_omit_output); + if (ret) { + goto end; + } + } + /* Close save element */ ret = mi_lttng_writer_close_element(writer); end: @@ -142,6 +168,12 @@ int cmd_save(int argc, const char **argv) case OPT_LIST_OPTIONS: list_cmd_options(stdout, save_opts); goto end; + case OPT_OMIT_NAME: + opt_omit_name = true; + break; + case OPT_OMIT_OUTPUT: + opt_omit_output = true; + break; default: ret = CMD_UNDEFINED; goto end; @@ -179,6 +211,20 @@ int cmd_save(int argc, const char **argv) goto end_destroy; } + if (opt_omit_name) { + if (lttng_save_session_attr_set_omit_name(attr, true)) { + ret = CMD_ERROR; + goto end_destroy; + } + } + + if (opt_omit_output) { + if (lttng_save_session_attr_set_omit_output(attr, true)) { + ret = CMD_ERROR; + goto end_destroy; + } + } + /* Mi check */ if (lttng_opt_mi) { writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi); diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h index 66d9cca73..00757363f 100644 --- a/src/common/config/config-session-abi.h +++ b/src/common/config/config-session-abi.h @@ -78,6 +78,8 @@ extern const char * const config_element_pid_tracker; extern const char * const config_element_trackers; extern const char * const config_element_targets; extern const char * const config_element_target_pid; +extern const char * const config_element_omit_name; +extern const char * const config_element_omit_output; extern const char * const config_domain_type_kernel; extern const char * const config_domain_type_ust; diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index 6c639af44..f032e1a34 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -128,6 +128,8 @@ const char * const config_element_pid_tracker = "pid_tracker"; const char * const config_element_trackers = "trackers"; const char * const config_element_targets = "targets"; const char * const config_element_target_pid = "pid_target"; +const char * const config_element_omit_name = "omit_name"; +const char * const config_element_omit_output = "omit_output"; const char * const config_domain_type_kernel = "KERNEL"; const char * const config_domain_type_ust = "UST"; diff --git a/src/common/mi-lttng-3.0.xsd b/src/common/mi-lttng-3.0.xsd index 436a9893b..2c29c9cea 100644 --- a/src/common/mi-lttng-3.0.xsd +++ b/src/common/mi-lttng-3.0.xsd @@ -417,6 +417,8 @@ THE SOFTWARE. + + -- 2.34.1