[PATCH] Add an option for raising Strauss awareness
Dmitry V. Levin
ldv at altlinux.org
Sun Apr 1 21:52:42 UTC 2018
On Sun, Apr 01, 2018 at 02:50:14AM +0200, Eugene Syromyatnikov wrote:
> As Der Strauss is the strace mascot and also an endangered species,
> it is now strace's responsibility to raise awareness about it,
> in a most strace way possible.
>
> * straus.c: New file.
> * straus.h: New header.
> * Makefile.am [ENABLE_STRAUS] (strace_SOURCES): Add them.
> * configure.ac: Add an option for enabling ability to raise Strauss
> awareness.
> * strace.c [ENABLE_STRAUS]: Include "straus.h"
> [ENABLE_STRAUS] (straus_flag): New static variable.
> (print_version): Print straus flag.
> [ENABLE_STRAUS] (usage): Print information about -R option.
> (printleader): Call print_straus if straus_flag is enabled.
> [ENABLE_STRAUS] (init): Parse -R option.
> * tests/straus.c: New file.
> * tests/straus.test: New test.
> * tests/Makefile.am (MISC_TESTS): Add it.
> * tests/.gitignore: Add straus.
> * tests/strace-V.test: Update expected output.
> (getoption): Move it...
> * tests/init.sh (getoption): ...here.
> * tests/pure_executables.list: Add straus.
> * strace.1.in: Document it.
> * NEWS: Mention it.
> ---
> Makefile.am | 4 ++
> NEWS | 1 +
> configure.ac | 16 +++++
> strace.1.in | 5 +-
> strace.c | 28 ++++++++
> straus.c | 80 +++++++++++++++++++++
> straus.h | 33 +++++++++
> tests/.gitignore | 1 +
> tests/Makefile.am | 1 +
> tests/init.sh | 17 +++++
> tests/pure_executables.list | 1 +
> tests/strace-V.test | 20 +-----
> tests/straus.c | 169 ++++++++++++++++++++++++++++++++++++++++++++
> tests/straus.test | 9 +++
> 14 files changed, 366 insertions(+), 19 deletions(-)
> create mode 100644 straus.c
> create mode 100644 straus.h
> create mode 100644 tests/straus.c
> create mode 100755 tests/straus.test
>
> diff --git a/Makefile.am b/Makefile.am
> index b961a6d..1b6d356 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -356,6 +356,10 @@ strace_LDADD += $(libiberty_LIBS)
> endif
> endif
>
> +if ENABLE_STRAUS
> +strace_SOURCES += straus.c straus.h
> +endif
> +
> @CODE_COVERAGE_RULES@
> CODE_COVERAGE_BRANCH_COVERAGE = 1
> CODE_COVERAGE_GENHTML_OPTIONS = $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) \
> diff --git a/NEWS b/NEWS
> index e26ccb9..75fcb9a 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -24,6 +24,7 @@ Noteworthy changes in release ?.?? (????-??-??)
> * Known pixel/SDR format names are printed as comments for pixelformat fields
> in v4l2 structures.
> * Enhanced decoding of kern_features syscall.
> + * Added ability to raise Strauss awareness.
>
> * Bug fixes
> * Fixed build on m68k.
> diff --git a/configure.ac b/configure.ac
> index 4b8bc73..2f57c81 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -994,6 +994,22 @@ if test "$arch" = mips && test "$no_create" != yes; then
> fi
> fi
>
> +AC_ARG_ENABLE([straus],
> + [AS_HELP_STRING([--enable-straus=yes|no],
> + [whether to enable option for increasing Strauss awareness])],
> + [case "$enableval" in
> + yes|no) enable_straus="$enableval" ;;
> + *) AC_MSG_ERROR([bad value $enableval for enable-straus
> + option. Valid options are: yes, no.])
> + ;;
> + esac],
> + [enable_straus=no])
> +
> +if test "x$enable_straus" = xyes; then
> + AC_DEFINE([ENABLE_STRAUS], 1, [Enable an option for raising Strauss awareness])
> +fi
> +AM_CONDITIONAL([ENABLE_STRAUS], [test "x$enable_straus" = xyes])
> +
> AC_ARG_ENABLE([mpers],
> [AS_HELP_STRING([--enable-mpers=yes|no|check|m32|mx32],
> [whether to enable multiple personalities support required
> diff --git a/strace.1.in b/strace.1.in
> index b0b692d..a9d3661 100644
> --- a/strace.1.in
> +++ b/strace.1.in
> @@ -58,7 +58,7 @@
> strace \- trace system calls and signals
> .SH SYNOPSIS
> .SY strace
> -.OP \-CdffhikqrtttTvVxxy
> +.OP \-CdffhikqrRtttTvVxxy
> .OP \-I n
> .OP \-b execve
> .OM \-e expr
> @@ -288,6 +288,9 @@ Print a relative timestamp upon entry to each system call. This
> records the time difference between the beginning of successive
> system calls.
> .TP
> +.B \-R
> +Raise Strauss awareness in the output.
> +.TP
> .BI "\-s " strsize
> Specify the maximum string size to print (the default is 32). Note
> that filenames are not considered strings and are always printed in
> diff --git a/strace.c b/strace.c
> index 4535645..8142769 100644
> --- a/strace.c
> +++ b/strace.c
> @@ -59,6 +59,10 @@
> #include "xstring.h"
> #include "delay.h"
>
> +#ifdef ENABLE_STRAUS
> +#include "straus.h"
> +#endif
> +
> /* In some libc, these aren't declared. Do it ourself: */
> extern char **environ;
> extern int optind;
> @@ -96,6 +100,10 @@ static unsigned int tflag;
> static bool rflag;
> static bool print_pid_pfx;
>
> +#ifdef ENABLE_STRAUS
> +static bool straus_flag;
> +#endif
> +
> /* -I n */
> enum {
> INTR_NOT_SET = 0,
> @@ -221,6 +229,9 @@ print_version(void)
> " no-mx32-mpers"
> # endif
> #endif /* SUPPORTED_PERSONALITIES > 2 */
> +#ifdef ENABLE_STRAUS
> + " straus"
> +#endif
> "";
>
> printf("%s -- version %s\n"
> @@ -300,6 +311,10 @@ Miscellaneous:\n\
> -h print help message\n\
> -V print version\n\
> "
> +#ifdef ENABLE_STRAUS
> +" -R raise Strauss awareness\n"
> +#endif
> +
> /* ancient, no one should use it
> -F -- attempt to follow vforks (deprecated, use -f)\n\
> */
> @@ -638,6 +653,11 @@ printleader(struct tcb *tcp)
> set_current_tcp(tcp);
> current_tcp->curcol = 0;
>
> +#ifdef ENABLE_STRAUS
> + if (straus_flag)
> + print_straus();
> +#endif
> +
> if (print_pid_pfx)
> tprintf("%-5d ", tcp->pid);
> else if (nprocs > 1 && !outfname)
> @@ -1581,6 +1601,9 @@ init(int argc, char *argv[])
> #ifdef USE_LIBUNWIND
> "k"
> #endif
> +#ifdef ENABLE_STRAUS
> + "R"
> +#endif
> "a:b:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxyz")) != EOF) {
> switch (c) {
> case 'a':
> @@ -1662,6 +1685,11 @@ init(int argc, char *argv[])
> case 'r':
> rflag = 1;
> break;
> +#ifdef ENABLE_STRAUS
> + case 'R':
> + straus_flag = 1;
> + break;
> +#endif /* ENABLE_STRAUS */
I think we can easily do better here by implementing levels of Strauss
awareness, just by using ++straus_flag here, and ...
> case 's':
> i = string_to_uint(optarg);
> if (i < 0 || (unsigned int) i > -1U / 4)
> diff --git a/straus.c b/straus.c
> new file mode 100644
> index 0000000..1f4706d
> --- /dev/null
> +++ b/straus.c
> @@ -0,0 +1,80 @@
> +/*
> + * Copyright (c) 2018 The strace developers.
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + * notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + * notice, this list of conditions and the following disclaimer in the
> + * documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote products
> + * derived from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include "defs.h"
> +
> +#include "straus.h"
> +
> +static const char *straus[] = {
> + " ____ ",
> + " / \\ ",
> + " |-. .-.| ",
> + " (_@)(_@) ",
> + " .---_ \\ ",
> + " /.. \\_/ ",
> + " |__.-^ / ",
> + " } | ",
> + " | [ ",
> + " [ ] ",
> + " ] | ",
> + " | [ ",
> + " [ ] ",
> + " / | __ ",
> + " \\| |/ _/ /_ ",
> + " \\ | |//___/__/__/_ ",
> + "\\\\ \\ / // -____/_ ",
> + "// \" \\\\ \\___.- ",
> + " // \\\\ __.----._/_ ",
> + "/ //|||\\\\ .- __> ",
> + "[ / __.- ",
> + "[ [ } ",
> + "\\ \\ / ",
> + " \"-._____ \\.____.--\" ",
> + " | | | | ",
> + " | | | | ",
> + " | | | | ",
> + " | | | | ",
> + " { } { } ",
> + " | | | | ",
> + " | | | | ",
> + " | | | | ",
> + " / { | | ",
> + " .-\" / [ -._ ",
> + "/___/ / \\ \\___\"-. ",
> + " -\" \"- ",
> + " ",
> + };
> +
> +void
> +print_straus(void)
... passing the level of awareness to this function.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180402/11a25707/attachment.bin>
More information about the Strace-devel
mailing list