Thu, 19 Apr 2018 08:51:17 +0000
Merge
erikj@459 | 1 | #!/bin/bash |
erikj@459 | 2 | # |
erikj@459 | 3 | # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
erikj@459 | 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
erikj@459 | 5 | # |
erikj@459 | 6 | # This code is free software; you can redistribute it and/or modify it |
erikj@459 | 7 | # under the terms of the GNU General Public License version 2 only, as |
erikj@459 | 8 | # published by the Free Software Foundation. |
erikj@459 | 9 | # |
erikj@459 | 10 | # This code is distributed in the hope that it will be useful, but WITHOUT |
erikj@459 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
erikj@459 | 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
erikj@459 | 13 | # version 2 for more details (a copy is included in the LICENSE file that |
erikj@459 | 14 | # accompanied this code). |
erikj@459 | 15 | # |
erikj@459 | 16 | # You should have received a copy of the GNU General Public License version |
erikj@459 | 17 | # 2 along with this work; if not, write to the Free Software Foundation, |
erikj@459 | 18 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
erikj@459 | 19 | # |
erikj@459 | 20 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
erikj@459 | 21 | # or visit www.oracle.com if you need additional information or have any |
erikj@459 | 22 | # questions. |
erikj@459 | 23 | # |
erikj@459 | 24 | |
erikj@459 | 25 | # MANUAL |
erikj@459 | 26 | # |
erikj@459 | 27 | # ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir |
erikj@459 | 28 | # |
erikj@459 | 29 | # Compares object files |
erikj@459 | 30 | # |
erikj@459 | 31 | |
erikj@459 | 32 | if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then |
ohair@478 | 33 | echo "bash ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir <pattern>" |
erikj@459 | 34 | echo "" |
erikj@459 | 35 | echo "Compare object files" |
erikj@459 | 36 | echo "" |
erikj@459 | 37 | exit 10 |
erikj@459 | 38 | fi |
erikj@459 | 39 | |
erikj@459 | 40 | ####### |
erikj@459 | 41 | # |
erikj@459 | 42 | # List of files (grep patterns) that are ignored |
erikj@459 | 43 | # |
erikj@459 | 44 | # 1) hotspot object files |
erikj@459 | 45 | IGNORE="-e hotspot" |
erikj@459 | 46 | |
erikj@459 | 47 | # 2) various build artifacts: sizer.32.o sizer.64.o dummyodbc.o |
erikj@459 | 48 | # these are produced during build and then e.g run to produce other data |
erikj@459 | 49 | # i.e not directly put into build => safe to ignore |
erikj@459 | 50 | IGNORE="${IGNORE} -e sizer.32.o -e sizer.64.o" |
erikj@459 | 51 | IGNORE="${IGNORE} -e dummyodbc.o" |
erikj@459 | 52 | IGNORE="${IGNORE} -e genSolarisConstants.o" |
erikj@459 | 53 | IGNORE="${IGNORE} -e genUnixConstants.o" |
erikj@459 | 54 | |
erikj@459 | 55 | OLD="$1" |
erikj@459 | 56 | NEW="$2" |
erikj@459 | 57 | shift; shift |
erikj@459 | 58 | PATTERN="$*" |
erikj@459 | 59 | |
erikj@459 | 60 | if [ -f $NEW/spec.sh ]; then |
erikj@459 | 61 | . $NEW/spec.sh |
erikj@459 | 62 | elif [ -f $NEW/../../spec.sh ]; then |
erikj@459 | 63 | . $NEW/../../spec.sh |
erikj@459 | 64 | elif [ -f $OLD/spec.sh ]; then |
erikj@459 | 65 | . $OLD/spec.sh |
erikj@459 | 66 | elif [ -f $OLD/../../spec.sh ]; then |
erikj@459 | 67 | . $OLD/../../spec.sh |
erikj@459 | 68 | else |
erikj@459 | 69 | echo "Unable to find spec.sh" |
erikj@459 | 70 | echo "Giving up" |
erikj@459 | 71 | exit 1 |
erikj@459 | 72 | fi |
erikj@459 | 73 | |
erikj@459 | 74 | export COMPARE_ROOT=/tmp/cimages.$USER/objects |
erikj@459 | 75 | mkdir -p $COMPARE_ROOT |
erikj@459 | 76 | |
erikj@459 | 77 | (${CD} $OLD && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.old |
erikj@459 | 78 | (${CD} $NEW && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.new |
erikj@459 | 79 | |
erikj@459 | 80 | # On macosx JobjC is build in both i386 and x86_64 variant (universial binary) |
erikj@459 | 81 | # but new build only builds the x86_64 |
erikj@459 | 82 | # Remove the 386 variants from comparison...to avoid "false" positives |
erikj@459 | 83 | ${GREP} -v 'JObjC.dst/Objects-normal/i386' $COMPARE_ROOT/list.old > $COMPARE_ROOT/list.old.new |
erikj@459 | 84 | ${CP} $COMPARE_ROOT/list.old $COMPARE_ROOT/list.old.full |
erikj@459 | 85 | ${CP} $COMPARE_ROOT/list.old.new $COMPARE_ROOT/list.old |
erikj@459 | 86 | |
erikj@459 | 87 | findnew() { |
erikj@459 | 88 | arg_1=$1 |
erikj@459 | 89 | arg_2=$2 |
erikj@459 | 90 | |
erikj@459 | 91 | # special case 1 unpack-cmd => unpackexe |
erikj@459 | 92 | arg_1=`${ECHO} $arg_1 | ${SED} 's!unpack-cmd!unpackexe!g'` |
erikj@459 | 93 | arg_2=`${ECHO} $arg_2 | ${SED} 's!unpack-cmd!unpackexe!g'` |
erikj@459 | 94 | |
erikj@459 | 95 | # special case 2 /JObjC.dst/ => /libjobjc/ |
erikj@459 | 96 | arg_1=`${ECHO} $arg_1 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'` |
erikj@459 | 97 | arg_2=`${ECHO} $arg_2 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'` |
erikj@459 | 98 | |
erikj@459 | 99 | full=`${ECHO} $arg_1 | ${SED} 's!\.!\\\.!g'` |
erikj@459 | 100 | medium=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*/[^/]*\)!\1!'` |
erikj@459 | 101 | short=`${ECHO} $arg_2 | ${SED} 's!\.!\\\.!g'` |
erikj@459 | 102 | if [ "`${GREP} -c "/$full" $COMPARE_ROOT/list.new`" -eq 1 ] |
erikj@459 | 103 | then |
erikj@459 | 104 | ${ECHO} $NEW/$arg_1 |
erikj@459 | 105 | return |
erikj@459 | 106 | fi |
erikj@459 | 107 | |
erikj@459 | 108 | if [ "`${GREP} -c "$medium" $COMPARE_ROOT/list.new`" -eq 1 ] |
erikj@459 | 109 | then |
erikj@459 | 110 | ${GREP} "$medium" $COMPARE_ROOT/list.new |
erikj@459 | 111 | return |
erikj@459 | 112 | fi |
erikj@459 | 113 | |
erikj@459 | 114 | if [ "`${GREP} -c "/$short" $COMPARE_ROOT/list.new`" -eq 1 ] |
erikj@459 | 115 | then |
erikj@459 | 116 | ${GREP} "/$short" $COMPARE_ROOT/list.new |
erikj@459 | 117 | return |
erikj@459 | 118 | fi |
erikj@459 | 119 | |
erikj@459 | 120 | # old style has "dir" before obj{64} |
erikj@459 | 121 | dir=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*\)/obj[64]*.*!\1!g'` |
erikj@459 | 122 | if [ -n "$dir" -a "$dir" != "$arg_1" ] |
erikj@459 | 123 | then |
erikj@459 | 124 | if [ "`${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] |
erikj@459 | 125 | then |
erikj@459 | 126 | ${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} "/$short" |
erikj@459 | 127 | return |
erikj@459 | 128 | fi |
erikj@459 | 129 | |
erikj@459 | 130 | # Try with lib$dir/ |
erikj@459 | 131 | if [ "`${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] |
erikj@459 | 132 | then |
erikj@459 | 133 | ${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} "/$short" |
erikj@459 | 134 | return |
erikj@459 | 135 | fi |
erikj@459 | 136 | |
erikj@459 | 137 | # Try with $dir_objs |
erikj@459 | 138 | if [ "`${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] |
erikj@459 | 139 | then |
erikj@459 | 140 | ${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} "/$short" |
erikj@459 | 141 | return |
erikj@459 | 142 | fi |
erikj@459 | 143 | fi |
erikj@459 | 144 | |
erikj@459 | 145 | # check for some specifics... |
erikj@459 | 146 | for i in demo hotspot jobjc |
erikj@459 | 147 | do |
erikj@459 | 148 | if [ "`${ECHO} $full | ${GREP} -c $i`" -gt 0 ] |
erikj@459 | 149 | then |
erikj@459 | 150 | if [ "`${GREP} $i $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] |
erikj@459 | 151 | then |
erikj@459 | 152 | ${GREP} $i $COMPARE_ROOT/list.new | ${GREP} "/$short" |
erikj@459 | 153 | return |
erikj@459 | 154 | fi |
erikj@459 | 155 | fi |
erikj@459 | 156 | done |
erikj@459 | 157 | |
erikj@459 | 158 | # check for specific demo |
erikj@459 | 159 | demo=`${ECHO} $arg_1 | ${SED} 's!.*/demo/jvmti/\([^/]*\)/.*!\1!g'` |
erikj@459 | 160 | if [ -n "$demo" -a "$dir" != "$demo" ] |
erikj@459 | 161 | then |
erikj@459 | 162 | if [ "`${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] |
erikj@459 | 163 | then |
erikj@459 | 164 | ${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} "/$short" |
erikj@459 | 165 | return |
erikj@459 | 166 | fi |
erikj@459 | 167 | fi |
erikj@459 | 168 | |
erikj@459 | 169 | return |
erikj@459 | 170 | } |
erikj@459 | 171 | |
erikj@459 | 172 | compare() { |
erikj@459 | 173 | old=$1 |
erikj@459 | 174 | new=$2 |
erikj@459 | 175 | ${DIFF} $old $new > /dev/null |
erikj@459 | 176 | res=$? |
erikj@459 | 177 | if [ $res -eq 0 ] |
erikj@459 | 178 | then |
erikj@459 | 179 | ${ECHO} 0 |
erikj@459 | 180 | return |
erikj@459 | 181 | fi |
erikj@459 | 182 | |
erikj@459 | 183 | # check if stripped objects gives equality |
erikj@459 | 184 | ${CP} $old $COMPARE_ROOT/`basename $old`.old |
erikj@459 | 185 | ${CP} $new $COMPARE_ROOT/`basename $old`.new |
erikj@459 | 186 | ${POST_STRIP_CMD} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null 2>&1 |
erikj@459 | 187 | ${DIFF} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null |
erikj@459 | 188 | res=$? |
erikj@459 | 189 | ${RM} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new |
erikj@459 | 190 | if [ $res -eq 0 ] |
erikj@459 | 191 | then |
erikj@459 | 192 | ${ECHO} S |
erikj@459 | 193 | return |
erikj@459 | 194 | fi |
erikj@459 | 195 | |
erikj@459 | 196 | name=`basename $1 | ${SED} 's!\.o!!'` |
erikj@459 | 197 | cntold=`strings $old | ${GREP} -c $name` |
erikj@459 | 198 | cntnew=`strings $new | ${GREP} -c $name` |
erikj@459 | 199 | |
erikj@459 | 200 | if [ $cntold -gt 0 -a $cntnew -gt 0 ] |
erikj@459 | 201 | then |
erikj@459 | 202 | ${ECHO} F |
erikj@459 | 203 | return |
erikj@459 | 204 | fi |
erikj@459 | 205 | |
erikj@459 | 206 | ${ECHO} 1 |
erikj@459 | 207 | } |
erikj@459 | 208 | |
erikj@459 | 209 | for F in `${CAT} $COMPARE_ROOT/list.old` |
erikj@459 | 210 | do |
erikj@459 | 211 | if [ "${IGNORE}" ] && [ "`${ECHO} $F | ${GREP} ${IGNORE}`" ] |
erikj@459 | 212 | then |
erikj@459 | 213 | # |
erikj@459 | 214 | # skip ignored files |
erikj@459 | 215 | # |
erikj@459 | 216 | continue; |
erikj@459 | 217 | fi |
erikj@459 | 218 | |
erikj@459 | 219 | if [ "$PATTERN" ] && [ `${ECHO} $F | ${GREP} -c $PATTERN` -eq 0 ] |
erikj@459 | 220 | then |
erikj@459 | 221 | continue; |
erikj@459 | 222 | fi |
erikj@459 | 223 | |
erikj@459 | 224 | f=`basename $F` |
erikj@459 | 225 | o=$OLD/$F |
erikj@459 | 226 | n=`findnew $F $f` |
erikj@459 | 227 | |
erikj@459 | 228 | if [ "$n" ] |
erikj@459 | 229 | then |
erikj@459 | 230 | n="$NEW/$n" |
erikj@459 | 231 | ${ECHO} `compare $o $n` : $f : $o : $n |
erikj@459 | 232 | else |
erikj@459 | 233 | ${ECHO} "- : $f : $o " |
erikj@459 | 234 | fi |
erikj@459 | 235 | done |