Bug 487993 - Alignment error when using Eigen with Valgrind and -m32
[valgrind.git] / auxprogs / update-demangler
blob9b62fffca565980a7e80f2c146c597144b3f2df8
1 #!/bin/sh
3 set -e
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 #---------------------------------------------------------------------
19 # You need to modify these revision numbers for your update.
20 old_gcc_revision=1719fa40c4ee4def60a2ce2f27e17f8168cf28ba # the revision of the previous update
21 new_gcc_revision=ca2f7c84927f85b95f0f48f82b93f1460c372db4 # the revision for this update
23 # Unless the organization of demangler related files has changed, no
24 # changes below this line should be necessary.
26 # Setup a temp directory
27 DIR=/tmp/demangle
29 rm -rf $DIR
30 mkdir -p $DIR
32 cd $DIR
34 echo "Updating the demangler in $DIR"
36 # 1) Make a shallow clone of the GCC repo containing only the 2 commits we need
37 mkdir gcc
38 cd gcc
39 git init
40 git remote add origin https://gcc.gnu.org/git/gcc.git
41 git config core.sparsecheckout true
42 echo "libiberty/*" > .git/info/sparse-checkout
43 echo "include/*" >> .git/info/sparse-checkout
44 echo git fetch --depth 1 origin $old_gcc_revision $new_gcc_revision
45 git fetch --depth 1 origin $old_gcc_revision $new_gcc_revision \
46 || git fetch origin # In case the above fails we will have to fetch all
47 git checkout $old_gcc_revision
48 cd ..
50 # 2) Check out files from old GCC revision
51 echo "Checking out GCC files @ $old_gcc_revision"
53 # 3) Assemble the ones we need in $DIR/$old_gcc_revision
54 mkdir $old_gcc_revision
55 cd $old_gcc_revision
56 cp ../gcc/include/ansidecl.h .
57 cp ../gcc/include/demangle.h .
58 cp ../gcc/include/dyn-string.h .
59 cp ../gcc/include/safe-ctype.h .
60 cp ../gcc/libiberty/cp-demangle.c .
61 cp ../gcc/libiberty/cp-demangle.h .
62 cp ../gcc/libiberty/cplus-dem.c .
63 cp ../gcc/libiberty/dyn-string.c .
64 cp ../gcc/libiberty/d-demangle.c .
65 cp ../gcc/libiberty/rust-demangle.c .
66 cp ../gcc/libiberty/safe-ctype.c .
67 cd ..
69 # 4) Check out files from new GCC revision
70 echo "Checking out GCC files @ $new_gcc_revision"
71 cd gcc
72 git checkout $new_gcc_revision
73 cd ..
75 # 5) Assemble the ones we need in $DIR/$new_gcc_revision
76 mkdir $new_gcc_revision
77 cd $new_gcc_revision
78 cp ../gcc/include/ansidecl.h .
79 cp ../gcc/include/demangle.h .
80 cp ../gcc/include/dyn-string.h .
81 cp ../gcc/include/safe-ctype.h .
82 cp ../gcc/libiberty/cp-demangle.c .
83 cp ../gcc/libiberty/cp-demangle.h .
84 cp ../gcc/libiberty/cplus-dem.c .
85 cp ../gcc/libiberty/dyn-string.c .
86 cp ../gcc/libiberty/d-demangle.c .
87 cp ../gcc/libiberty/rust-demangle.c .
88 cp ../gcc/libiberty/safe-ctype.c .
89 cd ..
91 # 6) Sparse check out valgrind coregrind/m_demangle into old_m_demangle
92 echo "Checking out coregrind/m_demangle"
93 mkdir valgrind-sparse-clone
94 cd valgrind-sparse-clone
95 git init
96 git remote add origin -f https://sourceware.org/git/valgrind.git/
97 git config core.sparsecheckout true
98 echo "coregrind/m_demangle/*" > .git/info/sparse-checkout
99 git pull origin master
100 cd ..
101 mv valgrind-sparse-clone/coregrind/m_demangle old_m_demangle
102 rm -rf valgrind-sparse-clone
104 # 7) Create new_m_demangle
105 cp -rp old_m_demangle new_m_demangle
106 cp -rp $new_gcc_revision/*.[ch] new_m_demangle
108 # 8) Compare files from previous GCC revision against old_m_demangle
109 # (This gets us the changes we made to the demangler).
110 echo "Creating patch"
111 set +e
112 diff -r -u $old_gcc_revision old_m_demangle > our-changes
113 echo "Patch file 'our-changes' created"
115 # 9) See how the patch would apply
116 echo "Attempting to apply the patch (but not actualy doing it)."
117 cd new_m_demangle
118 patch --dry -p1 < ../our-changes