Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | # *********************************************************************** |
michael@0 | 2 | # * COPYRIGHT: |
michael@0 | 3 | # * Copyright (c) 2004-2006, International Business Machines Corporation |
michael@0 | 4 | # * and others. All Rights Reserved. |
michael@0 | 5 | # *********************************************************************** |
michael@0 | 6 | # |
michael@0 | 7 | # This perl script checks for correct memory function usage in ICU library code. |
michael@0 | 8 | # It works with Linux builds of ICU using gcc. |
michael@0 | 9 | # |
michael@0 | 10 | # To run it, |
michael@0 | 11 | # 1. Build ICU |
michael@0 | 12 | # 2. cd icu/source |
michael@0 | 13 | # 3. perl ICUMemCheck.pl |
michael@0 | 14 | # |
michael@0 | 15 | # All object files containing direct references to C or C++ runtime library memory |
michael@0 | 16 | # functions will be listed in the output. |
michael@0 | 17 | # |
michael@0 | 18 | # For ICU 3.6, the expected output is |
michael@0 | 19 | # common/uniset.o U operator delete(void*) |
michael@0 | 20 | # common/unifilt.o U operator delete(void*) |
michael@0 | 21 | # common/cmemory.o U malloc |
michael@0 | 22 | # common/cmemory.o U free |
michael@0 | 23 | # i18n/strrepl.o U operator delete(void*) |
michael@0 | 24 | # layout/LEFontInstance.o U operator delete(void*) |
michael@0 | 25 | # layout/LEGlyphStorage.o U operator delete(void*) |
michael@0 | 26 | # layout/LayoutEngine.o U operator delete(void*) |
michael@0 | 27 | # |
michael@0 | 28 | # cmemory.c Expected failures from uprv_malloc, uprv_free implementation. |
michael@0 | 29 | # uniset.cpp Fails because of SymbolTable::~SymbolTable() |
michael@0 | 30 | # unifilt.cpp Fails because of UnicodeMatcher::~UnicodeMatcher() |
michael@0 | 31 | # strrepl.cpp Fails because of UnicodeReplacer::~UnicodeReplacer() |
michael@0 | 32 | # LayoutEngine.cpp Fails because of LEGlyphFilter::~LEGlyphFilter() |
michael@0 | 33 | # LEGlyphStorage.cpp Fails because of LEInsertionCallback::~LEInsertionCallback() |
michael@0 | 34 | # LEFontInstance.cpp Fails because of LECharMapper::~LECharMapper |
michael@0 | 35 | # |
michael@0 | 36 | # To verify that no additional problems exist in the .cpp files, #ifdef out the |
michael@0 | 37 | # offending destructors, rebuild icu, and re-run the tool. The problems should |
michael@0 | 38 | # be gone. |
michael@0 | 39 | # |
michael@0 | 40 | # The problem destructors all are for mix-in style interface classes. |
michael@0 | 41 | # These classes can not derive from UObject or UMemory because of multiple-inheritance |
michael@0 | 42 | # problems, so they don't get the ICU memory functions. The delete code |
michael@0 | 43 | # in the destructors will never be called because stand-alone instances of |
michael@0 | 44 | # the classes cannot exist. |
michael@0 | 45 | # |
michael@0 | 46 | $fileNames = `find common i18n layout io -name "*.o" -print`; |
michael@0 | 47 | foreach $f (split('\n', $fileNames)) { |
michael@0 | 48 | $symbols = `nm -u -C $f`; |
michael@0 | 49 | if ($symbols =~ /U +operator delete\(void\*\)/) { |
michael@0 | 50 | print "$f $&\n"; |
michael@0 | 51 | } |
michael@0 | 52 | if ($symbols =~ /U +operator delete\[\]\(void\*\)/) { |
michael@0 | 53 | print "$f $&\n"; |
michael@0 | 54 | } |
michael@0 | 55 | if ($symbols =~ /U +operator new\(unsigned int\)/) { |
michael@0 | 56 | print "$f $&\n"; |
michael@0 | 57 | } |
michael@0 | 58 | if ($symbols =~ /U +operator new\[\]\(unsigned int\)/) { |
michael@0 | 59 | print "$f $&\n"; |
michael@0 | 60 | } |
michael@0 | 61 | if ($symbols =~ /U +malloc.*/) { |
michael@0 | 62 | print "$f $&\n"; |
michael@0 | 63 | } |
michael@0 | 64 | if ($symbols =~ /U +free.*/) { |
michael@0 | 65 | print "$f $&\n"; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | } |