Debian Codegraph @

tools/scmp_app_inspector

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 #
4 # Runtime syscall inspector
5 #
6 # Copyright (c) 2012 Red Hat <[email protected]>
7 # Author: Paul Moore <[email protected]>
8 #
9
10 #
11 # This library is free software; you can redistribute it and/or modify it
12 # under the terms of version 2.1 of the GNU Lesser General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This library is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18 # for more details.
19 #
20 # You should have received a copy of the GNU Lesser General Public License
21 # along with this library; if not, see <http://www.gnu.org/licenses>.
22 #
23
24 ####
25 # functions
26
27 function verify_depsscip-shell shell shell-project 0.0.0 verify_deps().() {
28 [[ -z "$1" ]] && return
29 if ! whichscip-shell system . . which. "$1" >& /dev/null; then
30 echoscip-shell system . . echo. "error: install \"$1\" and include it in your \$PATH"
31 exit 1
32 fi
33 }
34
35 ####
36 # main
37
38 # verify script dependencies
39 verify_depsscip-shell shell shell-project 0.0.0 verify_deps(). strace
40 verify_depsscip-shell shell shell-project 0.0.0 verify_deps(). sed
41 verify_depsscip-shell shell shell-project 0.0.0 verify_deps(). sort
42 verify_depsscip-shell shell shell-project 0.0.0 verify_deps(). uniq
43
44 # get the command line arguments
45 opt_freq=0
46 opt_args=0
47 opt_out="/proc/self/fd/1scip-shell filesystem . . `/proc/self/fd/1`."
48 while getopts "afo:h" opt; do
49 case $opt in
50 a)
51 opt_args=1
52 ;;
53 f)
54 opt_freq=1
55 ;;
56 o)
57 opt_out="$OPTARG"
58 ;;
59 h|*)
60 echoscip-shell system . . echo. "usage $0 [-f] [-a] [-o <file>] <command> [<args>]"
61 exit 1
62 esac
63 done
64 shift $(exprscip-shell system . . expr. $OPTIND - 1)
65
66 # generate a temporary output file
67 raw=$(mktempscip-shell system . . mktemp. -t strace-raw_XXXXXX)
68 out="$raw-out"
69
70 # capture the strace output
71 strace -o $raw -- $*
72
73 # filter the raw strace
74 if [[ $opt_args -eq 0 ]]; then
75 if [[ $opt_freq -eq 0 ]]; then
76 catscip-shell system . . cat. $raw | sedscip-shell system . . sed. -e 's/(.*//' | sortscip-shell system . . sort. -u > $out
77 else
78 catscip-shell system . . cat. $raw | sedscip-shell system . . sed. -e 's/(.*//' | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. -c | sortscip-shell system . . sort. -nr > $out
79 fi
80 else
81 if [[ $opt_freq -eq 0 ]]; then
82 catscip-shell system . . cat. $raw | sedscip-shell system . . sed. -e 's/)[ \t]*=.*$/)/' \
83 | sedscip-shell system . . sed. -e 's/".*,/"...",/g;s/\/\*.*\*\//.../g' \
84 | sedscip-shell system . . sed. -e 's/0x[a-f0-9]\+/.../g' \
85 | sortscip-shell system . . sort. -u > $out
86 else
87 catscip-shell system . . cat. $raw | sedscip-shell system . . sed. -e 's/)[ \t]*=.*$/)/' \
88 | sedscip-shell system . . sed. -e 's/".*,/"...",/g;s/\/\*.*\*\//.../g' \
89 | sedscip-shell system . . sed. -e 's/0x[a-f0-9]\+/.../g' \
90 | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. -c | sortscip-shell system . . sort. -nr > $out
91 fi
92 fi
93
94 # display the output
95 echoscip-shell system . . echo. "============================================================" > $opt_out
96 echoscip-shell system . . echo. "Syscall Report (\"$*\")" >> $opt_out
97 [[ $opt_freq -eq 1 ]] && echoscip-shell system . . echo. " freq syscall" >> $opt_out
98 echoscip-shell system . . echo. "============================================================" >> $opt_out
99 catscip-shell system . . cat. $out >> $opt_out
100
101 # cleanup and exit
102 rmscip-shell system . . rm. -f $raw $out
103 exit 0