summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2022-04-01 20:24:39 +0200
committerEugene Syromyatnikov <evgsyr@gmail.com>2022-04-02 16:13:20 +0200
commit312b3dd0cef776191533ad2b850e4f54256ca8cf (patch)
treed11c9cd13354d9136bed95ca1d0eb8dfcc1081d4
parent065441616f2ae943ad85f93d9373edaa48da0c2d (diff)
downloadstrace-312b3dd0cef776191533ad2b850e4f54256ca8cf.tar.gz
Add an option for raising Strauss awareness
As der Strauss is the strace's mascot and also an endangered species, it is a strace's responsibility now to raise awareness about it. * src/strauss.c: New file. * src/strauss.h: New header. * src/Makefile.am (strace_SOURCES): Add them. * src/strace.c: Include "strauss.h". (version_verbosity): New static variable. (print_version): Add verbosity argument, call print_strauss. (increase_version_verbosity): New function. (init) <case 'V'>: Call increase_version_verbosity. (init): Call print_version and exit if version_verbosity is non-zero. * tests/strauss_body.exp: New file. * tests/strauss_head.exp: Likewise. * tests/Makefile.am (EXTRA_DIST): Add them. * tests/strace-V.test: Update expected output, add checks. * strace.1.in: Document it. * NEWS: Mention it.
-rw-r--r--NEWS1
-rw-r--r--doc/strace.1.in2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/strace.c23
-rw-r--r--src/strauss.c66
-rw-r--r--src/strauss.h19
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/strace-V.test35
-rw-r--r--tests/strauss_body.exp26
-rw-r--r--tests/strauss_head.exp11
10 files changed, 176 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index 0b1057195..9ffbc4f07 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Noteworthy changes in release ?.?? (????-??-??)
===============================================
* Improvements
+ * Added an interface of raising des Strausses awareness.
* Bug fixes
diff --git a/doc/strace.1.in b/doc/strace.1.in
index 2f8d02c93..0e8fabd23 100644
--- a/doc/strace.1.in
+++ b/doc/strace.1.in
@@ -1566,6 +1566,8 @@ proceeds as usual and stops traced processes on every system call.
.B \-\-version
Print the version number of
.BR strace .
+Multiple instances of the option beyond specific threshold tend to increase
+Strauss awareness.
.SS "Time specification format description"
.PP
Time values can be specified as a decimal floating point number
diff --git a/src/Makefile.am b/src/Makefile.am
index ab5428cf2..7773bb040 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -350,6 +350,8 @@ libstrace_a_SOURCES = \
static_assert.h \
statx.c \
statx.h \
+ strauss.c \
+ strauss.h \
string_to_uint.c \
string_to_uint.h \
swapon.c \
diff --git a/src/strace.c b/src/strace.c
index 2c165d5bf..28e6e4db9 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -36,6 +36,7 @@
#include "ptrace_syscall_info.h"
#include "scno.h"
#include "printsiginfo.h"
+#include "strauss.h"
#include "trace_event.h"
#include "xstring.h"
#include "delay.h"
@@ -92,6 +93,8 @@ static int rflag_scale = 1000;
static int rflag_width = 6;
static bool print_pid_pfx;
+static unsigned int version_verbosity;
+
/* -I n */
enum {
INTR_NOT_SET = 0,
@@ -218,7 +221,7 @@ strerror(int err_no)
#endif /* HAVE_STERRROR */
static void
-print_version(void)
+print_version(unsigned int verbosity)
{
static const char features[] =
#ifdef ENABLE_STACKTRACE
@@ -253,6 +256,9 @@ print_version(void)
PACKAGE_NAME, PACKAGE_VERSION, COPYRIGHT_YEAR, PACKAGE_URL);
printf("\nOptional features enabled:%s\n",
features[0] ? features : " (none)");
+
+ /* Raise strauss awareness */
+ print_strauss(verbosity);
}
static void
@@ -2048,6 +2054,13 @@ make_env(char **orig_env, char *const *env_changes, size_t env_change_count)
return new_env;
}
+static void
+increase_version_verbosity(void)
+{
+ if (version_verbosity < (STRAUSS_START_VERBOSITY + strauss_lines))
+ version_verbosity++;
+}
+
/*
* Initialization part of main() was eating much stack (~0.5k),
* which was unused after init.
@@ -2390,8 +2403,7 @@ init(int argc, char *argv[])
qualify_abbrev("none");
break;
case 'V':
- print_version();
- exit(0);
+ increase_version_verbosity();
break;
case 'w':
count_wallclock = 1;
@@ -2488,6 +2500,11 @@ init(int argc, char *argv[])
}
}
+ if (version_verbosity) {
+ print_version(version_verbosity);
+ exit(0);
+ }
+
argv += optind;
argc -= optind;
diff --git a/src/strauss.c b/src/strauss.c
new file mode 100644
index 000000000..e3a240ff8
--- /dev/null
+++ b/src/strauss.c
@@ -0,0 +1,66 @@
+/*
+ * Strauss awareness implementation.
+ *
+ * Copyright (c) 2018-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "defs.h"
+
+#include "strauss.h"
+
+static const char *strauss[] = {
+ "",
+ " ____",
+ " / \\",
+ " |-. .-.|",
+ " (_@)(_@)",
+ " .---_ \\",
+ " /.. \\_/",
+ " |__.-^ /",
+ " } |",
+ " | [",
+ " [ ]",
+ " ] |",
+ " | [",
+ " [ ]",
+ " / | __",
+ " \\| |/ _/ /_",
+ " \\ | |//___/__/__/_",
+ "\\\\ \\ / // -____/_",
+ "// \" \\\\ \\___.-",
+ " // \\\\ __.----._/_",
+ "/ '/|||\\` .- __>",
+ "[ / __.-",
+ "[ [ }",
+ "\\ \\ /",
+ " \"-._____ \\.____.--\"",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " { } { }",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " / { | |",
+ " .-\" / [ -._",
+ "/___/ / \\ \\___\"-.",
+ " -\" \"-",
+ };
+
+const size_t strauss_lines = ARRAY_SIZE(strauss);
+
+void
+print_strauss(size_t verbosity)
+{
+ if (verbosity < STRAUSS_START_VERBOSITY)
+ return;
+
+ verbosity = MIN(verbosity - STRAUSS_START_VERBOSITY, strauss_lines);
+
+ for (size_t i = 0; i < verbosity; i++)
+ puts(strauss[i]);
+}
diff --git a/src/strauss.h b/src/strauss.h
new file mode 100644
index 000000000..fb2e427aa
--- /dev/null
+++ b/src/strauss.h
@@ -0,0 +1,19 @@
+/*
+ * Strauss awareness interface declarations.
+ *
+ * Copyright (c) 2018-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef STRACE_STRAUSS_H
+#define STRACE_STRAUSS_H
+
+enum { STRAUSS_START_VERBOSITY = 5 };
+
+extern const size_t strauss_lines;
+
+extern void print_strauss(size_t verbosity);
+
+#endif /* STRACE_STRAUSS_H */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd7e84cb7..d21230b63 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -714,6 +714,8 @@ EXTRA_DIST = \
strace-k.test \
strace-r.expected \
strace.supp \
+ strauss_body.exp \
+ strauss_head.exp \
sun_path.expected \
syntax.sh \
trace_clock.in \
diff --git a/tests/strace-V.test b/tests/strace-V.test
index fdac7a3e4..a46948e69 100755
--- a/tests/strace-V.test
+++ b/tests/strace-V.test
@@ -38,13 +38,32 @@ option_secontext=$(get_config_option ENABLE_SECONTEXT " secontext")
features="${option_unwind}${option_demangle}${option_m32}${option_mx32}${option_secontext}"
[ -n "$features" ] || features=" (none)"
-cat > "$EXP" << __EOF__
-$(get_config_str PACKAGE_NAME) -- version $(get_config_str PACKAGE_VERSION)
-Copyright (c) 1991-${config_year} The strace developers <$(get_config_str PACKAGE_URL)>.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+for i in $(seq 4); do
+ case "$i" in
+ 1) opt="-V";;
+ 2) opt="-V -V -V -V";;
+ 3) opt="-VVVV -VVVV -VVVV -VVVV";;
+ 4) opt="-VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";;
+ esac
-Optional features enabled:${features}
-__EOF__
+ run_strace ${opt} > "${LOG}.${opt}"
-match_diff "$OUT" "$EXP"
+ cat > "${EXP}.${opt}" <<-__EOF__
+ $(get_config_str PACKAGE_NAME) -- version $(get_config_str PACKAGE_VERSION)
+ Copyright (c) 1991-${config_year} The strace developers <$(get_config_str PACKAGE_URL)>.
+ This is free software; see the source for copying conditions. There is NO
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ Optional features enabled:${features}
+ __EOF__
+
+ if [ 3 -le "$i" ]; then
+ cat $srcdir/strauss_head.exp >> "${EXP}.${opt}"
+ fi
+
+ if [ 4 -le "$i" ]; then
+ cat $srcdir/strauss_body.exp >> "${EXP}.${opt}"
+ fi
+
+ match_diff "${LOG}.${opt}" "${EXP}.${opt}"
+done
diff --git a/tests/strauss_body.exp b/tests/strauss_body.exp
new file mode 100644
index 000000000..ca457b409
--- /dev/null
+++ b/tests/strauss_body.exp
@@ -0,0 +1,26 @@
+ ] |
+ | [
+ [ ]
+ / | __
+ \| |/ _/ /_
+ \ | |//___/__/__/_
+\\ \ / // -____/_
+// " \\ \___.-
+ // \\ __.----._/_
+/ '/|||\` .- __>
+[ / __.-
+[ [ }
+\ \ /
+ "-._____ \.____.--"
+ | | | |
+ | | | |
+ | | | |
+ | | | |
+ { } { }
+ | | | |
+ | | | |
+ | | | |
+ / { | |
+ .-" / [ -._
+/___/ / \ \___"-.
+ -" "-
diff --git a/tests/strauss_head.exp b/tests/strauss_head.exp
new file mode 100644
index 000000000..cfb6fe456
--- /dev/null
+++ b/tests/strauss_head.exp
@@ -0,0 +1,11 @@
+
+ ____
+ / \
+ |-. .-.|
+ (_@)(_@)
+ .---_ \
+ /.. \_/
+ |__.-^ /
+ } |
+ | [
+ [ ]