3 # usttrace by Pierre-Marc Fournier 2009
4 # Distributed under the GPLv2.
7 LIBINTERFORK
="./libinterfork/.libs/libinterfork.so"
8 LIBMALLOCWRAP
="./libmallocwrap/.libs/libmallocwrap.so"
10 STD_LDLIBRARY_UST
="./libust/.libs:../liburcu"
12 BASE_TRACE_DIR
="$HOME/.usttraces"
15 echo "usage: $0 OPTIONS COMMAND" 2>/dev
/stderr
17 echo "Options:" 2>/dev
/stderr
18 echo " -l Runtime link with UST library." 2>/dev
/stderr
19 echo " (Needed only if program was not linked at compile time with libust.)" 2>/dev
/stderr
20 echo " -L Add path to ust libraries to LD_LIBRARY_PATH." 2>/dev
/stderr
21 echo " -m Instrument malloc calls." 2>/dev
/stderr
22 echo " -f Also trace forked processes." 2>/dev
/stderr
26 echo "$0: error: $1" 2>/dev
/stderr
29 while getopts ":hlLmf" options
; do
31 l
) arg_preload_libust
=1;;
33 m
) arg_preload_malloc
=1;;
34 f
) arg_preload_fork
=1;;
43 shift $
(($OPTIND - 1))
51 error
"no home specified"
56 error
"no command specified"
61 # Create directory for trace output
62 DATESTRING
="$(hostname)-$(date +%Y%m%d%H%M%S)"
63 OUTDIR
="$BASE_TRACE_DIR/$DATESTRING"
67 SOCKPATH
="/tmp/ust-sock-$$"
70 $USTD -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 &
73 # Establish the environment for the command
75 export UST_AUTOPROBE
=1
76 export UST_DAEMON_SOCKET
="$SOCKPATH"
78 if [ "$arg_preload_libust" = "1" ];
80 export LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:./libust/.libs"
81 export LD_PRELOAD
="$LD_PRELOAD:./libust/.libs/libust.so"
84 if [ "$arg_preload_malloc" = "1" ];
86 export LD_PRELOAD
="$LD_PRELOAD:./libmallocwrap/.libs/libmallocwrap.so"
89 if [ "$arg_preload_fork" = "1" ];
91 export LD_PRELOAD
="$LD_PRELOAD:./libinterfork/.libs/libinterfork.so"
94 if [ "$arg_ld_std_ust" = "1" ];
96 export LD_LIBRARY_PATH
="$LD_LIBRARY_PATH:$STD_LDLIBRARY_UST"
102 ## Because of the keepalive mechanism, we're sure that by the time
103 ## we get here, the daemon is connected to all the buffers that still exist.
104 ## Therefore we can politely ask it to die when it's done.
106 kill -SIGTERM "$USTDPID"
108 # Tell the daemon to die
109 echo "Waiting for ustd to shutdown..."
This page took 0.031383 seconds and 4 git commands to generate.