]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - malloc/memusage.sh
Use relaxed atomics for malloc have_fastchunks
[thirdparty/glibc.git] / malloc / memusage.sh
index be8f755a20e704d4efa9797f4e4cba0db9860cc1..93ece87a31979b54607f8e874a0d60e44477052d 100755 (executable)
@@ -1,5 +1,5 @@
 #! @BASH@
-# Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributed by Ulrich Drepper <drepper@gnu.org>, 1999.
 
 # Lesser General Public License for more details.
 
 # You should have received a copy of the GNU Lesser General Public
-# License along with the GNU C Library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA.
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
 
-memusageso=@SLIBDIR@/libmemusage.so
-memusagestat=@BINDIR@/memusagestat
+memusageso='@SLIBDIR@/libmemusage.so'
+memusagestat='@BINDIR@/memusagestat'
 TEXTDOMAIN=libc
 
 # Print usage message.
 do_usage() {
-  echo >&2 $"Try \`memusage --help' for more information."
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" memusage memusage
   exit 1
 }
 
 # Message for missing argument.
 do_missing_arg() {
-  echo >&2 $"memusage: option \`$1' requires an argument"
+  printf >&2 $"%s: option '%s' requires an argument\n" memusage "$1"
   do_usage
 }
 
@@ -44,7 +43,7 @@ Profile memory usage of PROGRAM.
    -d,--data=FILE         Generate binary data file and store it in FILE
    -u,--unbuffered        Don't buffer output
    -b,--buffer=SIZE       Collect SIZE entries before writing them out
-      --no-timer          Don't collect additional information though timer
+      --no-timer          Don't collect additional information through timer
    -m,--mmap              Also trace mmap & friends
 
    -?,--help              Print this help and exit
@@ -61,22 +60,32 @@ Profile memory usage of PROGRAM.
 Mandatory arguments to long options are also mandatory for any corresponding
 short options.
 
-For bug reporting instructions, please see:
-<http://www.gnu.org/software/libc/bugs.html>."
+"
+  printf $"For bug reporting instructions, please see:\\n%s.\\n" \
+    "@REPORT_BUGS_TO@"
   exit 0
 }
 
 do_version() {
-  echo 'memusage (GNU libc) @VERSION@'
+  echo 'memusage @PKGVERSION@@VERSION@'
   printf $"Copyright (C) %s Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-" "2004"
+" "2017"
   printf $"Written by %s.
 " "Ulrich Drepper"
   exit 0
 }
 
+# These variables are local
+buffer=
+data=
+memusagestat_args=
+notimer=
+png=
+progname=
+tracemmap=
+
 # Process arguments.  But stop as soon as the program name is found.
 while test $# -gt 0; do
   case "$1" in
@@ -88,9 +97,9 @@ while test $# -gt 0; do
     ;;
   --us | --usa | --usag | --usage)
     echo $"Syntax: memusage [--data=FILE] [--progname=NAME] [--png=FILE] [--unbuffered]
-            [--buffer=SIZE] [--no-timer] [--time-based] [--total]
-            [--title=STRING] [--x-size=SIZE] [--y-size=SIZE]
-            PROGRAM [PROGRAMOPTION]..."
+           [--buffer=SIZE] [--no-timer] [--time-based] [--total]
+           [--title=STRING] [--x-size=SIZE] [--y-size=SIZE]
+           PROGRAM [PROGRAMOPTION]..."
     exit 0
     ;;
   -n | --pr | --pro | --prog | --progn | --progna | --prognam | --progname)
@@ -213,15 +222,8 @@ datafile=
 if test -n "$data"; then
   datafile="$data"
 elif test -n "$png"; then
-  datafile=$(mktemp ${TMPDIR:-/tmp}/memusage.XXXXXX 2> /dev/null)
-  if test $? -ne 0; then
-    # Lame, but if there is no `mktemp' program the user cannot expect more.
-    if test "$RANDOM" != "$RANDOM"; then
-      datafile=${TMPDIR:-/tmp}/memusage.$RANDOM
-    else
-      datafile=${TMPDIR:-/tmp}/memusage.$$
-    fi
-  fi
+  datafile=$(mktemp -t memusage.XXXXXX) || exit
+  trap 'rm -f "$datafile"; exit 1' HUP INT QUIT TERM PIPE
 fi
 if test -n "$datafile"; then
   add_env="$add_env MEMUSAGE_OUTPUT=$datafile"