florian | e44b9cd | 2011-12-10 16:03:57 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | set -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 |
| 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 |
florian | a70dfab | 2011-12-10 16:06:57 +0000 | [diff] [blame] | 14 | # - a directory new_m_demangle whose contents should be copied to |
florian | e44b9cd | 2011-12-10 16:03:57 +0000 | [diff] [blame] | 15 | # m_demangle in valgrind trunk |
| 16 | # The patch will *not* be applied automacially. |
| 17 | #--------------------------------------------------------------------- |
| 18 | |
| 19 | # You need to modify these revision numbers for your update. |
| 20 | old_gcc_revision=r141363 # the revision of the previous update |
| 21 | new_gcc_revision=r181975 # 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 |
| 27 | DIR=/tmp/demangle |
| 28 | |
| 29 | rm -rf $DIR |
| 30 | mkdir -p $DIR |
| 31 | |
| 32 | cd $DIR |
| 33 | |
| 34 | echo "Updating the demangler in $DIR" |
| 35 | |
| 36 | # 1) Check out files from old GCC revision |
| 37 | echo "Checking out GCC files @ $old_gcc_revision" |
| 38 | |
| 39 | mkdir gcc-$old_gcc_revision |
| 40 | cd gcc-$old_gcc_revision |
| 41 | svn co -$old_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/libiberty libiberty > /dev/null |
| 42 | svn co -$old_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/include include > /dev/null |
| 43 | rm -rf libiberty/.svn |
| 44 | rm -rf include/.svn |
| 45 | cd .. |
| 46 | |
| 47 | # 2) Assemble the ones we need in $DIR/$old_gcc_revision |
| 48 | mkdir $old_gcc_revision |
| 49 | cd $old_gcc_revision |
| 50 | cp ../gcc-$old_gcc_revision/include/ansidecl.h . |
| 51 | cp ../gcc-$old_gcc_revision/include/demangle.h . |
| 52 | cp ../gcc-$old_gcc_revision/include/dyn-string.h . |
| 53 | cp ../gcc-$old_gcc_revision/include/safe-ctype.h . |
| 54 | cp ../gcc-$old_gcc_revision/libiberty/cp-demangle.c . |
| 55 | cp ../gcc-$old_gcc_revision/libiberty/cp-demangle.h . |
| 56 | cp ../gcc-$old_gcc_revision/libiberty/cplus-dem.c . |
| 57 | cp ../gcc-$old_gcc_revision/libiberty/dyn-string.c . |
| 58 | cp ../gcc-$old_gcc_revision/libiberty/safe-ctype.c . |
| 59 | cd .. |
| 60 | |
| 61 | # 3) Check out files from new GCC revision |
| 62 | |
| 63 | echo "Checking out GCC files @ $new_gcc_revision" |
| 64 | mkdir gcc-$new_gcc_revision |
| 65 | cd gcc-$new_gcc_revision |
| 66 | svn co -$new_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/libiberty libiberty > /dev/null |
| 67 | svn co -$new_gcc_revision svn://gcc.gnu.org/svn/gcc/trunk/include include > /dev/null |
| 68 | rm -rf libiberty/.svn |
| 69 | rm -rf include/.svn |
| 70 | cd .. |
| 71 | |
| 72 | # 4) Assemble the ones we need in $DIR/$new_gcc_revision |
| 73 | |
| 74 | mkdir $new_gcc_revision |
| 75 | cd $new_gcc_revision |
| 76 | cp ../gcc-$new_gcc_revision/include/ansidecl.h . |
| 77 | cp ../gcc-$new_gcc_revision/include/demangle.h . |
| 78 | cp ../gcc-$new_gcc_revision/include/dyn-string.h . |
| 79 | cp ../gcc-$new_gcc_revision/include/safe-ctype.h . |
| 80 | cp ../gcc-$new_gcc_revision/libiberty/cp-demangle.c . |
| 81 | cp ../gcc-$new_gcc_revision/libiberty/cp-demangle.h . |
| 82 | cp ../gcc-$new_gcc_revision/libiberty/cplus-dem.c . |
| 83 | cp ../gcc-$new_gcc_revision/libiberty/dyn-string.c . |
| 84 | cp ../gcc-$new_gcc_revision/libiberty/safe-ctype.c . |
| 85 | cd .. |
| 86 | |
| 87 | # 5) Check out valgrind coregrind/m_demangle into old_m_demangle |
| 88 | echo "Checking out coregrind/m_demangle" |
| 89 | svn co svn://svn.valgrind.org/valgrind/trunk/coregrind/m_demangle old_m_demangle > /dev/null |
| 90 | rm -rf old_m_demangle/.svn |
| 91 | |
| 92 | # 6) Create new_m_demangle |
| 93 | cp -rp old_m_demangle new_m_demangle |
| 94 | cp -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). |
| 98 | echo "Creating patch" |
| 99 | set +e |
| 100 | diff -r -u $old_gcc_revision old_m_demangle > our-changes |
| 101 | echo "Patch file 'our-changes' created" |
| 102 | |
| 103 | # 7) See how the patch would apply |
| 104 | echo "Attempting to apply the patch (but not actualy doing it)." |
| 105 | cd new_m_demangle |
| 106 | patch --dry -p1 < ../our-changes |