sotruss 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #! /bin/bash
  2. # Copyright (C) 2011-2021 Free Software Foundation, Inc.
  3. # This file is part of the GNU C Library.
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2.1 of the License, or (at your option) any later version.
  8. # The GNU C Library is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # Lesser General Public License for more details.
  12. # You should have received a copy of the GNU Lesser General Public
  13. # License along with the GNU C Library; if not, see
  14. # <https://www.gnu.org/licenses/>.
  15. # We should be able to find the translation right at the beginning.
  16. TEXTDOMAIN=libc
  17. TEXTDOMAINDIR=/usr/share/locale
  18. unset SOTRUSS_FROMLIST
  19. unset SOTRUSS_TOLIST
  20. unset SOTRUSS_OUTNAME
  21. unset SOTRUSS_EXIT
  22. unset SOTRUSS_NOINDENT
  23. SOTRUSS_WHICH=$$
  24. lib='/usr/$LIB/audit/sotruss-lib.so'
  25. do_help() {
  26. echo $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
  27. -F, --from FROMLIST Trace calls from objects on FROMLIST
  28. -T, --to TOLIST Trace calls to objects on TOLIST
  29. -e, --exit Also show exits from the function calls
  30. -f, --follow Trace child processes
  31. -o, --output FILENAME Write output to FILENAME (or FILENAME.$PID in case
  32. -f is also used) instead of standard error
  33. -?, --help Give this help list
  34. --usage Give a short usage message
  35. --version Print program version"
  36. echo
  37. printf $"Mandatory arguments to long options are also mandatory for any corresponding\nshort options.\n"
  38. echo
  39. printf $"For bug reporting instructions, please see:\\n%s.\\n" \
  40. "<https://bugs.linaro.org/>"
  41. exit 0
  42. }
  43. do_missing_arg() {
  44. printf >&2 $"%s: option requires an argument -- '%s'\n" sotruss "$1"
  45. printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
  46. exit 1
  47. }
  48. do_ambiguous() {
  49. printf >&2 $"%s: option is ambiguous; possibilities:"
  50. while test $# -gt 0; do
  51. printf >&2 " '%s'" $1
  52. shift
  53. done
  54. printf >&2 "\n"
  55. printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
  56. exit 1
  57. }
  58. while test $# -gt 0; do
  59. case "$1" in
  60. --v | --ve | --ver | --vers | --versi | --versio | --version)
  61. echo "sotruss (GNU) 2.33"
  62. printf $"Copyright (C) %s Free Software Foundation, Inc.
  63. This is free software; see the source for copying conditions. There is NO
  64. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  65. " "2021"
  66. printf $"Written by %s.\n" "Ulrich Drepper"
  67. exit 0
  68. ;;
  69. -\? | --h | --he | --hel | --help)
  70. do_help
  71. ;;
  72. --u | --us | --usa | --usag | --usage)
  73. printf $"Usage: %s [-ef] [-F FROMLIST] [-o FILENAME] [-T TOLIST] [--exit]
  74. [--follow] [--from FROMLIST] [--output FILENAME] [--to TOLIST]
  75. [--help] [--usage] [--version] [--]
  76. EXECUTABLE [EXECUTABLE-OPTION...]\n" sotruss
  77. exit 0
  78. ;;
  79. -F | --fr | --fro | --from)
  80. if test $# -eq 1; then
  81. do_missing_arg "$1"
  82. fi
  83. shift
  84. SOTRUSS_FROMLIST="$1"
  85. ;;
  86. -T | --t | --to)
  87. if test $# -eq 1; then
  88. do_missing_arg "$1"
  89. fi
  90. shift
  91. SOTRUSS_TOLIST="$1"
  92. ;;
  93. -o | --o | --ou | --out | --outp | --outpu | --output)
  94. if test $# -eq 1; then
  95. do_missing_arg "$1"
  96. fi
  97. shift
  98. SOTRUSS_OUTNAME="$1"
  99. ;;
  100. -f | --fo | --fol | --foll | --follo | --follow)
  101. unset SOTRUSS_WHICH
  102. ;;
  103. -l | --l | --li | --lib)
  104. if test $# -eq 1; then
  105. do_missing_arg "$1"
  106. fi
  107. shift
  108. lib="$1"
  109. ;;
  110. -e | --e | --ex | --exi | --exit)
  111. SOTRUSS_EXIT=1
  112. ;;
  113. --f)
  114. do_ambiguous '--from' '--follow'
  115. ;;
  116. --)
  117. shift
  118. break
  119. ;;
  120. -*)
  121. printf >&2 $"%s: unrecognized option '%c%s'\n" sotruss '-' ${1#-}
  122. printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
  123. exit 1
  124. ;;
  125. *)
  126. break
  127. ;;
  128. esac
  129. shift
  130. done
  131. export SOTRUSS_FROMLIST
  132. export SOTRUSS_TOLIST
  133. export SOTRUSS_OUTNAME
  134. export SOTRUSS_WHICH
  135. export SOTRUSS_EXIT
  136. export LD_AUDIT="$lib"
  137. exec "$@"