aoqi@0: #!/bin/bash aoqi@0: # aoqi@0: # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: aoqi@0: # MANUAL aoqi@0: # aoqi@0: # ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir aoqi@0: # aoqi@0: # Compares object files aoqi@0: # aoqi@0: aoqi@0: if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then aoqi@0: echo "bash ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir " aoqi@0: echo "" aoqi@0: echo "Compare object files" aoqi@0: echo "" aoqi@0: exit 10 aoqi@0: fi aoqi@0: aoqi@0: ####### aoqi@0: # aoqi@0: # List of files (grep patterns) that are ignored aoqi@0: # aoqi@0: # 1) hotspot object files aoqi@0: IGNORE="-e hotspot" aoqi@0: aoqi@0: # 2) various build artifacts: sizer.32.o sizer.64.o dummyodbc.o aoqi@0: # these are produced during build and then e.g run to produce other data aoqi@0: # i.e not directly put into build => safe to ignore aoqi@0: IGNORE="${IGNORE} -e sizer.32.o -e sizer.64.o" aoqi@0: IGNORE="${IGNORE} -e dummyodbc.o" aoqi@0: IGNORE="${IGNORE} -e genSolarisConstants.o" aoqi@0: IGNORE="${IGNORE} -e genUnixConstants.o" aoqi@0: aoqi@0: OLD="$1" aoqi@0: NEW="$2" aoqi@0: shift; shift aoqi@0: PATTERN="$*" aoqi@0: aoqi@0: if [ -f $NEW/spec.sh ]; then aoqi@0: . $NEW/spec.sh aoqi@0: elif [ -f $NEW/../../spec.sh ]; then aoqi@0: . $NEW/../../spec.sh aoqi@0: elif [ -f $OLD/spec.sh ]; then aoqi@0: . $OLD/spec.sh aoqi@0: elif [ -f $OLD/../../spec.sh ]; then aoqi@0: . $OLD/../../spec.sh aoqi@0: else aoqi@0: echo "Unable to find spec.sh" aoqi@0: echo "Giving up" aoqi@0: exit 1 aoqi@0: fi aoqi@0: aoqi@0: export COMPARE_ROOT=/tmp/cimages.$USER/objects aoqi@0: mkdir -p $COMPARE_ROOT aoqi@0: aoqi@0: (${CD} $OLD && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.old aoqi@0: (${CD} $NEW && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.new aoqi@0: aoqi@0: # On macosx JobjC is build in both i386 and x86_64 variant (universial binary) aoqi@0: # but new build only builds the x86_64 aoqi@0: # Remove the 386 variants from comparison...to avoid "false" positives aoqi@0: ${GREP} -v 'JObjC.dst/Objects-normal/i386' $COMPARE_ROOT/list.old > $COMPARE_ROOT/list.old.new aoqi@0: ${CP} $COMPARE_ROOT/list.old $COMPARE_ROOT/list.old.full aoqi@0: ${CP} $COMPARE_ROOT/list.old.new $COMPARE_ROOT/list.old aoqi@0: aoqi@0: findnew() { aoqi@0: arg_1=$1 aoqi@0: arg_2=$2 aoqi@0: aoqi@0: # special case 1 unpack-cmd => unpackexe aoqi@0: arg_1=`${ECHO} $arg_1 | ${SED} 's!unpack-cmd!unpackexe!g'` aoqi@0: arg_2=`${ECHO} $arg_2 | ${SED} 's!unpack-cmd!unpackexe!g'` aoqi@0: aoqi@0: # special case 2 /JObjC.dst/ => /libjobjc/ aoqi@0: arg_1=`${ECHO} $arg_1 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'` aoqi@0: arg_2=`${ECHO} $arg_2 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'` aoqi@0: aoqi@0: full=`${ECHO} $arg_1 | ${SED} 's!\.!\\\.!g'` aoqi@0: medium=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*/[^/]*\)!\1!'` aoqi@0: short=`${ECHO} $arg_2 | ${SED} 's!\.!\\\.!g'` aoqi@0: if [ "`${GREP} -c "/$full" $COMPARE_ROOT/list.new`" -eq 1 ] aoqi@0: then aoqi@0: ${ECHO} $NEW/$arg_1 aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: if [ "`${GREP} -c "$medium" $COMPARE_ROOT/list.new`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} "$medium" $COMPARE_ROOT/list.new aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: if [ "`${GREP} -c "/$short" $COMPARE_ROOT/list.new`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} "/$short" $COMPARE_ROOT/list.new aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: # old style has "dir" before obj{64} aoqi@0: dir=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*\)/obj[64]*.*!\1!g'` aoqi@0: if [ -n "$dir" -a "$dir" != "$arg_1" ] aoqi@0: then aoqi@0: if [ "`${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} "/$short" aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: # Try with lib$dir/ aoqi@0: if [ "`${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} "/$short" aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: # Try with $dir_objs aoqi@0: if [ "`${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} "/$short" aoqi@0: return aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: # check for some specifics... aoqi@0: for i in demo hotspot jobjc aoqi@0: do aoqi@0: if [ "`${ECHO} $full | ${GREP} -c $i`" -gt 0 ] aoqi@0: then aoqi@0: if [ "`${GREP} $i $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} $i $COMPARE_ROOT/list.new | ${GREP} "/$short" aoqi@0: return aoqi@0: fi aoqi@0: fi aoqi@0: done aoqi@0: aoqi@0: # check for specific demo aoqi@0: demo=`${ECHO} $arg_1 | ${SED} 's!.*/demo/jvmti/\([^/]*\)/.*!\1!g'` aoqi@0: if [ -n "$demo" -a "$dir" != "$demo" ] aoqi@0: then aoqi@0: if [ "`${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ] aoqi@0: then aoqi@0: ${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} "/$short" aoqi@0: return aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: return aoqi@0: } aoqi@0: aoqi@0: compare() { aoqi@0: old=$1 aoqi@0: new=$2 aoqi@0: ${DIFF} $old $new > /dev/null aoqi@0: res=$? aoqi@0: if [ $res -eq 0 ] aoqi@0: then aoqi@0: ${ECHO} 0 aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: # check if stripped objects gives equality aoqi@0: ${CP} $old $COMPARE_ROOT/`basename $old`.old aoqi@0: ${CP} $new $COMPARE_ROOT/`basename $old`.new aoqi@0: ${POST_STRIP_CMD} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null 2>&1 aoqi@0: ${DIFF} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null aoqi@0: res=$? aoqi@0: ${RM} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new aoqi@0: if [ $res -eq 0 ] aoqi@0: then aoqi@0: ${ECHO} S aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: name=`basename $1 | ${SED} 's!\.o!!'` aoqi@0: cntold=`strings $old | ${GREP} -c $name` aoqi@0: cntnew=`strings $new | ${GREP} -c $name` aoqi@0: aoqi@0: if [ $cntold -gt 0 -a $cntnew -gt 0 ] aoqi@0: then aoqi@0: ${ECHO} F aoqi@0: return aoqi@0: fi aoqi@0: aoqi@0: ${ECHO} 1 aoqi@0: } aoqi@0: aoqi@0: for F in `${CAT} $COMPARE_ROOT/list.old` aoqi@0: do aoqi@0: if [ "${IGNORE}" ] && [ "`${ECHO} $F | ${GREP} ${IGNORE}`" ] aoqi@0: then aoqi@0: # aoqi@0: # skip ignored files aoqi@0: # aoqi@0: continue; aoqi@0: fi aoqi@0: aoqi@0: if [ "$PATTERN" ] && [ `${ECHO} $F | ${GREP} -c $PATTERN` -eq 0 ] aoqi@0: then aoqi@0: continue; aoqi@0: fi aoqi@0: aoqi@0: f=`basename $F` aoqi@0: o=$OLD/$F aoqi@0: n=`findnew $F $f` aoqi@0: aoqi@0: if [ "$n" ] aoqi@0: then aoqi@0: n="$NEW/$n" aoqi@0: ${ECHO} `compare $o $n` : $f : $o : $n aoqi@0: else aoqi@0: ${ECHO} "- : $f : $o " aoqi@0: fi aoqi@0: done