1#!/bin/sh 2 3set -e 4 5#--------------------------------------------------------------------- 6# This quick and dirty script assists in updating the C++ demangler 7# machinery in coregrind/m_demangle. 8# The script will check out 9# - old and new revisions of the C++ demangler related files from GCC's trunk 10# - m_demangle from valgrind's trunk. 11# It will assemble 12# - a patch file with local changes that were applied to the C++ 13# demangler to make it work within valgrind 14# - a directory new_m_demangle whose contents should be copied to 15# m_demangle in valgrind trunk 16# The patch will *not* be applied automatically. 17#--------------------------------------------------------------------- 18 19# You need to modify these revision numbers for your update. 20old_gcc_revision=r181975 # the revision of the previous update 21new_gcc_revision=r212125 # the revision for this update 22 23# Unless the organization of demangler related files has changed, no 24# changes below this line should be necessary. 25 26# Setup a temp directory 27DIR=/tmp/demangle 28 29rm -rf $DIR 30mkdir -p $DIR 31 32cd $DIR 33 34echo "Updating the demangler in $DIR" 35 36# 1) Check out files from old GCC revision 37echo "Checking out GCC files @ $old_gcc_revision" 38 39mkdir gcc-$old_gcc_revision 40cd gcc-$old_gcc_revision 41svn co -$old_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/libiberty libiberty > /dev/null 42svn co -$old_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/include include > /dev/null 43rm -rf libiberty/.svn 44rm -rf include/.svn 45cd .. 46 47# 2) Assemble the ones we need in $DIR/$old_gcc_revision 48mkdir $old_gcc_revision 49cd $old_gcc_revision 50cp ../gcc-$old_gcc_revision/include/ansidecl.h . 51cp ../gcc-$old_gcc_revision/include/demangle.h . 52cp ../gcc-$old_gcc_revision/include/dyn-string.h . 53cp ../gcc-$old_gcc_revision/include/safe-ctype.h . 54cp ../gcc-$old_gcc_revision/libiberty/cp-demangle.c . 55cp ../gcc-$old_gcc_revision/libiberty/cp-demangle.h . 56cp ../gcc-$old_gcc_revision/libiberty/cplus-dem.c . 57cp ../gcc-$old_gcc_revision/libiberty/dyn-string.c . 58cp ../gcc-$old_gcc_revision/libiberty/safe-ctype.c . 59cd .. 60 61# 3) Check out files from new GCC revision 62 63echo "Checking out GCC files @ $new_gcc_revision" 64mkdir gcc-$new_gcc_revision 65cd gcc-$new_gcc_revision 66svn co -$new_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/libiberty libiberty > /dev/null 67svn co -$new_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/include include > /dev/null 68rm -rf libiberty/.svn 69rm -rf include/.svn 70cd .. 71 72# 4) Assemble the ones we need in $DIR/$new_gcc_revision 73 74mkdir $new_gcc_revision 75cd $new_gcc_revision 76cp ../gcc-$new_gcc_revision/include/ansidecl.h . 77cp ../gcc-$new_gcc_revision/include/demangle.h . 78cp ../gcc-$new_gcc_revision/include/dyn-string.h . 79cp ../gcc-$new_gcc_revision/include/safe-ctype.h . 80cp ../gcc-$new_gcc_revision/libiberty/cp-demangle.c . 81cp ../gcc-$new_gcc_revision/libiberty/cp-demangle.h . 82cp ../gcc-$new_gcc_revision/libiberty/cplus-dem.c . 83cp ../gcc-$new_gcc_revision/libiberty/dyn-string.c . 84cp ../gcc-$new_gcc_revision/libiberty/safe-ctype.c . 85cd .. 86 87# 5) Check out valgrind coregrind/m_demangle into old_m_demangle 88echo "Checking out coregrind/m_demangle" 89svn co svn://svn.valgrind.org/valgrind/trunk/coregrind/m_demangle old_m_demangle > /dev/null 90rm -rf old_m_demangle/.svn 91 92# 6) Create new_m_demangle 93cp -rp old_m_demangle new_m_demangle 94cp -rp $new_gcc_revision/*.[ch] new_m_demangle 95 96# 7) Compare files from previous GCC revision against old_m_demangle 97# (This gets us the changes we made to the demangler). 98echo "Creating patch" 99set +e 100diff -r -u $old_gcc_revision old_m_demangle > our-changes 101echo "Patch file 'our-changes' created" 102 103# 7) See how the patch would apply 104echo "Attempting to apply the patch (but not actualy doing it)." 105cd new_m_demangle 106patch --dry -p1 < ../our-changes 107