Blame elf/sotruss.sh

Packit 6c4009
#! @BASH@
Packit 6c4009
# Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 6c4009
# This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
# The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
# modify it under the terms of the GNU Lesser General Public
Packit 6c4009
# License as published by the Free Software Foundation; either
Packit 6c4009
# version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
# The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
# Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
# You should have received a copy of the GNU Lesser General Public
Packit 6c4009
# License along with the GNU C Library; if not, see
Packit 6c4009
# <http://www.gnu.org/licenses/>.
Packit 6c4009
Packit 6c4009
# We should be able to find the translation right at the beginning.
Packit 6c4009
TEXTDOMAIN=libc
Packit 6c4009
TEXTDOMAINDIR=@TEXTDOMAINDIR@
Packit 6c4009
Packit 6c4009
unset SOTRUSS_FROMLIST
Packit 6c4009
unset SOTRUSS_TOLIST
Packit 6c4009
unset SOTRUSS_OUTNAME
Packit 6c4009
unset SOTRUSS_EXIT
Packit 6c4009
unset SOTRUSS_NOINDENT
Packit 6c4009
SOTRUSS_WHICH=$$
Packit 6c4009
lib='@PREFIX@/$LIB/audit/sotruss-lib.so'
Packit 6c4009
Packit 6c4009
do_help() {
Packit 6c4009
  echo $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
Packit 6c4009
  -F, --from FROMLIST     Trace calls from objects on FROMLIST
Packit 6c4009
  -T, --to TOLIST         Trace calls to objects on TOLIST
Packit 6c4009
Packit 6c4009
  -e, --exit              Also show exits from the function calls
Packit 6c4009
  -f, --follow            Trace child processes
Packit 6c4009
  -o, --output FILENAME   Write output to FILENAME (or FILENAME.$PID in case
Packit 6c4009
			  -f is also used) instead of standard error
Packit 6c4009
Packit 6c4009
  -?, --help              Give this help list
Packit 6c4009
      --usage             Give a short usage message
Packit 6c4009
      --version           Print program version"
Packit 6c4009
Packit 6c4009
  echo
Packit 6c4009
  printf $"Mandatory arguments to long options are also mandatory for any corresponding\nshort options.\n"
Packit 6c4009
  echo
Packit 6c4009
Packit 6c4009
  printf $"For bug reporting instructions, please see:\\n%s.\\n" \
Packit 6c4009
    "@REPORT_BUGS_TO@"
Packit 6c4009
  exit 0
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
do_missing_arg() {
Packit 6c4009
  printf >&2 $"%s: option requires an argument -- '%s'\n" sotruss "$1"
Packit 6c4009
  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
Packit 6c4009
  exit 1
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
do_ambiguous() {
Packit 6c4009
  printf >&2 $"%s: option is ambiguous; possibilities:"
Packit 6c4009
  while test $# -gt 0; do
Packit 6c4009
    printf >&2 " '%s'" $1
Packit 6c4009
    shift
Packit 6c4009
  done
Packit 6c4009
  printf >&2 "\n"
Packit 6c4009
  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
Packit 6c4009
  exit 1
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
while test $# -gt 0; do
Packit 6c4009
  case "$1" in
Packit 6c4009
  --v | --ve | --ver | --vers | --versi | --versio | --version)
Packit 6c4009
    echo "sotruss @PKGVERSION@@VERSION@"
Packit 6c4009
    printf $"Copyright (C) %s Free Software Foundation, Inc.
Packit 6c4009
This is free software; see the source for copying conditions.  There is NO
Packit 6c4009
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit 6c4009
" "2018"
Packit 6c4009
    printf $"Written by %s.\n" "Ulrich Drepper"
Packit 6c4009
    exit 0
Packit 6c4009
    ;;
Packit 6c4009
  -\? | --h | --he | --hel | --help)
Packit 6c4009
    do_help
Packit 6c4009
    ;;
Packit 6c4009
  --u | --us | --usa | --usag | --usage)
Packit 6c4009
    printf $"Usage: %s [-ef] [-F FROMLIST] [-o FILENAME] [-T TOLIST] [--exit]
Packit 6c4009
	    [--follow] [--from FROMLIST] [--output FILENAME] [--to TOLIST]
Packit 6c4009
	    [--help] [--usage] [--version] [--]
Packit 6c4009
	    EXECUTABLE [EXECUTABLE-OPTION...]\n" sotruss
Packit 6c4009
    exit 0
Packit 6c4009
    ;;
Packit 6c4009
  -F | --fr | --fro | --from)
Packit 6c4009
    if test $# -eq 1; then
Packit 6c4009
      do_missing_arg "$1"
Packit 6c4009
    fi
Packit 6c4009
    shift
Packit 6c4009
    SOTRUSS_FROMLIST="$1"
Packit 6c4009
    ;;
Packit 6c4009
  -T | --t | --to)
Packit 6c4009
    if test $# -eq 1; then
Packit 6c4009
      do_missing_arg "$1"
Packit 6c4009
    fi
Packit 6c4009
    shift
Packit 6c4009
    SOTRUSS_TOLIST="$1"
Packit 6c4009
    ;;
Packit 6c4009
  -o | --o | --ou | --out | --outp | --outpu | --output)
Packit 6c4009
    if test $# -eq 1; then
Packit 6c4009
      do_missing_arg "$1"
Packit 6c4009
    fi
Packit 6c4009
    shift
Packit 6c4009
    SOTRUSS_OUTNAME="$1"
Packit 6c4009
    ;;
Packit 6c4009
  -f | --fo | --fol | --foll | --follo | --follow)
Packit 6c4009
    unset SOTRUSS_WHICH
Packit 6c4009
    ;;
Packit 6c4009
  -l | --l | --li | --lib)
Packit 6c4009
    if test $# -eq 1; then
Packit 6c4009
      do_missing_arg "$1"
Packit 6c4009
    fi
Packit 6c4009
    shift
Packit 6c4009
    lib="$1"
Packit 6c4009
    ;;
Packit 6c4009
  -e | --e | --ex | --exi | --exit)
Packit 6c4009
    SOTRUSS_EXIT=1
Packit 6c4009
    ;;
Packit 6c4009
  --f)
Packit 6c4009
    do_ambiguous '--from' '--follow'
Packit 6c4009
    ;;
Packit 6c4009
  --)
Packit 6c4009
    shift
Packit 6c4009
    break
Packit 6c4009
    ;;
Packit 6c4009
  -*)
Packit 6c4009
    printf >&2 $"%s: unrecognized option '%c%s'\n" sotruss '-' ${1#-}
Packit 6c4009
    printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
Packit 6c4009
    exit 1
Packit 6c4009
    ;;
Packit 6c4009
  *)
Packit 6c4009
    break
Packit 6c4009
    ;;
Packit 6c4009
  esac
Packit 6c4009
  shift
Packit 6c4009
done
Packit 6c4009
Packit 6c4009
export SOTRUSS_FROMLIST
Packit 6c4009
export SOTRUSS_TOLIST
Packit 6c4009
export SOTRUSS_OUTNAME
Packit 6c4009
export SOTRUSS_WHICH
Packit 6c4009
export SOTRUSS_EXIT
Packit 6c4009
export LD_AUDIT="$lib"
Packit 6c4009
Packit 6c4009
exec "$@"