From bb30da78812212ef51381217237908ccbf94c18e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 29 Jul 2019 11:42:58 -0400 Subject: [PATCH] cli: remove babeltrace2-log babeltrace-log (now renamed to babeltrace2-log) is a legacy tool provided by Babeltrace 1 used to transform `dmesg` output to CTF. The version currently provided by Babeltrace 2 simply runs babeltrace2 with a pre-defined graph topology. It does nothing that a user couldn't do on the command line. The equivalent now would be: dmesg | babeltrace2 -c src.text.dmesg -o ctf -w /path/to/trace It was therefore decided that it was no longer necessary to provide that utility, and to remove it. Change-Id: Id547bced56a8b9913cb152e1309919a15b6fbdd0 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/1796 Tested-by: jenkins Reviewed-by: Philippe Proulx --- configure.ac | 2 +- doc/man/Makefile.am | 1 - doc/man/babeltrace2-log.1.txt | 75 --------------- src/cli/Makefile.am | 18 +--- src/cli/babeltrace2-log.c | 168 ---------------------------------- tests/utils/utils.sh | 8 -- 6 files changed, 3 insertions(+), 269 deletions(-) delete mode 100644 doc/man/babeltrace2-log.1.txt delete mode 100644 src/cli/babeltrace2-log.c diff --git a/configure.ac b/configure.ac index cf89a9d5..e4a0c86d 100644 --- a/configure.ac +++ b/configure.ac @@ -679,7 +679,7 @@ CFLAGS=${save_CFLAGS} # Abuse autoconf's AC_ARG_PROGRAM output variable 'program_transform_name' # to rename babeltrace2.bin to babeltrace2 at install time. -program_transform_name="s&babeltrace2\.bin&babeltrace2&;s&babeltrace2-log\.bin&babeltrace2-log&;$program_transform_name" +program_transform_name="s&babeltrace2\.bin&babeltrace2&;$program_transform_name" AC_SUBST(program_transform_name) AC_CONFIG_FILES([ diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index 8cc9d4f3..850fdf04 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -11,7 +11,6 @@ MAN1_NAMES = \ babeltrace2-convert \ babeltrace2-help \ babeltrace2-list-plugins \ - babeltrace2-log \ babeltrace2-query \ babeltrace2-run MAN7_NAMES = babeltrace2-filter.utils.muxer \ diff --git a/doc/man/babeltrace2-log.1.txt b/doc/man/babeltrace2-log.1.txt deleted file mode 100644 index c88056c9..00000000 --- a/doc/man/babeltrace2-log.1.txt +++ /dev/null @@ -1,75 +0,0 @@ -babeltrace2-log(1) -================= -:manpagetype: program -:revdate: 5 October 2017 - - -NAME ----- -babeltrace2-log - Convert a Linux kernel ring buffer to a CTF trace - - -SYNOPSIS --------- -[verse] -*babeltrace2-log* [opt:--with-timestamps] 'OUTPUT-PATH' - - -DESCRIPTION ------------ -The `babeltrace2-log` tool reads the lines of a Linux kernel ring buffer, -as printed by the man:dmesg(1) tool, from the standard input stream and -converts them to a http://diamon.org/ctf/[CTF] trace written to the -'OUTPUT-PATH' directory. - -Usage example: - -[role="term"] ----- -$ dmesg | babeltrace2-log --with-timestamps my-trace ----- - -The events of the generated CTF trace are named `string` and contain a -single payload string field named `str` which contains the corresponding -ring buffer line. - -By default, `babeltrace2-log` does not try to extract the timestamps of -the kernel ring buffer lines to use them as the created events's -timestamps. A typical man:dmesg(1) line looks like this: - ----- -[87166.510937] PM: Finishing wakeup. ----- - -In the last example, the `[87166.510937]` part is a timestamp which -could be extracted. You can make `babeltrace2-log` extract timestamps -from lines with the opt:--with-timestamps option. - - -OPTIONS -------- -opt:-t, opt:--with-timestamps:: - Extract timestamps from the kernel ring buffer lines: set - the created event's payload's `str` field to the rest of the line, - excluding any timestamp prefix. - - -ENVIRONMENT VARIABLES ---------------------- -See the environment variables of man:babeltrace2-source.text.dmesg(7), -man:babeltrace2-filter.utils.muxer(7), and -man:babeltrace2-sink.ctf.fs(7). - -include::common-lib-env.txt[] - -include::common-cli-files.txt[] - -include::common-cmd-footer.txt[] - - -SEE ALSO --------- -man:babeltrace2-intro(7), -man:babeltrace2-source.text.dmesg(7), -man:babeltrace2-filter.utils.muxer(7), -man:babeltrace2-sink.ctf.fs(7) diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index d8946e44..338a85fa 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -17,8 +17,8 @@ if ENABLE_PYTHON_PLUGINS AM_CPPFLAGS += '-DCONFIG_IN_TREE_PROVIDER_DIR="$(abs_top_builddir)/src/python-plugin-provider/.libs"' endif -bin_PROGRAMS = babeltrace2.bin babeltrace2-log.bin -noinst_PROGRAMS = babeltrace2 babeltrace2-log +bin_PROGRAMS = babeltrace2.bin +noinst_PROGRAMS = babeltrace2 babeltrace2_bin_SOURCES = \ babeltrace2.c \ @@ -99,17 +99,3 @@ babeltrace2_SOURCES = $(babeltrace2_bin_SOURCES) babeltrace2_LDFLAGS = $(babeltrace2_bin_LDFLAGS) babeltrace2_LDADD = $(babeltrace2_bin_LDADD) babeltrace2_CFLAGS = $(AM_CFLAGS) -DBT_SET_DEFAULT_IN_TREE_CONFIGURATION - -# babeltrace2-log rules and config below -babeltrace2_log_bin_SOURCES = babeltrace2-log.c -babeltrace2_log_bin_LDADD = \ - $(top_builddir)/src/compat/libcompat.la \ - $(top_builddir)/src/common/libbabeltrace2-common.la \ - $(top_builddir)/src/logging/libbabeltrace2-logging.la \ - $(POPT_LIBS) -babeltrace2_log_bin_CFLAGS = $(AM_CFLAGS) '-DBT_CLI_PATH="$(abs_top_builddir)/src/cli/babeltrace2$(EXEEXT)"' - -# Only used for in-tree execution and tests -babeltrace2_log_SOURCES = $(babeltrace2_log_bin_SOURCES) -babeltrace2_log_LDADD = $(babeltrace2_log_bin_LDADD) -babeltrace2_log_CFLAGS = $(AM_CFLAGS) '-DBT_CLI_PATH="$(bindir)/babeltrace2$(EXEEXT)"' diff --git a/src/cli/babeltrace2-log.c b/src/cli/babeltrace2-log.c deleted file mode 100644 index 59f34e5d..00000000 --- a/src/cli/babeltrace2-log.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2017 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include -#include -#include -#include "common/assert.h" -#include -#include -#include - -static -void print_usage(FILE *fp) -{ - fprintf(stderr, "Usage: babeltrace2-log [OPTIONS] OUTPUT-PATH\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Options:\n"); - fprintf(stderr, "\n"); - fprintf(stderr, " -t, --with-timestamps Extract timestamps from lines and map them to\n"); - fprintf(stderr, " a CTF clock class\n"); -} - -static -int parse_params(int argc, char *argv[], char **output_path, - bool *no_extract_ts) -{ - enum { - OPT_WITH_TIMESTAMPS = 1, - OPT_HELP = 2, - }; - static struct poptOption opts[] = { - { "with-timestamps", 't', POPT_ARG_NONE, NULL, OPT_WITH_TIMESTAMPS, NULL, NULL }, - { "help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL }, - { NULL, '\0', 0, NULL, 0, NULL, NULL }, - }; - poptContext pc = NULL; - int opt; - int ret = 0; - const char *leftover; - - *no_extract_ts = true; - pc = poptGetContext(NULL, argc, (const char **) argv, opts, 0); - if (!pc) { - fprintf(stderr, "Cannot get popt context\n"); - goto error; - } - - poptReadDefaultConfig(pc, 0); - - while ((opt = poptGetNextOpt(pc)) > 0) { - switch (opt) { - case OPT_HELP: - print_usage(stdout); - goto end; - case OPT_WITH_TIMESTAMPS: - *no_extract_ts = false; - break; - default: - fprintf(stderr, "Unknown command-line option specified (option code %d)\n", - opt); - goto error; - } - } - - if (opt < -1) { - fprintf(stderr, "While parsing command-line options, at option %s: %s\n", - poptBadOption(pc, 0), poptStrerror(opt)); - goto error; - } - - leftover = poptGetArg(pc); - if (!leftover) { - fprintf(stderr, "Command line error: Missing output path\n"); - print_usage(stderr); - goto error; - } - - *output_path = strdup(leftover); - BT_ASSERT(*output_path); - goto end; - -error: - ret = 1; - -end: - if (pc) { - poptFreeContext(pc); - } - - return ret; -} - -int main(int argc, char *argv[]) -{ - char *output_path = NULL; - bool no_extract_ts; - int retcode; - GError *error = NULL; - gchar *bt_argv[] = { - BT_CLI_PATH, - "run", - "--component", - "dmesg:src.text.dmesg", - "--params", - NULL, /* no-extract-timestamp=? placeholder */ - "--component", - "ctf:sink.ctf.fs", - "--key", - "path", - "--value", - NULL, /* output path placeholder */ - "--params", - "single-trace=yes", - "--connect", - "dmesg:ctf", - NULL, /* sentinel */ - }; - - retcode = parse_params(argc, argv, &output_path, &no_extract_ts); - if (retcode) { - goto end; - } - - if (no_extract_ts) { - bt_argv[5] = "no-extract-timestamp=yes"; - } else { - bt_argv[5] = "no-extract-timestamp=no"; - } - - bt_argv[11] = output_path; - (void) g_spawn_sync(NULL, bt_argv, NULL, - G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL, - NULL, NULL, &retcode, &error); - - if (error) { - fprintf(stderr, "Failed to execute \"%s\": %s (%d)\n", - bt_argv[0], error->message, error->code); - } - -end: - free(output_path); - - if (error) { - g_error_free(error); - } - - return retcode; -} diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index a2a5c1dd..97de1c73 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -85,14 +85,6 @@ if [ "x${BT_TESTS_BT2_BIN:-}" = "x" ]; then fi export BT_TESTS_BT2_BIN -if [ "x${BT_TESTS_BT2LOG_BIN:-}" = "x" ]; then - BT_TESTS_BT2LOG_BIN="$BT_TESTS_BUILDDIR/../src/cli/babeltrace2-log" - if [ "$BT_OS_TYPE" = "mingw" ]; then - BT_TESTS_BT2LOG_BIN="${BT_TESTS_BT2LOG_BIN}.exe" - fi -fi -export BT_TESTS_BT2LOG_BIN - # TODO: Remove when bindings/python/bt2/test_plugin.py is fixed BT_PLUGINS_PATH="${BT_TESTS_BUILDDIR}/../src/plugins" -- 2.34.1