diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /intl/icu/source/tools/memcheck/ICUMemCheck.pl | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | intl/icu/source/tools/memcheck/ICUMemCheck.pl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/intl/icu/source/tools/memcheck/ICUMemCheck.pl b/intl/icu/source/tools/memcheck/ICUMemCheck.pl new file mode 100755 index 0000000000..019f7ecd78 --- /dev/null +++ b/intl/icu/source/tools/memcheck/ICUMemCheck.pl @@ -0,0 +1,64 @@ +# Copyright (C) 2016 and later: Unicode, Inc. and others. +# License & terms of use: http://www.unicode.org/copyright.html +# *********************************************************************** +# * COPYRIGHT: +# * Copyright (c) 2004-2006, International Business Machines Corporation +# * and others. All Rights Reserved. +# *********************************************************************** +# +# This perl script checks for correct memory function usage in ICU library code. +# It works with Linux builds of ICU using clang or gcc. +# +# To run it, +# 1. Build ICU +# 2. cd icu/source +# 3. perl tools/memcheck/ICUMemCheck.pl +# +# All object files containing direct references to C or C++ runtime library memory +# functions will be listed in the output. +# +# For ICU 58, the expected output is +# common/uniset.o U operator delete(void*) +# common/unifilt.o U operator delete(void*) +# common/cmemory.o U malloc +# common/cmemory.o U free +# i18n/strrepl.o U operator delete(void*) +# +# cmemory.c Expected failures from uprv_malloc, uprv_free implementation. +# uniset.cpp Fails because of SymbolTable::~SymbolTable() +# unifilt.cpp Fails because of UnicodeMatcher::~UnicodeMatcher() +# strrepl.cpp Fails because of UnicodeReplacer::~UnicodeReplacer() +# +# To verify that no additional problems exist in the .cpp files, #ifdef out the +# offending destructors, rebuild icu, and re-run the tool. The problems should +# be gone. +# +# The problem destructors all are for mix-in style interface classes. +# These classes can not derive from UObject or UMemory because of multiple-inheritance +# problems, so they don't get the ICU memory functions. The delete code +# in the destructors will never be called because stand-alone instances of +# the classes cannot exist. +# +$fileNames = `find common i18n io -name "*.o" -print`; +foreach $f (split('\n', $fileNames)) { + $symbols = `nm -u -C $f`; + if ($symbols =~ /U +operator delete\(void\*\)/) { + print "$f $&\n"; + } + if ($symbols =~ /U +operator delete\[\]\(void\*\)/) { + print "$f $&\n"; + } + if ($symbols =~ /U +operator new\(unsigned int\)/) { + print "$f $&\n"; + } + if ($symbols =~ /U +operator new\[\]\(unsigned int\)/) { + print "$f $&\n"; + } + if ($symbols =~ /U +malloc.*/) { + print "$f $&\n"; + } + if ($symbols =~ /(?m:U +free$)/) { + print "$f $&\n"; + } + +} |