-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmsShow-Linux
executable file
·223 lines (195 loc) · 7.54 KB
/
cmsShow-Linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/usr/bin/env bash
#set -x
checkOS()
{
# Only 64-bit arch supported, and OSX version 10.6 or more.
osname=`uname -s`
if [ f$osname = f"Darwin" ]; then
arch=`sysctl hw | grep 64bit | awk '{print $2;}'`
if [ $arch -eq 0 ]; then
echo "###################################"
echo "Only 64-bit OSX is supported!"
echo "###################################"
exit 1;
fi
osv=`sw_vers -productVersion |awk '{split($0,a,"\."); print a[1]a[2];}' `
if [ "$osv" -lt "108" ]; then
echo "#######################################"
echo "Only version 10.8 or greater supported!"
echo "#######################################"
exit 1;
fi
else
arch=`uname -m`
if [ f$arch != f"x86_64" -a f$arch != f"amd64" ]; then
echo "###################################"
echo "Only 64-bit GNU/linux is supported!"
echo "###################################"
exit 1
fi
fi
}
checkXConnection()
{
# Running via ssh can lead to dis-synchronization between server and
# client due to bugs and incompatibilities of GLX implementations.
# Here we apply some workarounds for known problems.
if [ f$osname != f"Darwin" -a -n "$SSH_CLIENT" ]; then
export LIBGL_NO_DRAWARRAYS=1
if ldd $ROOTSYS/lib/libRGL.so | grep libGL.so | grep -q nvidia; then
echo "################################################################################"
echo "# WARNING"
echo "################################################################################"
echo "You are running remotely on a machine that uses NVIDIA drivers."
echo "This is known to cause problems with some client configurations."
if [ -e /etc/redhat-release ]; then
grep -q 'Scientific Linux' /etc/redhat-release && grep -q '5.' /etc/redhat-release
is_sl5=$?
grep -q 'CentOS' /etc/redhat-release && grep -q '5.' /etc/redhat-release
is_centos5=$?
if [ $is_sl5 = 0 -o $is_centos5 = 0 ]; then
echo "We are running on SL5 or CentOS5."
if [ -e /usr/lib64/libGL.so.1.2 ]; then
echo "To avoid this problem libGL.so from MesaGL package will be preloaded."
export LD_PRELOAD=/usr/lib64/libGL.so.1.2:$LD_PRELOAD
else
echo "Can not find replacement libGL.so from MesaGL."
echo "If you run into trouble try installing mesa-libGL package on remote machine."
fi
fi
fi
echo "################################################################################"
fi
fi
# Require ZQuartz on 10.7 to avoid X11 freeze
if [ f$osname = f"Darwin" ]; then
osvt=`sw_vers -productVersion | awk '{if ( $1 >= 10.7 && $1 < 10.8 ) print $1;}'`
if [ -n "$osvt" ]; then
# echo "check quatz"
dispXOrg=`glxinfo | grep display | grep xquartz`
if [ -z "$dispXOrg" ]; then
echo "WARNING: XQuartz installation is required on OSX 10.7."
fi;
fi;
fi;
}
setupEnv()
{
# strip of the directory name for this shell script
export SHELLDIR=`dirname $0`
# if no directory specified we need to use the local directory
if [ ! -n "$SHELLDIR" ] || [ "$SHELLDIR" = "." ] ; then
export SHELLDIR=$PWD
fi
source "$SHELLDIR/env.sh"
export CMSSW_BASE=$SHELLDIR/cms/fwlite/$CMSSW_VERSION
for i in $SHELLDIR/cms/data-Fireworks-Geometry/*; do export CMSSW_SEARCH_PATH=$i:$CMSSW_SEARCH_PATH;done
. $SHELLDIR/lcg/root/6.12.07-gnimlf5/bin/thisroot.sh
for i in ` ls -d $SHELLDIR/external/*/*/lib`; do LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$i; done
}
printEnv()
{
# Needed only for debugging of a standalone version
for i in CMSSW_BASE CMSSW_SEARCH_PATH CMSSW_DATA_PATH LD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH PATH SHELLDIR; do
echo export $i=`eval echo \\$$i`
done
exit;
}
parseOptions()
{
# We store in originalOptions all the options that need to be passed to the
# actual cmsShow.exe executable but not those that are specific for the wrapper
# file itself.
while [ $# -gt 0 ]
do
case "$1" in
--soft) softflag=on ; originalOptions="${originalOptions} --soft";;
-d|--debug) debugflag=on; originalOptions="${originalOptions} --debug";;
-di|--debug-interactive) debuginteractiveflag=on;;
--valgrind) valgrindflag=on;;
--prompt) originalOptions="${originalOptions} $1 -r";;
--eve) originalOptions="${originalOptions} --eve -r";;
-r|--root-interactive) rootflag=on; originalOptions="${originalOptions} -r";;
*) originalOptions="$originalOptions $1";;
esac
shift
done
}
writeSystemInfoToFile()
{
file=$1
echo "" >> $file
echo "System Info" >> $file
uname -a >> $file
glxinfo >> $file
}
errorPrint()
{
# Wrap message to defined line width and add padding.
echo $2 | awk -v m=$1 '{ txt=$0; m-=4; \
ll=int(length(txt)/m) ; i=1; \
if (length(txt)>(m +2)) { \
{ print " # " substr(txt,0,m) " # "} \
while (i<ll) { { print " # " substr(txt,i*m+1,m) } i=i+1;} \
fmt=sprintf("%%%ds", ll*m + m + 1 -length(txt) ); x=sprintf(fmt, "#"); \
{ print " # " substr(txt,i*m+1,m) " " x " " } \
}\
else { \
fmt=sprintf("%%%ds", m +1 -length(txt) ); x=sprintf(fmt, "#"); \
{ print " # " (txt) " " x " "} } \
}'
}
################################################################################
# Main body of script starts here
################################################################################
setupEnv
if [ -z "$FROM_RELEASE" ]; then
checkOS
fi
checkXConnection
parseOptions $@
if [ "X$softflag" = "Xon" ] ; then
export LIBGL_ALWAYS_INDIRECT=1
export LIBGL_DRIVERS_PATH=/tmp/
export LIBGL_DEBUG=verbose
export MESA_DEBUG=1
fi
# Developers cases -- run from gdb or valgrind.
if [ "X$debuginteractiveflag" = Xon ] ; then
if [[ `uname` == 'Linux' ]]; then
gdbCmd="gdb --args cmsShow.exe $originalOptions"
else
gdbCmd="lldb -- cmsShow.exe $originalOptions"
fi
exec $gdbCmd
elif [ "X$valgrindflag" = Xon ] ; then
# MT: This should supposedly get rid of ROOT dicitonary reports etc. but it
# didn't seem to work very well when I tried it (so I disabled error limit).
# --suppressions=$ROOTSYS/etc/valgrind-root.supp
valgrind --num-callers=30 --log-file=valgrind.log.$$ --freelist-vol=100000000 \
--error-limit=no "cmsShow.exe" $originalOptions
exit;
fi
# Run cmsShow
creport=`mktemp /tmp/cmsshow-crash-report-XXXXXXXX`.txt
"cmsShow.exe" $originalOptions 2> >( tee $creport)
exitStatus=$?
if [ $exitStatus -gt 0 ] && [ $exitStatus -ne 137 ] && [ "$rootflag" != "on" ] ; then
writeSystemInfoToFile $creport
"$SHELLDIR/cmsShowSendReport" ${creport}
echo ""
msgLen=75;
awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }'
errorPrint $msgLen ""
errorPrint $msgLen " Abnormal program termination!"
errorPrint $msgLen ""
errorPrint $msgLen "Please send:"
errorPrint $msgLen "$creport"
errorPrint $msgLen "to hn-cms-visualization@cern.ch."
errorPrint $msgLen " "
awk -v msgLen=$msgLen 'BEGIN {printf(" %c", 35); i=0; while ( i <= msgLen) { printf( "%c", 35 ); ++i}; print ""; }'
echo ""
else
rm $creport;
fi
exit $exitStatus;