[PATCH v2] Add an option for raising Strauss awareness

Dmitry V. Levin ldv at altlinux.org
Mon Apr 1 19:11:37 UTC 2019


On Mon, Apr 01, 2019 at 08:55:00PM +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.
> 
> * straus.c: New file.
> * straus.h: New header.
> * Makefile.am (strace_SOURCES): Add them.
> * strace.c: Include "straus.h".
> (version_verbosity): New static variable.
> (print_version): Add verbosity argument, call print_straus.
> (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/straus_body.exp: New file.
> * tests/straus_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.
> ---
>  Makefile.am           |  2 ++
>  NEWS                  |  3 +++
>  strace.1.in           |  2 ++
>  strace.c              | 23 +++++++++++++---
>  straus.c              | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  straus.h              | 19 +++++++++++++
>  tests/Makefile.am     |  2 ++
>  tests/strace-V.test   | 37 +++++++++++++++++++-------
>  tests/straus_body.exp | 26 ++++++++++++++++++
>  tests/straus_head.exp | 11 ++++++++
>  10 files changed, 186 insertions(+), 13 deletions(-)
>  create mode 100644 straus.c
>  create mode 100644 straus.h
>  create mode 100644 tests/straus_body.exp
>  create mode 100644 tests/straus_head.exp
> 
> diff --git a/Makefile.am b/Makefile.am
> index 56987ae..c052bc7 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -309,6 +309,8 @@ strace_SOURCES =	\
>  	statx.c		\
>  	statx.h		\
>  	strace.c	\
> +	straus.c	\
> +	straus.h	\
>  	string_to_uint.c \
>  	string_to_uint.h \
>  	swapon.c	\
> diff --git a/NEWS b/NEWS
> index cf63dea..be43c2d 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -1,6 +1,9 @@
>  Noteworthy changes in release ?.? (????-??-??)
>  ==============================================
>  
> +* Improvements
> +  * Added an ability to raise Strauss awareness.
> +
>  * Bug fixes
>    * Fixed decoding of last two arguments of clone syscall on riscv.
>  
> diff --git a/strace.1.in b/strace.1.in
> index 76a7411..adcc942 100644
> --- a/strace.1.in
> +++ b/strace.1.in
> @@ -914,6 +914,8 @@ Print the help summary.
>  .B \-V
>  Print the version number of
>  .BR strace .
> +Multiple instances of the option beyond specific threshold tend to increase
> +Strauss awareness.
>  .SH DIAGNOSTICS
>  When
>  .I command
> diff --git a/strace.c b/strace.c
> index ca8d558..7078b09 100644
> --- a/strace.c
> +++ b/strace.c
> @@ -37,6 +37,7 @@
>  #include "ptrace_syscall_info.h"
>  #include "scno.h"
>  #include "printsiginfo.h"
> +#include "straus.h"
>  #include "trace_event.h"
>  #include "xstring.h"
>  #include "delay.h"
> @@ -79,6 +80,8 @@ static unsigned int tflag;
>  static bool rflag;
>  static bool print_pid_pfx;
>  
> +static unsigned int version_verbosity;
> +
>  /* -I n */
>  enum {
>  	INTR_NOT_SET        = 0,
> @@ -196,7 +199,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
> @@ -228,6 +231,9 @@ print_version(void)
>  	       PACKAGE_NAME, PACKAGE_VERSION, COPYRIGHT_YEAR, PACKAGE_URL);
>  	printf("\nOptional features enabled:%s\n",
>  	       features[0] ? features : " (none)");
> +
> +	/* Raise straus awareness */
> +	print_straus(verbosity);
>  }
>  
>  static void
> @@ -1547,6 +1553,13 @@ set_sighandler(int signo, void (*sighandler)(int), struct sigaction *oldact)
>  	sigaction(signo, &sa, oldact);
>  }
>  
> +static void
> +increase_version_verbosity(void)
> +{
> +	if (version_verbosity < (STRAUS_START_VERBOSITY + straus_lines))
> +		version_verbosity++;
> +}
> +
>  /*
>   * Initialization part of main() was eating much stack (~0.5k),
>   * which was unused after init.
> @@ -1691,8 +1704,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;
> @@ -1722,6 +1734,11 @@ init(int argc, char *argv[])
>  		}
>  	}
>  
> +	if (version_verbosity) {
> +		print_version(version_verbosity);
> +		exit(0);
> +	}
> +
>  	argv += optind;
>  	argc -= optind;
>  
> diff --git a/straus.c b/straus.c
> new file mode 100644
> index 0000000..93fa6bc
> --- /dev/null
> +++ b/straus.c
> @@ -0,0 +1,74 @@
> +/*
> + * 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 "straus.h"
> +
> +static const char *straus[] = {
> +	"                         ",
> +	"     ____                ",
> +	"    /    \\               ",
> +	"   |-. .-.|              ",
> +	"   (_@)(_@)              ",
> +	"   .---_  \\              ",
> +	"  /..   \\_/              ",
> +	"  |__.-^ /               ",
> +	"      }  |               ",
> +	"     |   [               ",
> +	"     [  ]                ",
> +	"    ]   |                ",
> +	"    |   [                ",
> +	"    [  ]                 ",
> +	"   /   |        __       ",
> +	"  \\|   |/     _/ /_      ",
> +	" \\ |   |//___/__/__/_    ",
> +	"\\\\  \\ /  //    -____/_   ",
> +	"//   \"   \\\\      \\___.-  ",
> +	" //     \\\\  __.----._/_  ",
> +	"/ //|||\\\\ .-         __> ",
> +	"[        /         __.-  ",
> +	"[        [           }   ",
> +	"\\        \\          /    ",
> +	" \"-._____ \\.____.--\"     ",
> +	"    |  | |  |            ",
> +	"    |  | |  |            ",
> +	"    |  | |  |            ",
> +	"    |  | |  |            ",
> +	"    {  } {  }            ",
> +	"    |  | |  |            ",
> +	"    |  | |  |            ",
> +	"    |  | |  |            ",
> +	"    /  { |  |            ",
> +	" .-\"   / [   -._         ",
> +	"/___/ /   \\ \\___\"-.      ",
> +	"    -\"     \"-            ",
> +	"                         ",
> +	"                         ",
> +	"                         ",
> +	"There's nothing more here, really.",
> +	"                         ",
> +	"                         ",
> +	"                         ",
> +	"...so far.               ",
> +	};

Great.  The only thing which troubles me is that this array contains a lot
of trailing spaces.  We don't have to print these trailing spaces, do we?


-- 
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/20190401/10523c1f/attachment.bin>


More information about the Strace-devel mailing list