]> granicus.if.org Git - strace/commitdiff
Print enabled optional features in strace version output
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 31 Jul 2017 16:52:01 +0000 (18:52 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 31 Jul 2017 18:04:22 +0000 (18:04 +0000)
In order to provide information to user what optionally built features
are available.

* strace.c (print_version): New variable "features".  Print features string
after non-liability disclaimer (or "(none)" in case it is empty).
(print_version) [USE_LIBUNWIND]: Concatenate "stack-unwind" into features
string.
* tests/strace-V.tests (getoption): New function.
Update check in accordance with updated output.

strace.c
tests/strace-V.test

index c503c3d12da35b3414426537b1732efffd842f89..0015ad50439f2dbb41a92e116ee730fc88c31e57 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -193,11 +193,19 @@ strerror(int err_no)
 static void
 print_version(void)
 {
+       static const char features[] =
+#ifdef USE_LIBUNWIND
+               " stack-unwind"
+#endif /* USE_LIBUNWIND */
+               "";
+
        printf("%s -- version %s\n"
               "Copyright (c) 1991-%s The strace developers <%s>.\n"
               "This is free software; see the source for copying conditions.  There is NO\n"
               "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
               PACKAGE_NAME, PACKAGE_VERSION, COPYRIGHT_YEAR, PACKAGE_URL);
+       printf("\nOptional features enabled:%s\n",
+              features[0] ? features : " (none)");
 }
 
 static void
index 37da9d1abd323262af91c23ef22f047bb20039da..ec1ca059da57347620c46a6d9f79e559f90af5c5 100755 (executable)
@@ -14,6 +14,23 @@ getstr()
                ../../config.h
 }
 
+# getoption OPTION YES_STRING [NO_STRING]
+#
+# Returns YES_STRING in case OPTION is enabled (present in config.h and has
+# a non-zero numeric value). Otherwise, NO_STRING (or empty string, if not
+# specified) is returned.
+getoption()
+{
+       local opt
+       opt=$(sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*([0-9]+)$/\1/p' \
+               ../../config.h)
+       if [ -n "$opt" -a "$opt" -ne 0 ]; then
+               printf "%s" "$2"
+       else
+               printf "%s" "${3-}"
+       fi
+}
+
 config_year=$(getstr COPYRIGHT_YEAR)
 
 [ "$year" -ge "$config_year" ] && [ "$config_year" -ge 2017 ] || {
@@ -21,11 +38,18 @@ config_year=$(getstr COPYRIGHT_YEAR)
        exit 1
 }
 
+option_unwind=$(getoption USE_LIBUNWIND " stack-unwind")
+
+features="${option_unwind}"
+[ -n "$features" ] || features=" (none)"
+
 cat > "$EXP" << __EOF__
 $(getstr PACKAGE_NAME) -- version $(getstr PACKAGE_VERSION)
 Copyright (c) 1991-${config_year} The strace developers <$(getstr 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__
 
 match_diff "$LOG" "$EXP"