abi-compliance-checker.pl revision 8580e858c582b97ac65413cea1c6067385020720
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
38580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko# ABI Compliance Checker (ABICC) 1.99.24
41bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# A tool for checking backward compatibility of a C/C++ library API
5ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
6850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2009-2011 Institute for System Programming, RAS
7850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies)
88bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko# Copyright (C) 2011-2012 ROSA Laboratory
9e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko# Copyright (C) 2012-2016 Andrey Ponomarenko's ABI Laboratory
10ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
11ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Written by Andrey Ponomarenko
12ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
13ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# PLATFORMS
14ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# =========
15ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux, FreeBSD, Mac OS X, Haiku, MS Windows, Symbian
16ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
17ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# REQUIREMENTS
18ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# ============
19ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux
20c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - G++ (3.0-4.7, 4.8.3, 4.9 or newer)
21ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - GNU Binutils (readelf, c++filt, objdump)
22850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Perl 5 (5.8 or newer)
23f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
248a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko#    - ABI Dumper (0.99.15 or newer)
25ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
26ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Mac OS X
27570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko#    - Xcode (g++, c++filt, otool, nm)
28f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
29ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
30ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  MS Windows
31c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - MinGW (3.0-4.7, 4.8.3, 4.9 or newer)
32ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - MS Visual C++ (dumpbin, undname, cl)
33850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Active Perl 5 (5.8 or newer)
3481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko#    - Sigcheck v2.52 or newer
3581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko#    - GnuWin Zip and UnZip
3681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko#    - Exuberant Ctags (5.8 or newer)
3774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#    - Add tool locations to the PATH environment variable
3881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko#    - Run vcvars64.bat (C:\Microsoft Visual Studio 9.0\VC\bin\)
39ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
40ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is free software: you can redistribute it and/or modify
41ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# it under the terms of the GNU General Public License or the GNU Lesser
42ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# General Public License as published by the Free Software Foundation.
43ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
44ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is distributed in the hope that it will be useful,
45ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# but WITHOUT ANY WARRANTY; without even the implied warranty of
46ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# GNU General Public License for more details.
48ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
49ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# You should have received a copy of the GNU General Public License
50ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# and the GNU Lesser General Public License along with this program.
51ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# If not, see <http://www.gnu.org/licenses/>.
52ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
53ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Getopt::Long;
54ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetopt::Long::Configure ("posix_default", "no_ignore_case");
55ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Path qw(mkpath rmtree);
56ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Temp qw(tempdir);
57ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Copy qw(copy move);
5874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkouse Cwd qw(abs_path cwd realpath);
59177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkouse Storable qw(dclone);
60ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Data::Dumper;
612fba63087b6e973c04b6d235fe10363657985263Andrey Ponomarenkouse Config;
62ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
638580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenkomy $TOOL_VERSION = "1.99.24";
648580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenkomy $ABI_DUMP_VERSION = "3.3";
65d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenkomy $XML_REPORT_VERSION = "1.2";
66f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy $XML_ABI_DUMP_VERSION = "1.2";
67ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OSgroup = get_OSgroup();
68ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ORIG_DIR = cwd();
69ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TMP_DIR = tempdir(CLEANUP=>1);
706fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenkomy $LOCALE = "C.UTF-8";
71ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
72ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Internal modules
73ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MODULES_DIR = get_Modules();
74ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkopush(@INC, get_dirname($MODULES_DIR));
75ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Rules DB
76ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RULES_PATH = (
77ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Binary" => $MODULES_DIR."/RulesBin.xml",
78ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Source" => $MODULES_DIR."/RulesSrc.xml");
79ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenkomy ($Help, $ShowVersion, %Descriptor, $TargetLibraryName,
81ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TestTool, $DumpAPI, $SymbolsListPath, $CheckHeadersOnly_Opt, $UseDumps,
82ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko$AppPath, $StrictCompat, $DumpVersion, $ParamNamesPath,
8314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko%RelativeDirectory, $TargetTitle, $TestDump, $LoggingPath,
846ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko%TargetVersion, $InfoMsg, $CrossGcc, %OutputLogPath,
85ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$OutputReportPath, $OutputDumpPath, $ShowRetVal, $SystemRoot_Opt, $DumpSystem,
86ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$CmpSystems, $TargetLibsPath, $Debug, $CrossPrefix, $UseStaticLibs, $NoStdInc,
87ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TargetComponent_Opt, $TargetSysInfo, $TargetHeader, $ExtendedCheck, $Quiet,
8807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko$SkipHeadersPath, $CppCompat, $LogMode, $StdOut, $ListAffected, $ReportFormat,
891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko$UserLang, $TargetHeadersPath, $BinaryOnly, $SourceOnly, $BinaryReportPath,
9052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko$SourceReportPath, $UseXML, $SortDump, $DumpFormat,
91177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko$ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath,
921fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$CheckInfo, $Quick, $AffectLimit, $AllAffected, $CppIncompat,
931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$SkipInternalSymbols, $SkipInternalTypes, $TargetArch, $GccOptions,
9481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko$TypesListPath, $SkipTypesListPath, $CheckPrivateABI, $CountSymbols, $OldStyle,
958580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko$DisableQuickEmptyReport, $SkipTypedefUncover);
96ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
97ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CmdName = get_filename($0);
98ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_LibExt = (
99ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic" => {
1009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"so",
101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "macos"=>"dylib",
102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"dll",
1039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"dso",
1049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"so"
105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static" => {
1079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"a",
108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"lib",
1099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"lib",
1109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"a"
111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_Archive = (
115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"zip",
116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"tar.gz"
117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ERROR_CODE = (
120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Compatible verdict
121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compatible"=>0,
122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Success"=>0,
123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible verdict
124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Incompatible"=>1,
125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Undifferentiated error code
126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Error"=>2,
127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # System command is not found
128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Not_Found"=>3,
129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot access input files
130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Access_Error"=>4,
131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot compile header files
132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Cannot_Compile"=>5,
133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Header compiled with errors
134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compile_Error"=>6,
135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Invalid input ABI dump
136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Invalid_Dump"=>7,
137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible version of ABI dump
138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Dump_Version"=>8,
139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot find a module
140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Module_Error"=>9,
141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty intersection between
142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # headers and shared objects
143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Intersection"=>10,
144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty set of symbols in headers
145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Set"=>11
146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
148ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkomy $HomePage = "http://lvc.github.io/abi-compliance-checker/";
149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenkomy $ShortUsage = "ABI Compliance Checker (ABICC) $TOOL_VERSION
1511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey PonomarenkoA tool for checking backward compatibility of a C/C++ library API
15281b09e8848c6646369681f534e7157f87533612fAndrey PonomarenkoCopyright (C) 2016 Andrey Ponomarenko's ABI Laboratory
153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoLicense: GNU LGPL or GNU GPL
154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUsage: $CmdName [options]
156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey PonomarenkoExample: $CmdName -lib NAME -old OLD.xml -new NEW.xml
157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOLD.xml and NEW.xml are XML-descriptors:
159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/headers/
166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/libraries/
170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMore info: $CmdName --help\n";
173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
174570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkoif($#ARGV==-1)
175570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $ShortUsage);
177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit(0);
178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetOptions("h|help!" => \$Help,
181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "i|info!" => \$InfoMsg,
182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v|version!" => \$ShowVersion,
183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dumpversion!" => \$DumpVersion,
184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# general options
185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l|lib|library=s" => \$TargetLibraryName,
186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d1|old|o=s" => \$Descriptor{1}{"Path"},
187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d2|new|n=s" => \$Descriptor{2}{"Path"},
188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump|dump-abi|dump_abi=s" => \$DumpAPI,
189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# extra options
190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "app|application=s" => \$AppPath,
19181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko  "static|static-libs!" => \$UseStaticLibs,
192d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-path|cross-gcc=s" => \$CrossGcc,
193d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-prefix|cross-prefix=s" => \$CrossPrefix,
194d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-options=s" => \$GccOptions,
195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysroot=s" => \$SystemRoot_Opt,
19615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v1|vnum1|version1|vnum=s" => \$TargetVersion{1},
19715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v2|vnum2|version2=s" => \$TargetVersion{2},
198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "s|strict!" => \$StrictCompat,
199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "symbols-list=s" => \$SymbolsListPath,
20052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  "types-list=s" => \$TypesListPath,
201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "skip-symbols=s" => \$SkipSymbolsListPath,
20299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  "skip-types=s" => \$SkipTypesListPath,
203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "headers-list=s" => \$TargetHeadersPath,
204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "skip-headers=s" => \$SkipHeadersPath,
205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "header=s" => \$TargetHeader,
206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "headers-only|headers_only!" => \$CheckHeadersOnly_Opt,
207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "show-retval!" => \$ShowRetVal,
208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "use-dumps!" => \$UseDumps,
209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "nostdinc!" => \$NoStdInc,
210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-system=s" => \$DumpSystem,
211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysinfo=s" => \$TargetSysInfo,
212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "cmp-systems!" => \$CmpSystems,
213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "libs-list=s" => \$TargetLibsPath,
214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "ext|extended!" => \$ExtendedCheck,
215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "q|quiet!" => \$Quiet,
216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "stdout!" => \$StdOut,
217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-format=s" => \$ReportFormat,
2185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko  "dump-format=s" => \$DumpFormat,
2191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "xml!" => \$UseXML,
220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "lang=s" => \$UserLang,
22154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  "arch=s" => \$TargetArch,
2221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "binary|bin|abi!" => \$BinaryOnly,
2231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "source|src|api!" => \$SourceOnly,
2242489ef88760861175102e4508089608391beead3Andrey Ponomarenko  "limit-affected|affected-limit=s" => \$AffectLimit,
225447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko  "count-symbols=s" => \$CountSymbols,
2260f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko  "old-style!" => \$OldStyle,
227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
23107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
2322b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  "cpp-incompatible!" => \$CppIncompat,
233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
23762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
24614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  "title|l-full|lib-full=s" => \$TargetTitle,
2471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
249570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
252177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
253e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
254f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "quick!" => \$Quick,
25581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko  "disable-quick-empty-report!" => \$DisableQuickEmptyReport,
256d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  "all-affected!" => \$AllAffected,
2571fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-symbols|skip-internal=s" => \$SkipInternalSymbols,
2581fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-types=s" => \$SkipInternalTypes,
2598580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko  "skip-typedef-uncover!" => \$SkipTypedefUncover,
260e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko  "check-private-abi!" => \$CheckPrivateABI
261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko) or ERR_MESSAGE();
262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ERR_MESSAGE()
264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "\n".$ShortUsage);
266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{"Error"});
267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_TYPE = $UseStaticLibs?"static":"dynamic";
270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLIB_TYPE = $LIB_TYPE;
271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoif($OSgroup!~/macos|windows/ and $SLIB_TYPE eq "dynamic")
272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # show as "shared" library
273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SLIB_TYPE = "shared";
274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_EXT = getLIB_EXT($OSgroup);
276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $AR_EXT = getAR_EXT($OSgroup);
277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $BYTE_SIZE = 8;
278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMMON_LOG_PATH = "logs/run.log";
279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HelpMessage="
281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoNAME:
282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  ABI Compliance Checker ($CmdName)
2830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  Check backward compatibility of a C/C++ library API
284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoDESCRIPTION:
286b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko  ABI Compliance Checker (ABICC) is a tool for checking backward binary and
2871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  source-level compatibility of a $SLIB_TYPE C/C++ library. The tool checks
2881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  header files and $SLIB_TYPE libraries (*.$LIB_EXT) of old and new versions and
2891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  analyzes changes in API and ABI (ABI=API+compiler ABI) that may break binary
2901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  and/or source-level compatibility: changes in calling stack, v-table changes,
2911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  removed symbols, renamed fields, etc. Binary incompatibility may result in
2921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  crashing or incorrect behavior of applications built with an old version of
2931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  a library if they run on a new one. Source incompatibility may result in
2941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  recompilation errors with a new library version.
295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
296dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  The tool is intended for developers of software libraries and maintainers
297dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  of operating systems who are interested in ensuring backward compatibility,
298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  i.e. allow old applications to run or to be recompiled with newer library
299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  versions.
300dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
301dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  Also the tool can be used by ISVs for checking applications portability to
302dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  new library versions. Found issues can be taken into account when adapting
303dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  the application to a new library version.
304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  This tool is free software: you can redistribute it and/or modify it
306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  under the terms of the GNU LGPL or GNU GPL.
307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUSAGE:
309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  $CmdName [options]
310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXAMPLE:
3120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  $CmdName -lib NAME -old OLD.xml -new NEW.xml
313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  OLD.xml and NEW.xml are XML-descriptors:
315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/header(s)/
322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/header(s)/
323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/library(ies)/
328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/library(ies)/
329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoINFORMATION OPTIONS:
333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -h|-help
334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print this help.
335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -i|-info
337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print complete info.
338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -v|-version
340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print version information.
341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -dumpversion
343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print the tool version ($TOOL_VERSION) and don't do anything else.
344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGENERAL OPTIONS:
34607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l|-lib|-library NAME
347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Library name (without version).
348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d1|-old|-o PATH
350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 1st (old) library version.
351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      It may be one of the following:
352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         1. XML-descriptor (VERSION.xml file):
354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <version>
356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  1.0
357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </version>
358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <headers>
360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/header(s)/
361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/header(s)/
362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </headers>
364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <libs>
366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/library(ies)/
367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/library(ies)/
368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </libs>
370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
37101e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko                 ...
372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         2. ABI dump generated by -dump option
374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         3. Directory with headers and/or $SLIB_TYPE libraries
375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         4. Single header file
376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
37701e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko      If you are using an 2-4 descriptor types then you should
378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      specify version numbers with -v1 and -v2 options too.
379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      For more information, please see:
3811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        http://ispras.linuxbase.org/index.php/Library_Descriptor
382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
38307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d2|-new|-n PATH
384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 2nd (new) library version.
385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
38607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump|-dump-abi PATH
387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create library ABI dump for the input XML descriptor. You can
388570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      transfer it anywhere and pass instead of the descriptor. Also
389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      it can be used for debugging the tool.
390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
3916ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko      Supported versions of ABI dump: 2.0<=V<=$ABI_DUMP_VERSION\n";
392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub HELP_MESSAGE() {
394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $HelpMessage."
395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFO:
396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko     $CmdName --info\n");
397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub INFO_MESSAGE()
400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "$HelpMessage
402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXTRA OPTIONS:
40307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -app|-application PATH
40452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify the application that should be checked
405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for portability to the new library version.
406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
40781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko  -static
408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check static libraries instead of the shared ones. The <libs> section
409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the XML-descriptor should point to static libraries location.
410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4118bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-path PATH
412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to the cross GCC compiler to use instead of the usual (host) GCC.
413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4148bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-prefix PREFIX
415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      GCC toolchain prefix.
4168bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko
4178bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-options OPTS
4188bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko      Additional compiler options.
419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysroot DIR
421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify the alternative root directory. The tool will search for include
42207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      paths in the DIR/usr/include and DIR/usr/lib directories.
423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v1|-version1 NUM
425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 1st library version outside the descriptor. This option is needed
426bd1767ac0e8d4a913683bf84e6305bed1850a427Mathieu Malaterre      if you have preferred an alternative descriptor type (see -d1 option).
427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      In general case you should specify it in the XML-descriptor:
429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <version>
430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              VERSION
431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </version>
432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v2|-version2 NUM
434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 2nd library version outside the descriptor.
435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
436c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko  -vnum NUM
437c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      Specify the library version in the generated ABI dump. The <version> section
438c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      of the input XML descriptor will be overwritten in this case.
439c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko
440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -s|-strict
441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Treat all compatibility warnings as problems. Add a number of \"Low\"
442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      severity problems to the return value of the tool.
443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -headers-only
445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check header files without $SLIB_TYPE libraries. It is easy to run, but may
446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without detecting of added/removed symbols.
448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <libs> section
450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -show-retval
456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Show the symbol's return type in the report.
457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
45807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -symbols-list PATH
45952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of symbols (mangled
46052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      names in C++) that should be checked. Other symbols will not be checked.
46152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
46252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  -types-list PATH
46352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of types that should
46452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      be checked. Other types will not be checked.
465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -skip-symbols PATH
46799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of symbols that should not be checked.
46899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
46999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  -skip-types PATH
47099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of types that should not be checked.
471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
47507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
48907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
49607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
54952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option should be used with -dump-system option to dump
55052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      ABI of operating systems and configure the dumping process.
551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cmp-systems -d1 sys_dumps/NAME1/ARCH -d2 sys_dumps/NAME2/ARCH
553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare two system ABI dumps. Create compatibility reports for each
554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and the common HTML report including the summary of test
555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      results for all checked libraries. Report will be generated to:
55607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_compat_reports/NAME1_to_NAME2/ARCH
557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -libs-list PATH
559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with a list of libraries, that should be dumped by
560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the -dump-system option or should be checked by the -cmp-systems option.
561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -ext|-extended
563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If your library A is supposed to be used by other library B and you
564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      want to control the ABI of B, then you should enable this option. The
565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      tool will check for changes in all data types, even if they are not
566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      used by any function in the library A. Such data types are not part
567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the A library ABI, but may be a part of the ABI of the B library.
568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The short scheme is:
570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        app C (broken) -> lib B (broken ABI) -> lib A (stable ABI)
571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -q|-quiet
573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print all messages to the file instead of stdout and stderr.
574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default path (can be changed by -log-path option):
575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          $COMMON_LOG_PATH
576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -stdout
578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print analysis results (compatibility reports and ABI dumps) to stdout
579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      instead of creating a file. This would allow piping data to other programs.
580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-format FMT
582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change format of compatibility report.
583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Formats:
584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        htm - HTML format (default)
585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        xml - XML format
586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-format FMT
5885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Change format of ABI dump.
5895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Formats:
5905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        perl - Data::Dumper format (default)
5915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        xml - XML format
5925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
5931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -xml
5945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Alias for: --report-format=xml or --dump-format=xml
5951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
59607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -lang LANG
597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Set library language (C or C++). You can use this option if the tool
598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      cannot auto-detect a language. This option may be useful for checking
599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      C-library headers (--lang=C) in --headers-only or --extended modes.
60054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
60154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  -arch ARCH
60254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      Set library architecture (x86, x86_64, ia64, arm, ppc32, ppc64, s390,
60354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      ect.). The option is useful if the tool cannot detect correct architecture
60454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      of the input objects.
605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -binary|-bin|-abi
6071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Binary\" compatibility problems only.
6081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
60907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
6101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
6111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -source|-src|-api
6121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Source\" compatibility problems only.
6131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
61407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
615f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6162489ef88760861175102e4508089608391beead3Andrey Ponomarenko  -limit-affected LIMIT
617f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      The maximum number of affected symbols listed under the description
618f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      of the changed type in the report.
619447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
620447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko  -count-symbols PATH
621447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko      Count total public symbols in the ABI dump.
6220f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko
6230f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko  -old-style
6240f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko      Generate old-style report.
6251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
63052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
63807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
64307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
64407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
64507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
6462b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
6472b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  -cpp-incompatible
6482b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko      Set this option if input C header files use C++ keywords.
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
66007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
66407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
66707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6705c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
67207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
67562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
67662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
67707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
68007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
68207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
6831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
6881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
6891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
69007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
6911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
69207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
70007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
70207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
70507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
70707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
72307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
72752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
72814b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  -title NAME
72907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
73107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
73207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
73307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
734570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
735570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
738570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
739570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
740570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
749159324eebddb0a6101832a3433f845fc74a3735eSangwoo Lee          3 - skip headers that include non-Linux headers
7508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
754177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
755177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
756177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
757e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
758e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
759e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
76081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
76181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko  -disable-quick-empty-report
76281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko      Do not generate quick empty report if input ABI dumps are equal.
763d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
7641fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-symbols PATTERN
7651fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check symbols matched by the pattern.
7661fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
7671fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-types PATTERN
7681fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check types matched by the pattern.
769e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
7708580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko  -skip-typedef-uncover
7718580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko      Do not report a problem if type is covered or
7728580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko      uncovered by typedef (useful for broken debug info).
7738580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko
774e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko  -check-private-abi
775e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      Check data types from the private part of the ABI when
776e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      comparing ABI dumps created by the ABI Dumper tool with
777e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      use of the -public-headers option.
778e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
779e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      Requires ABI Dumper >= 0.99.14
78062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
78307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
78607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
78707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
794ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    ".$HomePage."\n");
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
84762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
84862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
84962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
85062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
85162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
85262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
85362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
85462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
85562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
85662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
85762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
85862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
85962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
86062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
86162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
86362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
86462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
86562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
86662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
86762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
86862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
86962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
87062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
87162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
87262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
87662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
87762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
87862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
87962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
88062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
88162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
8828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
8838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
88462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
88562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
9488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
9498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
999e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
1000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
1001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
1003f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $EMERGENCY_MODE_48 = 0;
100407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
1006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
1007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
1008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
1009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
1010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
1011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
1014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
106462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
106562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
106662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
106762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
106862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
106962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
107062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
107162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
107262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
107362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
107462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
107562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
107662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
107762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
107862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
107962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
108062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
108162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
108262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
108362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
108462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
108562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
108662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
11319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
11549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
11559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
11569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
11579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
11589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
11599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
11609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
11619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
11629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
11639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
11659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
11669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
11679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
11689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
117074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
117174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
117274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
117374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
117474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
117574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
117674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
117774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
117874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
117974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
118074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
118174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
118274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
118374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
118474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
118574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
118674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
11879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
11889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
11899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
11909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
11919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
11929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
11939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
11949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1212570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1218570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1224570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1226570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1227570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1228570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1229570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1230570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1231570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
12489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
12499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
12509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
12558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
1258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1259570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
126015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenkomy $TargetComponent = undef;
1261dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1264dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy $TOP_REF = "<a class='top_ref' href='#Top'>to the top</a>";
12711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
12751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
128882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
129174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
129274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
129374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1294177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1296177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1297177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1298850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1299177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1300177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1301177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1302177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
13131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
13191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
13224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
132362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1325177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1326177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
133362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
133462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
13359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1348a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1349a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1350a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
135252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy %TypesList;
1353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
135562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
135662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
135762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
135862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
135962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
136062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
136162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
136262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
136362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
136462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
13689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
137062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
137107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1373fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1374fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
137874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1391570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1395570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1396570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1397570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
14028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1413f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
14149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
14159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
141707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
142601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
142701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
142801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
14319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
143207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
14339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
14349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1436d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkomy %CheckedArch;
1437d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1440570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
14419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1445570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1446570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1447570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1450570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
14641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
146562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
14681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
14691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
14701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1471f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $CurrentSymbol; # for debugging
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1473447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko#Report
1474447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenkomy %TypeChanges;
1475447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
1476447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko#Speedup
1477447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenkomy %TypeProblemsIndex;
1478447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
1479f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1480f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1482fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1487f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
14886fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Filters
1489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14926fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Format of objects
1493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
14998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1506570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1507570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1509570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
15198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
1520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
15259e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"sect_aff\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
15269e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"sect_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
15331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
15341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15362489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy %Severity_Val=(
15372489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "High"=>3,
15382489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Medium"=>2,
15392489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Low"=>1,
15402489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Safe"=>-1
15412489ef88760861175102e4508089608391beead3Andrey Ponomarenko);
15422489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
155574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
155674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
157201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
157601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
157701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
157801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
158401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1595570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
15970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1599dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1600dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1601dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1602dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1603dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1604dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1605dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
163174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
163274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
163674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
165662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
167462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
167562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
16961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
17021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
17111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
173274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
173662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
174662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
174762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
174862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
175162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
175262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
175362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
175462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
175562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1758a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
175962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
176362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1765570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
176662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
176862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
176962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1770a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
177162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
177262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1774570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
177774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
178062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1786b3118d9752afef5233235b4f95359357b2e72432Andrey Ponomarenko    if($Path=~/[\*\+\(\[\|]/)
1787b3118d9752afef5233235b4f95359357b2e72432Andrey Ponomarenko    { # pattern
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
18085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1812570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1832ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $DHeaders = parseTag(\$Content, "headers");
1833ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $DHeaders) {
1834ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1835ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
1836ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    elsif(lc($DHeaders) ne "none")
1837ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # append the descriptor headers list
1838ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Headers"})
1839ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # multiple descriptors
1840ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1842ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
1843ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1844ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
1845ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1846ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
1847ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not -e $Path) {
1848ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$Path\'");
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1852ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
1867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
1869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
1877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1883570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
1884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
1886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1892570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
1893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
1895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1901570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
1902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
1903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
1905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
1906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1907570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
1908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
1909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1915570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
1916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1917570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
1918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_include_paths")))
1919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1925570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"AddIncludePaths"}}, $Path);
1926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
19288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
19298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
19308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
19318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
19328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
19338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
19348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
1935570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
1936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
19388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
194374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
194474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
19458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
19468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
194774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
194874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
1954b3118d9752afef5233235b4f95359357b2e72432Andrey Ponomarenko
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
1959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
1960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
1965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
1967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
1969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
1972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
1975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
1977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
19821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
1983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
1984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
1986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
19871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
1988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
1989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
1991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
1992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1993a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
1994a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
1995a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
1996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
1997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
1998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
2000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
20021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
2003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
2004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
2006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
2007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
201101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
2012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
201301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
201401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
201501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
201601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
201701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
201801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
201901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
202001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
202101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
202201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
202301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
2024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
202501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
202601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
202701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
202801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
202901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
203001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
203101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
203201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
203301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
203401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
203501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
203601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
203701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
203801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
203901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
204001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
204101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
204301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
204401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
204501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2048850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2050850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2051850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2052850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
20554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
205674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
20574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
20584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
20594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
206282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
206401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2066850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2071850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2072850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2073850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2074850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2075850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
20764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2077850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
207862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
207962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
208062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
208162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
208274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2083570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
208574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
208674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
208774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2088570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2089570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2090177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2091570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2092570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2093177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2094177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2095177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2096177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2097177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2098177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2099177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2100177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2101177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2103177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2104177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2105570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
210662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
210762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2125d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Lines = split(/\n/, $Content);
2126850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2127850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2128850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2129850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2130177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2131850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2132850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2133850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
213462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2135850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2136850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2137850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
21383ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3." ";
2139850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2141850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2142850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2143850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2144850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2145850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2146850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2147850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2148850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
214982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
215082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
215182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
215282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
215982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
216082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
216182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
216282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2167f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2169f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2170f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2171f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2172f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2173f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2174f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2175f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2177f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2181f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2182f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2183f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2184f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2185f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2186f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2189b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2191b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
219262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
219362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
219462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
219562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
219662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
219762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
219862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2199f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
220062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
220162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
220262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
220362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
220462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
220562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2206f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2208f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2209f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2210f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2212f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2213f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2214f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2215f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2216f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2217f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
22189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2219f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2220f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2221850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2225b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2226b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
22314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
22324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
22334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
22344b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
22354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
22364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
22374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
22384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
22394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
22404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
22414b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
22424b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2255177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2256989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2258989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
226062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2261177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
226262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2263177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2264177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2265177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2266177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2267177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2268177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2269177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2270177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2271177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2272177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2273177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2274177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2275177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2277177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2278177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2279177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2280177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2281177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2282177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2283177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2284177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2285177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2286177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2287177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2288177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2289177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2290989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
229362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2294850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2295850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2296850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2297850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2298177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2299850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2300850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2304177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2306177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2307177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2308177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2310989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2311989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2312989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2313989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2314989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2315989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2316989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2317989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2319989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2320989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2321989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2322989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2323989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2324989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2325177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2326177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2327989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2328989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2329850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2330850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2332177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2333989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2334850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2335850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
233662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2337177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2338989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
234662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2347dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
234862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
234962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
235062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
235162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
235262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
235362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
235462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
235562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2356dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
235862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
236362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
237062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
23720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
237662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
237962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
238062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
238101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
238262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
238362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
238401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
238562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
238601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
238762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
238862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2392177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2393177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2408177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2409177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2410177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2412177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2415177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2419177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
24211b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        if($NBid ne $Bid
24221b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        and $NBid ne $Tid)
2423177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2430177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2439082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2441e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2449be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2450be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2451be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2452be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2472e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2480e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2500177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2518e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2519e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2528e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2529e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2531e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2533e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
25371b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($NBid ne $Bid
25381b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                and $NBid ne $New)
2539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2540e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2541e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2546e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2548be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2549be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2550be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2551be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2552be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2556e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2558e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2559e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2563e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2564e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2567e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
257362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
257862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
258062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
259362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2597b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
259862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
260062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2606b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2607b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2608b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2619b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2623b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
262762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
262962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2631b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2635b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2638b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2642b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2647b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2648b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2649b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
265262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2653b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2655b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2656b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2657b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2658b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
266562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
266662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
266762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
266862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
266962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
267062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
267162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
267562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2677b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2678b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2679b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2681b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
268862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
269062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
269162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
269262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
269462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
269562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
269662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
269762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
269862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
270062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
270262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
270762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
270862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
271062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
271262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
271362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
271462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
271562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
271862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
271962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
272062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
272162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
272262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
272362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
272462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
272562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
272662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
272762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
272862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
272962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
273062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
273162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
273262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
273362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
273662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
273962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
274162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
27420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
274362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
274462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
274562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
274662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
274862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
274962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
275062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
275162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
275262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
275362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
275462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
275662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
275762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
275862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
275962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
276062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
276162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
276262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2763177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2764177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2765177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2766177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2767177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2768177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
276962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
277062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
277162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
277262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
277362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
277462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
277562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
277662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2777177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2778177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2779177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2780177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2781177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2782177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2783177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2784177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
279062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2791989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2792989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
279362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2794989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2795989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2796989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2797989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2798989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2799989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
280362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
280462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
28050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2807f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2808f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2809f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
281162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
281362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
281462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
281562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
28160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2817989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
281862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
281962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
282062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
28210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2822989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2823989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2824989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2826989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2828989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2829989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2830989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
28310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2832989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2833989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2834989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2836989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
28389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
28390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
28400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
284262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2843989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2844989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2848177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
285062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
28510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
28520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
285362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
28570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
28580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
28590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
28600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
28610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
28620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
28630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
28640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
28650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
2869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
2871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
2875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
2884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
2886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
2887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
2888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
2898989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
289962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
290062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
29010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
29020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
290462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
2905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
290662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
2907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
290862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
2909fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
291062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
29140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
291562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
2916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
2919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
2920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
292162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
2922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
2923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
2926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
29280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
2929989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
29300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
2931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
2932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
29340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
2935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
29380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
2939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
2941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
294374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
294474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
294574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
294674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
294774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2948850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
2949850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
2950850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
2951850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
29528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
29538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
29548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
29558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
29568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
29578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
2958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
2959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
2961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
2962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
2963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
2964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
2965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
2968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
2970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
2971989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2972989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
2973989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
2974989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
29750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
29760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
2977989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
2978989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
2979989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
29800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
2982989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
29830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
2984989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
29850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
2986989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
2987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
2988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
2989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
29930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
2994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
29950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
29960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
29970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
29980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
29990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
30000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
30010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
30020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
30030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
3004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
3008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
3010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
3012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
3013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
30140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
30150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
3016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3018f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
3019f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3020f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
30219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
30220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
30230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
3024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
302562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
30260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
3027989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
3028989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
3029989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3030989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3031989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
303762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
303862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
303962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
304062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
304162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
304262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
304362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
304462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
304562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
304662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
304762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
304862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
304962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
305362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
305462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
305562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
305662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
305862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3059b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
306262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
306562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
306862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
306962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
307162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
307262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
307362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
307462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
307562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
307662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
307762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
307862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
307962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
308062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
308162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3083177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
308962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3090b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3091b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
309262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3094b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3095b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3096b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
31011477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
310862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
311062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3124f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3128f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3129f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3130f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3131f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3132f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
31349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
314062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3147dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
314862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
315762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3174dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3175dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
317601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
317701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
317801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
317901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
318001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
318101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
318201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
318301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
318401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3187dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
319062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
319262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
319962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
320201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
320301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
320401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
320501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
320662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3208f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3209f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3210f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
321462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3215989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3216989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3217989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
322562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
322662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
322762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
322862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3229989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
323062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
323862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3256989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
325701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3258989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3260989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3261989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
326362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
326462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3265989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3266989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3267989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3268989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3269989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3270989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3271989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
327262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3273989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
327401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3275989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3276989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
327762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
327862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3279989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3280989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3281989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3282989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3283989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3284989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3285989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
32970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
32980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
33020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
33030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
33040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
33050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
33060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
33140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
33150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
33200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
33220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
33270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
33280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
33310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
33340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
33350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
33420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
33480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
33490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
33570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
33610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
33690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
33730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
33770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
33800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
33820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
33830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
33850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
33860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
33890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
33900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
33920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
33930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
33950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
33960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
33980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
340474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
340574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
340674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
340774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
340874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
340974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
341074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3414dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3415dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3416dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3417dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3418dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3419dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3420dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3421dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3422dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3423dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3424dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3425dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
34310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
34330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
34340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
34360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
343862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
34390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
344062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
344162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
344262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
34430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
344462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
344562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
344662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
34470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
34519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
34520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
345362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
34540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
345562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
345662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
34570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
34580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
34600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
34610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
34620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
34659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
34669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
34679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
34689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
34700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
34710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
34730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
34740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
34750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
34760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
34780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
348062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
348162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
348362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3490e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3491e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3492e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3493e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3494e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3495e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3496e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3497e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3498e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
350062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
350162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
350262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
350362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
350462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
350562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
350762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
350862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
350962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
351062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
351162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
351262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
35150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
351662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
351762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
351862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
351962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3520dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
35210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
352262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
352362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
35240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
352562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
352662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
352762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
352862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
352962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
353162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
353362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
35360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
353762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
354262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
354862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
355462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
356662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3592177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3595177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3596177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3597177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3598177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3599177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3603177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3604177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3605177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
361462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3620dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
362601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3627dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3628dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3629dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3630dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3631dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
363962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3645850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3646850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3647850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3648850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3649f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3650f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3651f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3652f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3653f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3654f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3655f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3656f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
36589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
36650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3666850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
36680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
36690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
36700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
36710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
36720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
367462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
36750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3676177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3677177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3678177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
36790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
36800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
36810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
368262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
368362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
36840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
36850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
36860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
368962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
369062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3691177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3692177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3693177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
369462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
369562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
369662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
369762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
369835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
369935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
370135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3703dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
37075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
37085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
37095c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
37105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
37115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
37125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
37135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
37145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
37155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
37165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
37175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
37185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
37195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
37205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
37215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
37269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3747850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3748850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3749850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3750850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
375362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
375462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
375562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
375662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
375762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
375862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
375962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
376062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
37639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
376974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
377074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
377174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
377274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
377862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3793dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
379462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
37961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
37971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
37981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
379901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
38001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
38011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
38021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
38031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
38041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
38051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
38061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
38071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
38082956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
38091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
38101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
38111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3812177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
38131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
38141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
38151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
38161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
381701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
38181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
38191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
38201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
38211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38242956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
38291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3830dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3832dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3833dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3834dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3836b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3837b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3839b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type")) {
3840b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3841b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3842b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
3843b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."<...>", "T");
3844b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
384962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
385162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
385262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3853850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3856850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3857850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
385962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3860850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38682489ef88760861175102e4508089608391beead3Andrey Ponomarenko
386962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
3871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
3873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
3875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
3876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
38782489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Intrinsic")
38792489ef88760861175102e4508089608391beead3Andrey Ponomarenko    {
38802489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(defined $TypeAttr{"Header"})
38812489ef88760861175102e4508089608391beead3Andrey Ponomarenko        {
38822489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if($TypeAttr{"Header"}=~/\Adump[1-2]\.[ih]\Z/)
38832489ef88760861175102e4508089608391beead3Andrey Ponomarenko            { # support for SUSE 11.2
38842489ef88760861175102e4508089608391beead3Andrey Ponomarenko              # integer_type has srcp dump{1-2}.i
38852489ef88760861175102e4508089608391beead3Andrey Ponomarenko                delete($TypeAttr{"Header"});
38862489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
38872489ef88760861175102e4508089608391beead3Andrey Ponomarenko        }
38882489ef88760861175102e4508089608391beead3Andrey Ponomarenko    }
38892489ef88760861175102e4508089608391beead3Andrey Ponomarenko
3890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
3891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
389262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
38931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
3894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
3895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
389662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
38971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
3898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
3899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
3901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
3902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
3904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
3906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
3908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
3909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
3910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
3914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
3916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
3918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
3920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
3921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
3927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
3929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
3931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
3933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
3934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
3940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3941e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
3942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3943e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
3944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3945e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
3946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
3948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
3949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3950e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3951e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
3952e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
3953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
3954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
3955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
39581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
39591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
39601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
3961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
3963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
396401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
396501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
396601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
396701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
3968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
3970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
3972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
3974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
3975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
3976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
3977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3978177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
39799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
398074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
398274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
3983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
3985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
3986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
3988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
3989850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
399062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
3991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
3992850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
3993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3995f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3996f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3997f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
399974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
400074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
400174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
400274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
4003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
400474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
400574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
400674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
400774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
400874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
400974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
401074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
4011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
4012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
4013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
4015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
4016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
4018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
4019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
4020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
402382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
402482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
402582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
402682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
402782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
402882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
402982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
403082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
40318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
403282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
40338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
403482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
403582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
40368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
40378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
40468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
404782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
404882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
404982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
405074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
40514b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
40524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
40534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
40544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
40554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
405682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4081177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4082177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4083177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
409162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
40921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
40961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
409762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
410062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
410362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
411862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
412062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4122177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4124177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4130b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
41311b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            if($ClassId eq $TypeId)
4132b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            { # class A<N>:public A<N-1>
4133b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko                next;
4134b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            }
4135b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4136850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4137850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4138850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4139850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4140177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4141850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
41434b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
41464b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
414901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
41511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
41554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4158850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
41643ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    if($Info=~/type[ ]*:[ ]*@(\d+) /) {
41653ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko        return $1;
41663ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    }
41673ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
41683ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    return "";
4169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4200f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $PName = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"name"};
4201f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
4203f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
4204f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($PName eq "this"
4205f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method")
4206f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
4207f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
4208f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
4209f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
421062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
421262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
423462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
425262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
425362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4261f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
42669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
42781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
42811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4287b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko{ # TODO
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
42961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
432607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
43271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
432835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
43291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
433035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
433135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
433235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
43331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
43341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
43351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
43361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
433707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
43471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
43481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
43491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4350850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
43511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
43521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
43531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
43541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
43721477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4384850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4385850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
43861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4420f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/C1([EI])/C2$1/;
4421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D0([EI])/D1$1/;
4427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4429f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D1([EI])/D2$1/;
4430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
443507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
44371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
44391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
44431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
44441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
44471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
44481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
44491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
44511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
44521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
44531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
44611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
449862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
450074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
450407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
450562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
45341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
453535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
45361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
453735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
453835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
453935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
45401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
45411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
45421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
45431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
454407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4680dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
4750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = macro_mangle($Repl->{$MangledType});
4754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mangled!~/$Replace/) {
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub delete_keywords($)
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
476662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
47779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
478362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
478562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
478662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
478762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
479362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
48019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
480762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
48089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4818989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4819989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4820989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4821989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4822989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4823989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4824989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4825989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4826989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4827989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4828989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
48320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
48370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
48390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
48408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
48418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
48420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
48438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
48448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
48450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
48468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
48478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
48480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
48490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
48500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
48530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
48540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
48600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
48610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
48660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
48680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
48690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
487062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
48710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
48720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
48730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
48750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
48770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
48780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
487901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
488001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
488101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
488201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
488301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
488401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
48850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
4890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4893989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
4894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4895989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
4896dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
4897989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
4898989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
4899989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
4900989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
4901989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
4902989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4903989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
4904989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
4905989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4906dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
4907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
4910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
4911fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
4912570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
4913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
4914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
4915570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
4916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
4918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
4919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
4922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
4924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
4925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
4926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
4928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
4930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
4931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
4935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
4936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4937850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
4938850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
4939850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
4940850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
4941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
4946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
4947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
4948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
495062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
4951f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"})
4952f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or $EMERGENCY_MODE_48)
4953f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
4954f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
49558a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko      # GCC 4.8.[012] doesn't mangle anything
49561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
4957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
4959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
4960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
49621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
4963f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or not $BinaryOnly
4964f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or $EMERGENCY_MODE_48)
49651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
49661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
49671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
49681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
49691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
49701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
4971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
4976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
4978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
4979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
4980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
4984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
49851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
4986989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
4987989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
4988989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
49891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
49901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
4991a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
4992a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
49971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
4998a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
4999a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
500374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
50041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
5005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
500662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
5008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
5009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
501062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
501162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
501262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
501462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
501562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
501662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
501762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
501862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
501962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
502062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
502162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
502262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
50251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5027a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
5028a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
502974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
503074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
503174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
503274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
503374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
503474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
503574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5036a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5040a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5041a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5045a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5046a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5047a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
50481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
50751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
50771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
50781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
50791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
50801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5081b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(@TParams) {
5082b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".join(", ", @TParams).">";
5083b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
5084b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
5085b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<...>";
5086b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
50879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
50911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5093f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5094f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5095f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5096f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5097f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5098f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5099f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5100f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5101f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5102f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5103f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5104f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5105989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
51061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
51079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
51091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
51141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
511507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
511607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
51171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5121fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
513162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
513262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5133177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5134177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5135177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
513662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
513762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
513862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
513962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
514035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
514135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
51421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
514335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
51471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
51511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
51521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
51541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
51551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
51571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
51591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
51601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5169dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5175fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5176fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5177fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
51798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
51808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
51818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
51828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
51838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
51848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
51858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
51868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
51888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
51898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
51908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
51948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
51968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
51978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
52008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
52018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
52028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
52038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
52048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
52058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
52068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
52071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
52091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5212989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5213a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5214989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5215989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5216989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5217989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5218989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5219989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5220989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5221989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5222989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
52251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
522782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5228e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5229e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
52301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5234b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
523662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5239850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5240850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5241570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5242570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5243570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5244570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5245570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5246570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5248850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
52511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
52521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
52531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
52569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
52571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
52651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
52691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
52741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
52771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
52811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
52851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5288dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5289dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5290dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
52919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
52929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5293dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5294dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5296dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5298f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
52991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
53001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
53031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
530507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
530607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
530707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
530807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
530974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
531074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
531174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
531274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
531374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
531474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
531574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
531674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
531774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
531874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
531974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
532074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
532174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
532274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
532374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
532474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
532574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
532674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
532774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
532874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
532974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
533074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
533174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
533274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
533374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5339dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5340dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5341dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5342dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5343dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5348e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5349e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5350e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5351e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5352e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5353e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5354e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5355e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5356e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5357e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5358e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5361dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5362dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5364dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5365dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5367dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
53740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
537574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53784b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
53794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53814b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
53824b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
538362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
53844b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
53854b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
53860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
53924b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53944b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
53954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5396989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5397989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
539874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
539974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
540074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
540174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
540274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
540374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
54044b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54074b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5408fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
54091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5410fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
541401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
54164b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
54264b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
543062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
543162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
543262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
543362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
543462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
54370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
54380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
54394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
54401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
54410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
54420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
54430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
54440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
54450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5449f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
54504b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5451f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
54520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5464f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
54654b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
54660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
546974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
547074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
54751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
547662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5477f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5478f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5479f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5480f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
548262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
548362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5484850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
548562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5486850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5487850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
548862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5490850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5492850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5493850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5494850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5496ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5497ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5499f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos, $Vtt_Pos) = (0, 0, -1);
5500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
55010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
550262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
550362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
550462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
550562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
5506f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $ParamName = "p".($PPos+1);
5507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
550862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
550962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
551062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
551162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
551262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
551362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
551462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
551862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5519989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5520989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5521989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5522989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5523989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5524989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
552662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
55280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
55320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
554262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
554362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
554462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
55470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
55500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5551f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($ParamName ne "this" or $FType ne "Method") {
5552f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5553f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
5554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
555601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
55631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
55641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
556562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
5566f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5567f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5568f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5569f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
5570f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        # skip "this"-parameter
557146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
55740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
55750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
55760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
5578f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos) = (0, 0);
5579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
55800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
55810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
55820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
55830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
558962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
559062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5591dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
559546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
559746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
559846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
559946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
560046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
560146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
5602f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($PPos+1);
560346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
560446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
560546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
560646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5607e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
560846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
560946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
561046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
561146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
561246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
561346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
561446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
561546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
561646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
561746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
561846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
56190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
56200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
562162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
56220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
562301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
562401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
56258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
56268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
56278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
56288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
562901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
563001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
563101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
563201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
5636f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Pos!=0 or $FType ne "Method") {
5637f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5638f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
56390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
564462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
564562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
564662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
564762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
564862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
564962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
565062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
565162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
565262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
565362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
565462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
565562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
565662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
565762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
565862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
565962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
566062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
566162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
566262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
566362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
566462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
566562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5666e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5667e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5668e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5669e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5670e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5671e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5672e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5673e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5674e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5675e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5676e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
567762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
567862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
567962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
568062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
568162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
568262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
568362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
568462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
568562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
568662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
568762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
568862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
568962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
569062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
569162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
569262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
569362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
569462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
569562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
569662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
569762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
569862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
569962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
570062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
570162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
570262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
570362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
570462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
570562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
570662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
570762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
570862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
570962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
571062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
571462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
571562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
571662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
571762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
571962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
572062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
572162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
572262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
572362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
572462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
572562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
572662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
572762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
572862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
572962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
573062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
573162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
573262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5734dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5735dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
573662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
573762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
573862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
573962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
574062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
574162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
574262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
574362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
574462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
574562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
574662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
574762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
574862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
574962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
575062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
575162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
575262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
575362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
575462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
575562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
575662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
575762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
575862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
575962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
576062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
576162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
576262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
576362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
576462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
57658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
57668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
57678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
57688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
57698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
57708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
57718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
57728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
57738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
57748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
57758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
577662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
577762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
577862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
577962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
578062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
578162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
578262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
578362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
578462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
578562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
578662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
578762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
578862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
578962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
579062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
579162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
579262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
579362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
579462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
579562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
579662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
579762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5798177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5799177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5800177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5801177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5802177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5803177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5804177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5805177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5806177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5807177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5808177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
580962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
581062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
581162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
581262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
581362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5814dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5815dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5822dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5823dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
58243ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko        if($Info=~/(low|int)[ ]*:[ ]*([^ ]+) /) {
58253ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko            return $2;
5826dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5833dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5835dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5836dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5837dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5838dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5839dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5840dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5841dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5842dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5843dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5844dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5845dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5846dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5849dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5850dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
58591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
58611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
58641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
5872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
5873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
5874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
5876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
5877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
5881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5882dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5883dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5884dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
5885dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
5886dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
5888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
5889dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5890dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
5891dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
5892dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5896989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
5897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5898dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5899dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5900dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
5901dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5902dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5903dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
5904dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5905dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5906dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
5907dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5908dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5909dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5910dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
5911dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5912dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5913dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
5919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5920dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5921dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5922dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
5923dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
5924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5925dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
5926dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5929dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
593274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
5933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
593474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
593574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
593674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
593774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
593874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
593974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
594074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
594174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
5942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
594374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
5944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
594574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
594674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
594774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
594874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
595074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
595174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
595274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
595374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
595474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
595874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
595974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
596274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
5963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
5965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
596674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
5967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
596874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
596974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
597074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
597174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
597374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
597474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
597574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
597674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
597774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
598174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
5985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
598674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
598774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
5988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
598962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
5990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
599162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
5992dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
599362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
599462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
599562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
599662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
599762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
599862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
599962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
600062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
600162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
600262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
600362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
600462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
600562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
600662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
600762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
6008dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
601162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
601262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
601362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
601462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
6015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6017dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
6021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6022dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6024dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
6025dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
6026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
6027dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
6028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
6029dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
6030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6031dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6032dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6033dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6035dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6036dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6044dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6045dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6046dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6047dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6048dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6050dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6055dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6056dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6057dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6058dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6059dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6061dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6064f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6066dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6067dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6068dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6069dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6070dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6072dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
607562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
607762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
607862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
608062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
608162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6083dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
608662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
608762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
608962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
609062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
609262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
609362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
609462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
609662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
609762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
610062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
610162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
610262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
610362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
61048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
61058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
61068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
61078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
61088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
61098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
61108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
61118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
61128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
61138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
61148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
61158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
61168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
611762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
611862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
611962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
612062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
612162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
612262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
612362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
612462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
612562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
612662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
612762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
612862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
612962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
613062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
613162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
613262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
613362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
613462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
613562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
613662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
613762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
613862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
61398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
614062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
61418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
614262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
614362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
614462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
614562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
614662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
614762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
614862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
614962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
615062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
615262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6161f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6163850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6164850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6172850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6173850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
62019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
62098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
62299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
62449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
626174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6262850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
62634b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
626474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
626574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
626674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
626774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
626874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
626974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
627074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
627174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
627374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
627474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
627574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6276850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
627874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
627974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
628074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
628174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
628274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
628374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
628474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
628574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
628674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
63069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
63139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
63168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
63198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
63218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
63228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
63238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
63268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
63319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
63429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
63479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
63529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
63579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
63619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
63629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
63669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
63679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
63719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
63728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
63738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
63748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
63758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
63778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
63798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
63818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
63838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
63848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
63858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6392570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6394570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6395570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6396570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6397570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6398570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6399570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6400570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6402570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6403570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6406a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6407a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6408a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6409a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6410a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6411a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
64218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6422570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6423570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6433570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
64418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6446570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
64498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6460850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6461850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6463850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
647462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
648562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
64899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
64909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
65008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
65018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
65028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
65038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6504fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
65058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
65068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
65078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
65088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
65098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6510dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6511dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6512dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6514dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6515dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6516dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6517dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6518dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6519dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
652062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6522dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6523dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6524dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6525dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
65456fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko                { # all names are different with current prefix
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6555850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6556850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6557850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6558850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
65618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6600850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6634850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6635850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
663962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
664262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
66489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
66499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
66509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
66519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6656850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
66588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
66598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
66608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
66618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
66628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
66638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
66648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
66658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6666850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
667174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6682fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6686fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
669274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6695fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6696fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6697fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6698fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6699fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6700fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6701fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6702fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6703fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6704fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6705fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6706fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6707fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6708fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6709fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
672374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
672474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6731570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6732570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6733570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6734570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6735570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
673874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6749850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
675374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
675581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                $HPath = realpath_F($Candidate);
6756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
67591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
676274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
676862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
67759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
67769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
677774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
677874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
677974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
678074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
67819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
67829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6793850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6794850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6795850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6796850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6797850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6798850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6799850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6800850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6801850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6802850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6803850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6804850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6847570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6848570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6849570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6850570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
6875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
6878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
6879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
6882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
6883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
6886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
6887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
6893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
68948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
6895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
68968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
6898a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
69018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
69028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
69038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6904a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
69058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
69068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
6907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
69088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
69098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
69108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
69118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
69128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
69138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
69148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
6923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
6925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
6926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
6927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
6928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
6930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
6931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
6958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
6962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
6963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
6966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
6967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
6968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
6973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
6980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
6981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
69909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
69979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
69989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
69999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
70009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
70019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
70029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
7024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
7025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
7028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
7029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
7030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
705762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
705862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
705962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
706062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
706162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
706262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
706362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
706462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
706762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
706862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
706962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
707062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
707162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
707262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
707362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
707562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
707662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
707762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
70819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
70829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
708362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
70869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
70879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
70889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
70899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
709074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
709474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
709574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
709674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
709774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
709974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
710007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
710174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
710274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
710374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
710407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
710507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
710607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
710762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7108570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
711174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7114e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
711562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7116e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
712262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
712562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
712662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
713562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7156570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
715962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
716062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
716262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
716362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
716562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
716662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
716762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
716962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
717262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
718474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7194dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
719674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
720662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
720762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
720862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
720962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
721062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
721162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
721274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
721362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
721462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
721662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
721762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7222dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7223dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7224dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
72259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7226dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
72280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7233989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7235dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7239dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
72418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
72428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
72438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
72448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
72458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
72468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
72478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
72488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
72498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7250dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7251dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7259989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7261989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7262989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7263989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
726407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7266570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7267989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7268989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7269989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7271989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7274989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7279989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7281570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7282989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7283570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
728462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
728562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
728662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
728762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
728862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
728962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
729062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
729462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
729562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
729662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
729762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
729862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
729962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
730062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
730162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
730262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
730362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7304989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7305989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7309989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7310989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7311989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7314989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7319989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7320989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7321989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7322989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7323989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7324989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7325989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7333989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7334989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7335989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7336989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7337989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7339989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7344dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7351a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
73599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
73609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
73619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
73629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
73639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7364570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
73659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
73669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
73679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
73689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
73699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
73709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
73719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
73729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
73739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
73749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
73759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
73769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
73779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
73809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
73869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
73879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
73949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
73959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
73989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
740762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
740862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
740962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
741062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
741262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7414f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/C1[EI]/) {
7415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7417f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/C2[EI]/) {
7418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
742162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7423f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/D1[EI]/) {
7424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D2[EI]/) {
7427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7429f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D0[EI]/) {
7430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7436f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Symbol=~/C1[EI]/) {
7437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7439f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/C2[EI]/) {
7440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7442f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D1[EI]/) {
7443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7445f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D2[EI]/) {
7446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7448f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D0[EI]/) {
7449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
74560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
74570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
74580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
74590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
74600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
746162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
74620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
74630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
74640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
74650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
746862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
746962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
747062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
747262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
74738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
7474ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
747562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
74768a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
747762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7481aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
7482aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $ClassName=~s/\bstruct //g;
74838a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
74848a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(index($Symbol, "_ZTV")==0) {
74858a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return "vtable for $ClassName [data]";
74868a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
74878a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
7488aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $Signature .= $ClassName."::";
7489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
749462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7495fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7498fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
750007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
750107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7503fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7504fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7505fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
750862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
75108a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($Pos eq "") {
75118a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            next;
75128a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
75138a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
751462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
75158a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if(not $ParamTypeId) {
75168a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            next;
75178a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
75188a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
751962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
75258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
75268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
75278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7531f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($ParamName eq "this"
7532f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $Symbol=~/\A(_Z|\?)/)
7533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
7535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7536f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
754262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
754362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
75448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
754862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
75508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
75528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
755362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
755462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
75558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
755762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
755862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
75598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
756162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
756262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
756374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
75648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
756862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
75698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
75728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
75748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7580989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7581989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7597989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7598989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7599989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7600989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7601989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7602989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7603989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7604989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7605989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7606989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7607989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7608989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7609989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7610989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7611989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7612989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7613989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7615f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7620989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7621989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7622989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7623989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7624989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7626989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7630989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7631989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
76349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
763562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
76369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
76379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
763862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
763962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
764162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
76439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
76459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
76469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
76479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
76489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
76499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
765062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
765199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    $N=~s/\b(const|volatile) ([\w\:]+)([\*&,>]|\Z)/$2 $1$3/g; # "const void" to "void const"
765299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
7653f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
765462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7655f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7656f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
765762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7658f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
765962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7660f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
766162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
76639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
76659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
76669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
76679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
766862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7669dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko    $N=~s/,([^ ])/, $1/g;
767099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
76719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7735570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7745989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7746989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7747989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7750989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7754989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7755989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7756989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7757989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7758989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7759989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7760989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7761989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7762989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7763989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7764989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7765989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7766989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
776774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
776874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
776974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
777074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
777174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
777274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
777374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
77871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
779774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
780674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
780874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
78091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
78101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
781474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
781574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
78251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
78271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7832570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
784062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
7853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
7854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
7868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
7878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
787981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            "-D__unaligned=\" \"",
788081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            "-D__nullptr=\"nullptr\"",
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
7882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
7887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
7889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
7890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
7891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
7892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
7893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
7894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
7895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
7896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
7897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
7901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
7902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
7903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
7904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
7905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
7906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
7907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
7908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
7909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
7910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
7911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
7912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
7913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
7914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
7915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
7916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
7917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
7918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
791981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if($Arch eq "x86")
792081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        {
7921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
7922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
792381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        elsif($Arch eq "x86_64")
792481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        {
7925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
792681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            $MinGW_Opts{"-D_M_X64=300"}=1;
7927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
7929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
7930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
7932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
7937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
7938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
7939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
7940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
7941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
7942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
7943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
7944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
7945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
7946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
7947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
7948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
7949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
7950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
7951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
7952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
7953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
7954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
7955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
7956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
7957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
7958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
7959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
7960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
7961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
7962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
7963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
7964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
7965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
796682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
7967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
7968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
7969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
7971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
7972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
7974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
797801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
797982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
7980570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
798174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
798274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
798382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
798482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
798582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
798682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
798782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
798882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
798982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
799082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
799182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
799282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
7994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
7996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
7998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
7999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
8001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
8004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
8005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8006f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
8007f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($EMERGENCY_MODE_48)
8008f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # workaround for GCC 4.8 (C only)
8009f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $GccCall .= "c++";
8010f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
8011f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    elsif(check_gcc($GCC_PATH, "4"))
8012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
8013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
8014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
8015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
8019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
8020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
8022d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # platform-specific options
8023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
8024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
8026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
802701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
802801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
8029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
8030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
8032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
8033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8034d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(my $Opts_GCC = getGCC_Opts($Version))
8035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
8036d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $GccCall .= " ".$Opts_GCC;
8037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8038a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
8039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
8040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
8041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
8042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
8044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
804601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
8047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
804801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
8049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
8050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
8051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
8052850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
80539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
80549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
8055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
80579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
80589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8063bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8064bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
80659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8066850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8069850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8070850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
80729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
807501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
807601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
807701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
80789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
807901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
808001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
808101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
808201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
808301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
808401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
808501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
808601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
80879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
80889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
80899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
80909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
80919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
80929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
80939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
80949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
809501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
809601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
809701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
809801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
80999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
810001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
810101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
81029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
810301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
810401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8105f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8106f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8107f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8108f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8109f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8110f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8111570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8112570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8113570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8114570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8115570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8116570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8117570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8118570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8119570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8120f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8121570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8122570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8123570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8124570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8125570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8126f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8127f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8128bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
812982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
813082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8131bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8132bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8133bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8134bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8135bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8136bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8137bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8138bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8139f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8140bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8141f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
81429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8143f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8144f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8145f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8146f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8147f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8148f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
81499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
81509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
81519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
81529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8153f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8154f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
81559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
81569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
81579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8159f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8160f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
81619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8162f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
81639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
81649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
81659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
81669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
81689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
81709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
81739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
81769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8181f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8182f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8183f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8184f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
81858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
818601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
81878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
81889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
81898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
81908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
819107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
81968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
82138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
82178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
82198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
82201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
82228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
82248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8229bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8230bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8231bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8232d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*([\,\)\;\.\[]|\-\>|\:\s*\d))/$1$2c99_$3$4/g)
8233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8235d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko          # int foo(char template[], char*);
8236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
823907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8240bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
824807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8249bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
825807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8259bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
826607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8267bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
827507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8276bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
828307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8284bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
82909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
82929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
829307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8294bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
829507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
82968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
82978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
82988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
82998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
83008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
83018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
83028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
830307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
830407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
830507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8306bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8307bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8308bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8309bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
831007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
83139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
83148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
83159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
83169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
83179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
83189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
83199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
83209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
83218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8322fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8323fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8324fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8325fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
83279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
83299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
83309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
833207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
83358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
833607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
83388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
83408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
83418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
83428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
83458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
83468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
83488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
83498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
83508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
83518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
83548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
83558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
83578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
83598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
83608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
83628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
83638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
83648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
83678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
83698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
83708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
83738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
83758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
83798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
83838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
83848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
83868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
83878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
83898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
83908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
83918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
83928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
83938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
83948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
83958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
83998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
84008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8402850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8403850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
84048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
84058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
84068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
84078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
84098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
84108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
84118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
84128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
84148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
84158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
84168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
84188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
84198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
84208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
84238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
84248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
84258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
84278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
84288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
84318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
84328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
84338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8434850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
843807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
844462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8458f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8474a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8475a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8476a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8477a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
84811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8484f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8485f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8486f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8487f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8488f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
84898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8490f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8491f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8492f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8493570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8494f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8495f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8496f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8497f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8498f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8499570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8500570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8501570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
850582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
850682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
850782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
850882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
850982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
851082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
851182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
851282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
851382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
851482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
85169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
85179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
85189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
85199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
85209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
85219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
85229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
85239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8524f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8525f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8526f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
85278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
8533d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($UserLang eq "C") {
8534d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TUdump .= " -U__cplusplus -D_Bool=\"bool\"";
8535d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
853607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
85408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8543a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
854801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
854901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
855007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
85512b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and index($Errors, "c99_")!=-1
85522b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and not defined $CppIncompat)
855301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
855407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
85552b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
85562b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                if($Debug)
85572b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                {
85582b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                    # printMsg("INFO", $Errors);
85592b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                }
85602b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
856107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
856201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
856301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
856401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
856601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
85679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
856801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
856901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
85709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
857301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
858401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
858501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
858601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
858701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8595570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8597570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8598570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8599570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8600570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
860101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
860201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
860301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
860401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
860501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
860601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
860701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
860801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
860901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
861101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
861201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8617570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8620f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
86218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8622570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8623570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8624570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8625570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8628570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8629570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8630570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8631570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8632570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8649989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8671a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8672a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8673a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8674a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8675a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8676a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8677570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8681570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8691570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8692570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8693570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8694570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8695570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8696570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8697570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8698570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8699570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8700570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8701570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8702570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8703570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8704570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8705570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8709570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8719f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8720a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8721dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
87244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
87346fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Cmd = "dir \"$Path\" /B /O";
8735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
874174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
874274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
874374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8744570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
87468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
87478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
87488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
87498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8750570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
87518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
87538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
875974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8791570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8792570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8793570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
87959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
87968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
87979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
87989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8799570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8800570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8801570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
88028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8803570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
88044b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8812447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
8813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8819447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
8820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
882774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
882974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
883274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
883674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8840b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko      # *.tar.gz.amd64 (dh & cdbs)
8841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8853a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
885774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
885974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
886374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
886774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
887074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
887674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
8877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
887874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
888174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
888574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
8891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
88935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
88945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
88955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
8898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
8910a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
8924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
8927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
8928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
8931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
8933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
8934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
8936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
8942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
8946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
8954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
8956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
8958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
8963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
8965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
8968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
8972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
8973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
897562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
8976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
8977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
8980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
8984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
8985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
8986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
8990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
8991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
8992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
8996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
8997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
8998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
8999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
9001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9002570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
9003850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
9004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
9005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
9006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
90121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
9013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
9015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
9016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
901846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
90199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
90209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
90219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
90229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
90239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
9024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
9025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
9027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
9029850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
9030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
903146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
9032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
9038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
9039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
9040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
9041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
9042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
9045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
9046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
9048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
9052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
9056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
9057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9081177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9082177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9083177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
90981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
910662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
910962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
911162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
911262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
911362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
911462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
911562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
911662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
911762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
911862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
912162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
912462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
912862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9130f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
913162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
913301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
913462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9135f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
913601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
913701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
913862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
913962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
914062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
914162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
914762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
915062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9152f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
915362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
915562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
915662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
915762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
915862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
915962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
91661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
91691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
91701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
91711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
9172ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
91731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
91741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
91751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
91761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
91781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
91791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
91811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
91821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
918462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
918562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
920762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
92081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
921062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
92110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
92120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
92130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
92140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
92150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
92160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
92170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
921862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
92190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
92200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
92210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
92220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
92230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
92240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
92250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
92260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
92270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
92280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
92290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
92300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
92311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
92331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
92341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9235082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
92411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9242850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
92431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9244850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9245989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
92461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
924762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
924862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
92491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9255850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9257850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9258850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9259850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9260850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9261850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9262850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9263850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9264850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9265850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
92685c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
92695c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
92705c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
92715c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
92725c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
92735c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
92745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
92755c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
92765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
92775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
92785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
92795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
92805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
92815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
92825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
92835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
92845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
92855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
92861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
92931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
92981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
93001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
93011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
93021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
93031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
93041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
93051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
93071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
93151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
93208a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
93218a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        # NOTE: duplicated entries in the ABI Dump
93228a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if(defined $CompleteSignature{$LibVersion}{$MnglName})
93238a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
93248a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
93258a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            {
93268a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} eq "p1")
93278a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                {
93288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    next;
93298a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                }
93308a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
93318a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
93328a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
9333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
93351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
93361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
933862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
93471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9349850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9350fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9351fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9352fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
93538a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
9354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9355fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9357fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9358fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9359850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
93601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9369850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9370850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9371850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9372850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9373850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
93769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9377850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
937962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9381850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9383850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9385850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9390850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9392850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9394850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9395850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9396850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9397850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9398850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9399850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9400850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9401850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9402850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9403850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
940662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9407850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
94101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9412850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
941462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9415850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9416850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
941862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9430850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9432850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
943362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
943562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
94371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
94381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9439850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
94401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
94411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9442850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
94431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
94489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
94499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
94509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9452dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
945374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
94549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9456dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
945874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
945974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
946062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
946174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
94661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
94671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
946862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
94691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
947062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
94711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
947262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
947362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
94741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
947562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
94761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
947762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
947862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
94791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
948062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
948162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
94821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
94831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
94841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
94851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
94861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9500177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9519177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
955062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9552989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9554989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9556989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
955862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9559850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9571850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9572989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9575989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9576850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9577850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9578850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9579850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9581850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9582850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
95831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9584850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9585989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9590989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
95911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9592850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9596850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9597177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9598989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9599177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9600989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9603989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9604989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9612177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9614177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9623989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9624177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9625177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9626177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9627177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9628177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9629177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
96301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9631177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9632177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9633177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
96341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
96351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
96361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
96371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
963935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9641850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
964235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
964335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
964435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
964535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
964635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
964735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
964835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
964935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
965035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9651850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9652850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
96540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9656850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9658850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9659850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
96608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
96618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9662c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
96638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
96648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
96658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9666177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9667850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9668850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9669850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9670850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9671850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9672850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
96730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9674850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
96750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
96760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
96770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9678850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9679850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9680850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
96810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9682850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9683850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9684850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9686850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9688850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9689850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9690850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9691850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9692850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9693850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9701850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
970335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
970435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
970535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
970635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
970735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
970835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
970935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
971235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
971335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
972101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
9722ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($SInfo, $LibVersion))
972335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
972435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
972535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
972635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
97270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
97280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9732850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9734850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9735850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9736850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9737850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
97380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
97390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
97400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
97410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9742850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9743850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
97451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9747177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9748177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9749177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9750177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9751177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
97521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9753177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9754177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
97551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9759177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9760177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9761989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9762989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9763989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
97661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9768850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9769850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9770850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
977101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
977201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
977301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9774f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId}{"Type"});
9775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
977662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9778177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9779177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9780177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9781177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9782177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
978301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
978462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
978662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
978762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
979001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
979101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
979201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9793850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
979462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
979562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
979628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub pickType($$)
979762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
979862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
97999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
98009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
98019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
98029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
98039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
98049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
98059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
98069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
98079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
98089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
98099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
98109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
981128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"};
981228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
981328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isBuiltIn($THeader)) {
981428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
981528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
981628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
981728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/) {
981828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
981928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
982028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
982128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"})) {
982228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
982328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
982428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
982528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(selfTypedef($Tid, $LibVersion)) {
982628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
982728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
982828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
982928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(not isTargetType($Tid, $LibVersion)) {
983028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
983128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
983228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
983328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 0;
983428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko}
983528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
983628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub isTargetType($$)
983728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko{
983828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
983928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
984028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/)
984128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    { # derived
984228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 1;
984328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
984428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
984562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
98468a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    { # NOTE: header is defined to source if undefined (DWARF dumps)
984728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(not is_target_header($THeader, $LibVersion))
984828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        { # from target headers
984928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
9850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9851850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
98528a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    else
98538a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    { # NOTE: if type is defined in source
98548a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($UsedDump{$LibVersion}{"Public"})
98558a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
98568a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(isPrivateABI($Tid, $LibVersion)) {
98578a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return 0;
98588a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
98598a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            else {
98608a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return 1;
98618a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
98628a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
98638a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        else {
98648a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            return 0;
98658a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
98662c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
986728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
98681fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalTypes)
98691fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
98701fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$Tid}{"Name"}=~/($SkipInternalTypes)/)
98711fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
98721fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            return 0;
98731fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
98741fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
98751fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
987628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 1;
9877850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9878850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9880850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9881850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9886850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
989828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            if(pickType($Tid, $LibVersion))
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9930989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
9933850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
9935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
9936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
9938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
9943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
9944850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9946989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9952177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
9956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
9960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
9964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9965177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
9966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
9967989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
9968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9969177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
9972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
9974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
9978177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
9980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
9982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
9983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
9985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
9987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
9988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
999262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
9993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
9994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
999562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
9996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
9998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
9999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
10001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
10003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
10005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
10006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
10009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
10012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
10015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
10016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
10018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
10019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
10020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
10021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
10022850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
10027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
10028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
10030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
10031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
10032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
10033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
1003462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1003562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
10036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
10037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
10038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
10040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
10041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
10043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
10045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
10046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
10047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
10048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
10049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
10050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
10052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
10054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
10056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
10057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
10058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
10059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
10061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
10062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10063850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
10064850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1006562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
10066850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
1006762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1006862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
10069850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
10070dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
10071f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
10072850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
10073850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10074850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
10075850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
10076850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10077850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
10078850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10079850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
10080850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
10081850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
10082850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10083850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
10085dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
10086850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
10087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
10090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1009428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(pickType($Tid, $LibVersion))
10095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
100968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
100978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
100988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1009962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1010062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1010162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1010262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1010362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1010462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1010562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1010662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
101078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
101088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
101098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
101128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
101138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
101148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1012062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1013562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10143e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10144e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10145989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10146989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10154e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10155e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
101651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
101671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
101681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
101711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1017362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
101751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
101761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
101821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10192850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
101981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
101991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
102001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
102011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
102021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10203850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10204850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10236fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10237fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10240fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10249fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
102561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
102591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10260fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1028662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
103041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1031062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1033762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10338850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10339850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10341850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1035462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10355dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10356dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10357dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10358dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10359dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
103661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
103681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
103691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
103701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
103721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
103731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
103741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
103781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
103791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
103801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
103841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
103851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
103861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
103871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
103881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1039462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10404dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10405dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10409dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10415a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko    foreach my $MemPos (sort {int($a)<=>int($b)} keys(%{$TypePtr->{"Memb"}}))
10416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10437d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused|dummy)[_\d]*\Z/i) {
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10449737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
10450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10453737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
10454737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    my $Access = $TypePtr->{"Memb"}{$FieldPos}{"access"};
10455737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if($Access eq "private")
10456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10457737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        return 0;
10458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10459737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
10460737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    # by name in C language
10461737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    # TODO: add other methods to detect private members
10462737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
1046381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if($MName=~/priv|abidata|parent_object|impl/i)
10464737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    { # C-styled private data
10465737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        return 0;
10466737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
10467737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if(lc($MName) eq "abi")
10468737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    { # ABI information/reserved field
10469737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        return 0;
10470737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
10471737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if(isReserved($MName))
10472737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    { # reserved fields
10473737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        return 0;
10474737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
10475737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
10476737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    return 1;
10477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
104801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
104821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
104831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1048462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
104851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
104861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
104871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
104881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
104901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
104921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
104931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
104951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
104961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
104971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
104981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
105001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
105011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
105051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
105171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
105181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10519dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
105201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
105211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
105221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
105241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
105311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
105341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
105361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10539ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
105421fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
105438a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($Entry1=~/ 0x/ or $Entry2=~/ 0x/)
105441fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        { # NOTE: problem with vtable-dumper
105451fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            next;
105461fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
105471fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
10548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10562989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10563989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10564989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10565989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10566989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10567989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10568989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10569989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10570989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
105711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
105791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10582e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10583e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId, 1)) {
10584e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10585e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10586e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
105871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
105961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
106041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
106061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
106071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
106091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10611e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10612e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId, 1)) {
10613e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10614e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10615e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10616dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10619dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
106211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10622dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
106231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
106241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
106251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
106261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10627dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10632dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10635dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
106371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10638dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
106391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
106401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
106411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
106421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10643dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
106491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1065062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
106511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
106521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
106531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
106541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
106571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
106581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
106601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
106611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
106641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
106671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
106701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
106711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
106721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
106731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
106741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
106751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
106761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
106799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
106809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
106819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
106829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
106831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
106849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
106851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
106861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
106881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
106891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
106929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
106939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
106941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
106951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
106961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
106971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
106981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1070362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1070462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
107051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
107069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
107091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
107111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10713e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10714e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId_Old, 1)) {
10715e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10716e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10717e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1072762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
107281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1073262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10734850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10735850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10736850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10737850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10738850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10739850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10740f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10741850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10742850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10743850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10744850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10747ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10748ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $Class_New{"Size"} or not $Class_Old{"Size"})
10749ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # incomplete info in the ABI dump
10750ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
10751ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
10752ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10753ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10756f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10757f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10758f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10759f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10761f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10762f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1076374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1076474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10767f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1077262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10773f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10776f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1077774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
107811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
107821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
107831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
107841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
107851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
107861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
107931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10802f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10803f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10804f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10805f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10806f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10807f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
108129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
108149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
108151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1082862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10829f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10832f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1083374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
108371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
108381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
108391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
108401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
108411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
108421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
108431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
108441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
108451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
108461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
108491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
108501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
108511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
108521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
108551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10858f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10859f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10860f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10861f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10862f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10863f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
108689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
108709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
108711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
108811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
108821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
108831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10884f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10885f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
108861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1088862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10889f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
108901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10891f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10892f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
108931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
108941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
108951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
109011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
109031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
109041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
109051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
109071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
109081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
109091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
109101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
109161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
109181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
109201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
109211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
109221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
109231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
109291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
109311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
109351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
109361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
109371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
109381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
109391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1094062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1094162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10942f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
109431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
109441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
10946d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        my $ProblemType = undef;
109471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
109481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
109511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
109531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
109541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
109551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
109561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
109571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
109581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
109591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
109601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
109611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
109661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
109689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
109721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
109731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
109741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
109751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
109761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10980f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
109811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
10982f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
109831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
109841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
109851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
109861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
109871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
109881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
109891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
109901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
10991f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
109921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
10993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1099462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
10995f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
109961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
109971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
10998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
110001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
110011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
11002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
11003850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
11004f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
11005f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
110061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
110071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
11008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11009850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
110101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
110111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
110121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
11013850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
11014850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
110151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
110161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
110171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
110181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
110191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
110201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
110221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
110231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
110241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11025850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
110261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
110281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
110291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
110301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
110311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
110331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
110341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
110351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11036850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
110371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
11039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
11050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1105262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
11053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
11054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
11057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
11058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
11059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
11062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
11063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
11064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
11070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
110711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
11072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
11073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
11074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1107662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1107762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
11078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
11079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
11085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
110861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
110871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
11088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
11089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
11090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
11091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
11092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
11093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
11094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
110961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
110971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1109962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
111001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
111011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
111021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
111031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
111041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
111051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
111061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
111071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
111081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
111091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
111100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
111111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
111121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
111130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
111150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
111160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
111170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
111180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
111190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
111200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
111210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
111220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
111230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
111280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
111290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
111300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
111310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
111360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
111380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
111391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
111401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
111411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
111421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
111431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
111441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
111451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
111461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
111471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
111501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
111541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
111551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
111561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
111571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
111601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
111641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
111651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
111669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
111671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
111681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
111691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
111721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
111791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
111801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
111831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
111901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
111931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11194dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11195dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
111961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11198dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11200dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
112011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11202dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11203dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11204dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
112079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11210dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11211dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11212dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11213dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11214dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1121562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
112161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
112201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
112211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
112221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
112261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
112271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
112281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
112291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
112309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
112311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
112321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
112341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
112351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
112381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
112391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
112411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11243dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11245dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11246dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11247dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11248dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11249dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
112501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11251dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11253dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11255dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
112561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
112571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11258dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11259dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11260dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11261dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11264dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11265dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11266850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
112689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11271dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11272dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11273dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11274dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11275dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11276dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11277dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11278dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11279dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1128062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
112811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
112871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
112881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
112891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
112901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
112911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
112921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
112931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
112941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
112951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
112971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
113011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
113031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
113041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
113051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1134662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1134762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
113588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
113598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
113601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
113618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11369f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1137362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11374f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1137662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1137762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1138062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1138162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1138262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1138462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1138562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1138662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1138862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1138962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1139062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1139262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1139362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1139462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11404ce36037cd5eadbc0cee77abd9215a89d4257e4e4Andrey Ponomarenko    if($Name=~/last|count|max|total|num/i)
11405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11439fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11440fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11482fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11491e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenkosub isPrivateABI($$)
11492e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko{
11493e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
11494e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11495e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if($CheckPrivateABI) {
11496e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return 0;
11497e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11498e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11499e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$TypeId}{"PrivateABI"}) {
11500e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return 1;
11501e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11502e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11503e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    return 0;
11504e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko}
11505e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
1150662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1150862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
11509f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Id or not $Type2_Id);
11510f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1151186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
11513f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id};
11514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11515f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1151662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1151762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
115181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
11519f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
115201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11522f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11523f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11524f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1152586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"})
1152686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    {
1152786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        if($Type1_Pure{"Name"} eq "__unknown__"
1152886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Pure{"Name"} eq "__unknown__")
1152986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        { # Error ABI dump
1153086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = {});
1153186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        }
1153286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    }
1153386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
11534e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if(isPrivateABI($Type1_Id, 1)) {
11535e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return {};
11536e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11537e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11538e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11539e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11540e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11541f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my %SubProblems = ();
11542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11543fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11544fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11545fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11546fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11547fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11548fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11549fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
115501fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if(not defined $UsedDump{1}{"DWARF"}
115511fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and not defined $UsedDump{2}{"DWARF"})
115521fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                {
115531fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
115541fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Target"=>$Type1_Pure{"Name"},
115551fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
115561fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                }
11557fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11558f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11565850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11569f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return {};
11570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11571850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
115728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11574f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
11575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11576f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1_Pure{"Name"}});
11578f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1{"Name"}});
11579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
115801fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(not isTargetType($Type1_Pure{"Tid"}, 1)) {
115811fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return {};
1158228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1158328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
11584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11590fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11592fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11593fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11594fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11596fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11597fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11598fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11599fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11600fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11601fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1161562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1161662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
116186ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    if(%Typedef_1 and %Typedef_2
11619dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11620dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11622f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11623f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
116278580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko            or differentDumps("V")
116288580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko            or $SkipTypedefUncover)
11629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11634850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
116359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
116369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
116421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
11643d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            and $Type1{"Size"} and $Type2{"Size"}
116441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
116528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
116538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
1165486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
1165586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            if(defined $UsedDump{1}{"DWARF"})
1165686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            {
1165786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                if($Base1_Pure{"Name"}=~/\b__unknown__\b/
1165886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                or $Base2_Pure{"Name"}=~/\b__unknown__\b/)
1165986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                { # Error ABI dump
1166086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = {});
1166186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                }
1166286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            }
1166386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
11664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
116658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
116828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1168774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1168874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1168974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1169074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1169174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1169374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1169474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1169574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1169674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1169774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1169874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1169974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1170074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1170174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1170274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1170374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1170474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1170574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1170674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11708f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
117109e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
117118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
117129e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
117171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
11718d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        and $Type1_Pure{"Size"} and $Type2_Pure{"Size"}
117191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
117231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11733fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11734fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11744f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE);
11745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11747fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11748fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
117490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11750f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11751f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
11752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11753f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}})) {
11754f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
11755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MemberPair_Pos = (defined $Type2_Pure{"Memb"}{$Member_Pos} and $Type2_Pure{"Memb"}{$Member_Pos}{"name"} eq $Member_Name)?$Member_Pos:find_MemberPair_Pos_byName($Member_Name, \%Type2_Pure);
11766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1177362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11779082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11780082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11784082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11798082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11799082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11802082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11807082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MemberPair_Pos = (defined $Type1_Pure{"Memb"}{$Member_Pos} and $Type1_Pure{"Memb"}{$Member_Pos}{"name"} eq $Member_Name)?$Member_Pos:find_MemberPair_Pos_byName($Member_Name, \%Type1_Pure);
11822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
118261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1182762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11850082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11862082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
118851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
118861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
118871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
118901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
118911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1189362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1189562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
119131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11916082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
119198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
119208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
119218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
119228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
119238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
119248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
119258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
119268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
119389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
119399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
119409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
119419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
119429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
119439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
119449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
119611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
119621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
119631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
119641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
119651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(getOffset($MNum-1, \%Type1_Pure, $TypeInfo{1}, getArch(1), $WORD_SIZE{1})!=getOffset($RelatedField{$MNum-1}, \%Type2_Pure, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
11974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1198874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
119921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
119931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1199774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
12002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1200374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
12004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
12007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
12009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
12011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
12012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
12015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
12016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
12017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
12018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
12020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
12021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
12022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
12023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
12024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
12026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
12027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
12028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
12030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
12031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
12034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
12035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
12036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
12037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
12040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
12042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
12043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
12045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
12046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
12048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12050fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
12052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
12053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
12054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
12056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12059fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
12061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1206262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
12063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
12064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
12065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1206662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
12067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
12068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
12069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1207062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1207162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
120721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12073d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                and $SizeV1 and $SizeV2
120741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
12077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
12078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
12079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
12080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
12081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
12082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
12083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
12085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
12086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
12087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12091fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                if(getOffset($MNum-1, \%Type1_Pure, $TypeInfo{1}, getArch(1), $WORD_SIZE{1})!=getOffset($RelatedField{$MNum-1}, \%Type2_Pure, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
12104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
12105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1210646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1210746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1210846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1210946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1211046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1211146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1211246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
12113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
12114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
12115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
12116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
12117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
12118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
12119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
12120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
12124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
12125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
12126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1212862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
121290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
121300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
121330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
121340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1213574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
12140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
121410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1214274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
12145f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my %Sub_SubChanges = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
12146f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12148f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12149f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
12152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
12153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
12154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
12155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1215662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
12157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
12159f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
121600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12162f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
12163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
121650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
121660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
12168f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Added_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12171f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
121740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
121750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
12177f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Removed_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12180f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12182fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12183fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12184fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12185fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12186fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12188f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubChanges))
12189fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12190f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12191f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
12196f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                delete($Sub_SubChanges{$ProblemType});
121970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12202f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
122061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12211fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12213fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                if(getOffset($MNum-1, \%Type1_Pure, $TypeInfo{1}, getArch(1), $WORD_SIZE{1})!=getOffset($RelatedField{$MNum-1}, \%Type2_Pure, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12228d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        # TODO: Private_Field_Type rule?
12229d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
12230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1224074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1224174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12242f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubChanges{$ProblemType_Init}}))
12243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubChanges{$ProblemType_Init}{$Attr};
12245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12252f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # checking member type changes
12253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12254f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my %DupProblems = ();
12256f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12257447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    foreach my $Sub_SubProblemType (sort keys(%{$Sub_SubProblems}))
12258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12259447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        foreach my $Sub_SubLocation (sort {length($a)<=>length($b)} sort keys(%{$Sub_SubProblems->{$Sub_SubProblemType}}))
12260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12261f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12262f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12263f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                if(defined $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}}) {
12264f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    next;
12265f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                }
12266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12267f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12268f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12269f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
12270f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12271f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12272f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12273f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}} = 1;
12274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12277f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12278f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %DupProblems = ();
12279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12287082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
122941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
122951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
122961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
122971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
122981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
123011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(getOffset($MNum-1, \%Type2_Pure, $TypeInfo{2}, getArch(2), $WORD_SIZE{2})!=getOffset($RelatedField_Rev{$MNum-1}, \%Type1_Pure, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1232174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
123251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
123261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1233074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1233674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1234674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12350f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
123518a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    if($Type1_Pure{"Type"} eq "FuncPtr")
123528a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    {
123538a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        foreach my $PPos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Param"}}))
123548a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
123558a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(not defined $Type2_Pure{"Param"}{$PPos}) {
123568a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                next;
123578a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
123588a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123598a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PT1 = $Type1_Pure{"Param"}{$PPos}{"type"};
123608a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PT2 = $Type2_Pure{"Param"}{$PPos}{"type"};
123618a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123628a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PName = "p".$PPos;
123638a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123648a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $FP_SubProblems = mergeTypes($PT1, $PT2, $Level);
123658a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my %DupProblems = ();
123668a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123678a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            foreach my $FP_SubProblemType (keys(%{$FP_SubProblems}))
123688a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            {
123698a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                foreach my $FP_SubLocation (keys(%{$FP_SubProblems->{$FP_SubProblemType}}))
123708a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                {
123718a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if(not defined $AllAffected)
123728a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    {
123738a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        if(defined $DupProblems{$FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation}}) {
123748a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                            next;
123758a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        }
123768a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    }
123778a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123788a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $NewLocation = ($FP_SubLocation)?$PName."->".$FP_SubLocation:$PName;
123798a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    $SubProblems{$FP_SubProblemType}{$NewLocation} = $FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation};
123808a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123818a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if(not defined $AllAffected)
123828a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    {
123838a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        $DupProblems{$FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation}} = 1;
123848a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    }
123858a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                }
123868a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
123878a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123888a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            %DupProblems = ();
123898a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
123908a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    }
123918a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
12392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12393f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
12394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1240074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12401dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12402dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1240374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1240474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1240574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1240674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1240762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1240874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12409dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12410dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12411dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12412dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1241362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1241562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
124161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1241762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1241862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1242062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1242162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1242862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1244062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12442f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12443f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12444f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12445f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12447f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12449f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12450f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1245962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1246162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1246362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1246462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1246662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1246762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1247962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1248162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1248362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1248462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1248662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1248762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1249062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1249462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1249662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1249862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1249962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1252062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12522f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12523f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12524f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12525f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12526f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12527f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12528fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12529fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12530f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12531f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12532f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12533f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12534f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12535f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12536f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12537f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12538f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12539f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12540f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1254362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1254562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12546dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1254762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1254862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12551989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
125520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12557ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isInLineInst($$) {
1255801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1255901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1256001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
12561ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateInstance($$)
12562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12563ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
12564ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12565ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
1256662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12567ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1256862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
12569ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(index($ClassName,"<")!=-1) {
12570ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 1;
1257162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1257262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1257362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12574ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ShortName = $SInfo->{"ShortName"})
1257562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12576ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(index($ShortName,"<")!=-1
12577ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        and index($ShortName,">")!=-1) {
12578ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            return 1;
1257962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1258062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12581ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1258262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12585ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateSpec($$)
12586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12587ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
1258801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1259062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1259401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
126041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12605ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12606989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12610d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
126111fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(defined $SkipInternalSymbols)
12612d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
126131fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return 0 if($Symbol=~/($SkipInternalSymbols)/);
12614d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
12615d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1261628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($Symbol=~/\A_Z/)
1261728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    {
1261828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Symbol=~/[CD][3-4]E/) {
1261928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
1262028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1262128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1262228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1262362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1262962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12638ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"};
12639ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12644ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12645ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12646ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols
12647ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not $TargetHeadersPath or not $Header
12648ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or not is_target_header($Header, 1))
12649ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # -symbols-list | -headers-list
12650ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 0;
12651ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
12652ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12653ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12654ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12655ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols (in application)
12656ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            return 0;
12657ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12658ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12659ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12660ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
126611fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($ClassId)
126621fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
126631fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            if(not isTargetType($ClassId, $LibVersion)) {
126641fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                return 0;
126651fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            }
126661fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
126671fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
12668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1267162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12685ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Header)
12686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1268762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12694ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($TypesListPath and $ClassId)
1269552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        { # user defined types
1269652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1269752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1269852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if(not $TypesList{$CName})
1269952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
12700ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(my $NS = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"})
12701ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12702ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    $CName=~s/\A\Q$NS\E\:\://g;
12703ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
12704ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12705ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(not $TypesList{$CName})
12706ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12707ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    my $Found = 0;
12708ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12709ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    while($CName=~s/\:\:.+?\Z//)
12710ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    {
12711ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        if($TypesList{$CName})
12712ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        {
12713ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            $Found = 1;
12714ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            last;
12715ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        }
12716ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12717ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12718ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    if(not $Found) {
12719ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        return 0;
12720ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12721ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
1272252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1272352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
12724ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12725850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12726850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12728850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
127291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12731ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
12732ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
127331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12734ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
12735ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline virtual methods
12736ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if($Type=~/InlineVirt/) {
12737ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        return 1;
12738ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    }
12739ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
12740ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable)
12741ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    { # check bases
12742ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
12743ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        {
12744ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            if(not isCopyingClass($DCId, $LibVersion))
12745ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            { # exists a derived class without default c-tor
12746ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                $Allocable=1;
12747ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                last;
127481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12751ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable) {
127521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
127531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12755ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                else
12756ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline non-virtual methods
12757ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    return 0;
12758ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                }
12759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1277762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1279562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
128051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12808ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"});
12809c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
128101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
128121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12815ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"});
128169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12820dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12821dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12822dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
128230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12824dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12825dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
128278a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
128288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if($SkipSymbols{1}{$Symbol})
128298a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            { # user defined symbols to ignore
128308a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                next;
128318a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
12832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12834c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1284462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
128451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1284662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1284762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1284862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1284962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1285062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
128511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
128521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
128531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
128581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
128591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
128601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
128611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12862b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12863b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12864b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12865b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12866b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
128671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
128691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
128701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
128711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1287262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
128761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
128771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
128781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
128791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1288062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
128811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
128821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
128831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
128841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
128851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12886850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12887850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12888850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12889850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12890850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12891850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12892850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12893850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
128941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
128951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
128961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
128971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
128980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
128991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
129051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
129151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
129161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
129171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
129181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
129191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
129211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
129221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
129231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1292462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
129271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
129281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12929850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
129301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
129311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1293262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12933850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
129341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
129351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
129361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
129381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12939850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12940850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12941850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12942850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12943850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12944850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
129461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
129481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
129491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
129501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
129511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12957b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12958b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12959b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12960b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12961b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12962b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12963b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
129649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
129659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
129669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
129679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
129689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
129699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
129709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
129719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
129729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
129739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
129749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
129759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
129769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
129779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
129789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
129791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
129801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
129811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
129821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
129831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
12989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
129911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
129949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
129959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
12996850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12997850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12998850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
12999850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
13000850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
13001850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
13002850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
13003850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
13004850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
130091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
130101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
13013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
130141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
13015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
13016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
130179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
130189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
13019850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
13020850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
13021850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
13022850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
13023850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
13024850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
13025850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
13026850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
13027850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
130320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
130340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
130350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1303662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
13037f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{"this"}}=(
1303862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1303974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
130400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
130420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
130430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
130440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
13048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
13052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
13054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
13055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
13056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
13057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
13059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
13060850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
13061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
13062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
13063850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
13064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
13065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
13066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
13068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
13080989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
13081989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
13082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
13083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
13085989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
13086989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
13087989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13088989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13089989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
13090989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
13091989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13092989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13093989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
13094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
13095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
13100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
131011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
131021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
13103570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
131041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
131051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
13106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
13107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
13108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
13110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
13113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
13115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
13116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
13117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1311862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
13119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
13121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
131231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
131241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
131251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
131261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
131271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
131281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
131291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
131301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
13131dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
131321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
13133dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
131341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
13135dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
13136dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
131371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
131381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
131391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
131401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
131411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
131421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
131431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
131441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
131451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
131461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
131471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
131481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
13149dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
13150dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
13151dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
13152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
13153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
13154dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
13155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
13156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
13157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
13158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
13159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
13160dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
13161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
13162dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
13163dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
13164dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
13165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
13166dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
13167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
13168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
13169dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
131701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
131711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
131721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
131731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
131741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
131751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
131760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
131770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
131780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
131790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
131800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
131820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
131840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
131860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
131880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
131890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
131908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
13191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
131921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
13193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
13194f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
131951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
131961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
13197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
131981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
132001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
13201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
132040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
132050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
132060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
132091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
132131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
132161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1321762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1321862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
132190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
132210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
132230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
132240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
132250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
132270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
132290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1323074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
132310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
132361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
132371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
132381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
132420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
132430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
132440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
132471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
132481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
132511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
132541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
132551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1325662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1325762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
132590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
132600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
132620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
132630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
132640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
132660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
132680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1326974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
132700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
132756fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        and $OStarget eq "windows")
13276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1327762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1327962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1328162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1328362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
132841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
132851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
132861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1328862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
132911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13292fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
132931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1329562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1329862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1330062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
133011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
133021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
133031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1330562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
133081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13309fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
133101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1331262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1331562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1331662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1331762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1331862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1331962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
133221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
133261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1332762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1332862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
133291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1333062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
133371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
133391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1334162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
133421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
133431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13344f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(C[1-2][EI])/)
13345989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
13347f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(C[1-2][EI])/$CtorType/g;
13348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
133501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
133511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13352f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(D[0-2][EI])/)
13353989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
13355f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(D[0-2][EI])/$DtorType/g;
13356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13358dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1335962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13360dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
133621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1336362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13365fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1336662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
133671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1336862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1337062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1337362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
133750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
133761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1337762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1337962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1338262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
133861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1338762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1338962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1339262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
133940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
133951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1339662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1339862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1340062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
134021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
134031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1340462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1340662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
134121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
134131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
13414f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $CurrentSymbol = $Symbol;
13415f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
134161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
134171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
134181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
134191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
134201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
134221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
134231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
134241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
134251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
134261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
134271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
134281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
134291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
134311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
134321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
134331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
134341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
134401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
134411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
134421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
134431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
134441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
134501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
134511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
134521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
134531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
134551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
134561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
134601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
134669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
134689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
134719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
134739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
134779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
134819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1348562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
134860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
134880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
134890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
134900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
134910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
134920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
134930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
134940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
134950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
134960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
134970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
134980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
134990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
135000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
135010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
135020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
135030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
135040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
135050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
135060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
135070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
135080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13509850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
135100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
135110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
135130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
135160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
135170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
135190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
135220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
135230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
135250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
135291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
135301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
135341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1353562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1353962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
135401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
135419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
135471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
135489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
135501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
135511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
135559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13557fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
135581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
135621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
135641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13566dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13567dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13568dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
135691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1357062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13571dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13572dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
135731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1357462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
135751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
135761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
135771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
135781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
135791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
135811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
135829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
135831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
135849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
135859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
135869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
135879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
135881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
135891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
135901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1359174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
135921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
135931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
136001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13604ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
136051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
136061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
136081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13610ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
136151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13617dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1361862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1361962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1362062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1362162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1362362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1362562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1362662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1363262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
136361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1363962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
136420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1364362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13644f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1364562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
136461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13650f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1365162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13652f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1365362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1365462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1365662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
136580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1365962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13660f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1366162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1366262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1366362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
136641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1367062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
136730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1367462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13675f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1367662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
136771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13684dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
136851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
136871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13689dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
136901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1369162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1369262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13693ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13699dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1370062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1370162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13702ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13703ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13705ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1370762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1370862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13714ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
137181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13721ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
137240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13725ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13726f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1372762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
137281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
137301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13732f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1373362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13734f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1373562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13736ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13738ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
137400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13741ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13742f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1374362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13744ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13745ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
137461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13752ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
137550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13756ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13757f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1375862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
137591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
137661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
137671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
13768f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %RC_SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13770f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubProblemType (keys(%RC_SubProblems))
13771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13772f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $New_Value = $RC_SubProblems{$SubProblemType}{"New_Value"};
13773f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Old_Value = $RC_SubProblems{$SubProblemType}{"Old_Value"};
13774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13775f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13779fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13781fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13784fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13793fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13794fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13798fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13799fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13800fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13801fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13804fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13805fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13806fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13817fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13818fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13819fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13820fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13822fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13823fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13824fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13825fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13826fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13827fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
138349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13839fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13840fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13841fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13842fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13843fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13844fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13848f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13849f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13850f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13851f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13852f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13853f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13854f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13855f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13856f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13857f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13859f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13860f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13861f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13862f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13863f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13864f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13865f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13866f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13867f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13868f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13869f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13870f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13871f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13872f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13873f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13875f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13876f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13878f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13879f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13880f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13881f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13882f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13883f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13884f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13885f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13887f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13888f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13890f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13891f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13892f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13893f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13894f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13895f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13896f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13897f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13898f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13899f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13900f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13902f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13903f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13905f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13906f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13907f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13908f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13909f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13910f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13911f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13912f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13913f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13915f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13916f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13918f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13919f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13921f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13922f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13923f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13924f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13925f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13926f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13927fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13928fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13929fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13930fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13931fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13932fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13933fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13934fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13935f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"} = $RC_SubProblems{$SubProblemType};
139369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
13941f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Sub_SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13942f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13943f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $AddProblems = {};
13944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13950fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
1395133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        if(defined $Sub_SubProblems->{"DataType_Size"})
13952fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13953d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1395433ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            foreach my $Loc (keys(%{$Sub_SubProblems->{"DataType_Size"}}))
1395533ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            {
1395633ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                if(index($Loc,"->")==-1)
13957d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                {
13958d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    if($Loc eq $Sub_SubProblems->{"DataType_Size"}{$Loc}{"Type_Name"})
13959d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    {
13960d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        $AddProblems->{"Global_Data_Size"}{$Loc} = $Sub_SubProblems->{"DataType_Size"}{$Loc}; # add a new problem
13961d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        last;
13962d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    }
1396333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                }
13964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13967f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if(not defined $AddProblems->{"Global_Data_Size"})
13968fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13970fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13972fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
13973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
13974fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
13975fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
13976f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"}{"retval"} = {
13977fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
13978f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE };
13979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13984f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$AddProblems}))
13986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13987f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$AddProblems->{$SubProblemType}}))
13988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1398933ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1399033ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1399133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1399233ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13993f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $AddProblems->{$SubProblemType}{$SubLocation};
13994f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
13995f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
13996f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13997f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13998f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
13999f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14000f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                {
1400133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1400233ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1400333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1400433ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
14005f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1401162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1401262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1401362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
140141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
14015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1401662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1401762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
14018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
14019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
14021f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Sub_SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
14022f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14024f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
14026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
14027f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
140331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
140341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
140351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
14036850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
14037850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
14038850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
14039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
140420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
140480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
140490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
140500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1405162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
140529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
140530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
140550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
140580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
140600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
140610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
140620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
140630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
140660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
140690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
14072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
140731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
140750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
140780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
140800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
140810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
140829e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
140830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
140840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
14085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1408762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
140880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
140890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
140900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1409162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
140920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
140930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
140940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
140960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
140970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
140980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
140990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
141000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
141010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
141020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
141030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
141040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
141050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
14106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
141110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
141120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
141140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
141150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
141160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
141199e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    while($Value=~/(\w+)/)
141209e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    {
141219e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        my $W = $1;
141229e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
141239e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        if($W eq $Qual) {
141249e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Value=~s/\b$W\b/\@/g;
141259e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        }
141269e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        else {
141279e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Value=~s/\b$W\b//g;
141289e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        }
141290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141309e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
141319e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    $Value=~s/\@/$Qual/g;
141320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
141330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
141350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
141360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
141370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
141380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
141390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
141400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
141410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
141430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
141440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
141450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
141460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
141480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
141490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
141530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
141564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
141574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
141584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
141614b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
141624b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
141634b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
141660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
14168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
14169a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1417001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1417101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1417201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1417301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1417401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1417501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
141764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
141770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
141780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
141790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141804b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
141810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
141820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
141830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141844b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
141854b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
141864b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
141874b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
141880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
141890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
14192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
14193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
14194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
14196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
14198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
14199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14200ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
14201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
14202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
14206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
142071fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    elsif(defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}
142081fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}
142091fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}{"offset"})
142101fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
142111fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return "unknown";
142121fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
14213fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
14215fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
14216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14217ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
14218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14219ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
142200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
142210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
142220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14223dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
14224dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
14225dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
14226dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
142270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
142280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
142290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
142300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14231ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
14233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14234177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14235177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14236177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14237ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14238ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1423962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1424062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1424152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1424252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %PureType1 = get_PureType($PType1_Id, $TypeInfo{1});
1424352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1424462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1424562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
1424652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
142470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14248ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
142491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
142501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1425162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
142521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
142531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14257dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14258f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
142601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14264dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14265f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14268fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14270fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14271fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
142761fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
142771fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if($Old_Regs ne "unknown"
142781fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and $New_Regs ne "unknown")
14279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
142801fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    if($Old_Regs and $New_Regs)
142811fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
142821fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        if($Old_Regs ne $New_Regs)
142831fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        {
142841fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
142851fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Target"=>$PName1,
142861fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
142871fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Old_Value"=>$Old_Regs,
142881fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "New_Value"=>$New_Regs  );
142891fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        }
142901fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
142911fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif($Old_Regs and not $New_Regs)
14292fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
142931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
142941fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Target"=>$PName1,
142951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
142961fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Old_Value"=>$Old_Regs  );
142971fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
142981fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif(not $Old_Regs and $New_Regs)
142991fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
143001fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14302f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
143061fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
14307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14308fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14309fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14310fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14311fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14312f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start1 = $CompleteSignature{1}{$Symbol}{"Param"}{0}{"offset"};
14313f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start2 = $CompleteSignature{2}{$Symbol}{"Param"}{0}{"offset"};
14314f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14315f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $Old_Offset = $Old_Offset - $Start1;
14316f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $New_Offset = $New_Offset - $Start2;
14317f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14318f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if($Old_Offset ne $New_Offset)
14319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
14320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14321f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Target"=>$PName1,
14322f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14323f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Old_Value"=>$Old_Offset,
14324f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "New_Value"=>$New_Offset  );
14325f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
14326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14327fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14328fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14329fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14331177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14332177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14334177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
143350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
143360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1433762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1433862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
143390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
143400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
143410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
1434252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Name"} eq "bool"
143430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
143440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
143450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
143460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
143470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
143480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1435101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1435201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1435301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1435401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1435501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1435601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1435701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1435801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
143590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
143610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
143620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
143650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
143660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
143671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14368dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14369f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
143710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
143770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
14378f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
143830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
143840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
143850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
143860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
14387f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
143890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14391ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14392ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14393ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14394ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14395ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14396ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14397ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14398ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14399ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14400f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14401ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14402ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14403ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14404ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14405ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14407ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14409dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14410f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14415fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14416fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14417fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1442162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
144240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
144251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14478f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14479f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
144981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14499f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14502f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14503f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14505f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14509fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14510f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14511f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14512f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14513f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14514f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14515f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14516f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14517f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14518f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14519f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14521f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14522f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14523f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14524f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14525f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14527f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14528f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14529f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14530f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14531f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
145341fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            elsif($Conv1{"Method"} ne "unknown"
145351fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            and $Conv2{"Method"} ne "unknown")
14536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14537f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14538f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14540f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14541f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14544f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14545f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
145471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14548dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14549f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
145501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
145511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14553f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14555f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
14557f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Sub_SubProblems = mergeTypes($PType1_Id, $PType2_Id, $Level);
14558f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14560f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1456552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Type"}!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
14571f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
145791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
145811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
145941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
145981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1460062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14609e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14610e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
146138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
146148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
146158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
146168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
146178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
146188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
146198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
146208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
146218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
146228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
146248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
146258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
146268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
146288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
146298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
146321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
146338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14634f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14635f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
146368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
146429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
146439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
146449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14645f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko    if($Type2_Pure{"Name"} eq "void")
14646f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko    { # from something to void*
14647f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko        return 0;
14648f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko    }
14649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14689fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14696fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
147021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
147031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
147041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
147051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
147061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
147071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
147081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14711fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14717570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14718570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14724fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
147388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
147391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
147401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
147411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
147421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
147431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
147441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
147451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
147468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
147488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
147498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
147518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
147528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
147538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
147548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
147558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
147578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
147588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
147628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
147638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
147648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
147668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
147678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
147738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
147748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
147768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
147811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
147831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14784dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14785dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14786dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1478862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1478962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14790f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14791f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
1479286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
147938580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko    if(defined $SkipTypedefUncover)
147948580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko    {
147958580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}) {
147968580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko            return ();
147978580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        }
147988580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko
147998580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        if(cmpBTypes($Type1_Pure{"Name"}, $Type2_Pure{"Name"}, 1, 2)) {
148008580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko            return ();
148018580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        }
148028580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko    }
148038580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko
14804f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14805f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1480674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1480786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"})
1480886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    {
1480986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        if($Type1_Pure{"Name"} eq "__unknown__"
1481086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Pure{"Name"} eq "__unknown__"
1481186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type1_Base{"Name"} eq "__unknown__"
1481286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Base{"Name"} eq "__unknown__")
1481386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        { # Error ABI dump
1481486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            return ();
1481586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        }
1481686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    }
1481786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
1481862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1481962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
148279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
148289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
148299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
148309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
148319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
148329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
148339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
148349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
148359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
148369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
148379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
148389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
148399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
148409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
148419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
148429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
148461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
148478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
148488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14854f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14863f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14864f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14871f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14872f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14881f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14886f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14893f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE);
14894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14898dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14899dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14905f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
149098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14914f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14915f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14922f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14923f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
149341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
149351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
149361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
149401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
149411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
149451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
149511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14957ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array"
14958ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    and $Type1_Pure{"BaseType"})
14959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
149611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
149770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
149780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
149790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
149800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
149810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
149830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1498474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1498574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
149860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
149870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
149880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1498974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
149900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
149910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
149958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
149968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149972b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
149982b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
149992b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
15001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
1500262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
150030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
15004f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
15005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1500662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
150070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
15008f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
15009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
15011850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
15012850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
15013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
15014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
15015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
150160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1501762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1501862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
150190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
150200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1502174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
150220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
150230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
150240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
150250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1502662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1502762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
150280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1502962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1503074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1503174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1503274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1503374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1503474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1503574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1503674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
15037d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        { # added type prefix in 2.20
1503874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1503974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
15040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
15041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
150458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
150468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
150478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
150488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
150498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
150518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
150558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
150578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150602b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150612b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        if($TT1 eq "FuncPtr"
150622b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        and $TT2 eq "FuncPtr")
150632b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        {
150642b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN1_C = $TN1;
150652b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN2_C = $TN2;
150662b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150672b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN1_C=~s/\b(struct|union) //g;
150682b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN2_C=~s/\b(struct|union) //g;
150692b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150702b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if($TN1_C eq $TN2_C) {
150712b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                return 0;
150722b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
150732b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
150748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
15075d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15076d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my ($N1, $N2) = ($TN1, $TN2);
15077d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N1=~s/\b(struct|union) //g;
15078d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N2=~s/\b(struct|union) //g;
15079d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15080d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($N1 eq $N2)
15081d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    { # QList<struct QUrl> and QList<QUrl>
15082d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        return 0;
15083d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
15084d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
15086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
15089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
150901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
15091989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
15092989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
15093989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
15094dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
150951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
15096dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
15097dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15098dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
15099dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
15100989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15101dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
151021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15103dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
15104dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15105dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
15106dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
15107dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
15108989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15109dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
151101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15112989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
15113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
15116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
15117dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
15118dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
15119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
15120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
15123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
151255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
151265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
15127dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
15128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
15129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
15130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
15131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
151328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
151338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
15134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
151358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
15138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
151425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
151435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
151445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
151455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
151465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
151475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
151485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
151505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
151515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
151525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
151545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
151555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
151575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
151585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1515901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1516001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1516101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1516201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1516301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1516401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1516501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1516601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1516701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1516801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1516901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1517001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1517101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1517201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1517301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1517401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1517501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
15176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
15177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
15179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
15180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
15183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
15189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
15195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
15197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
15198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
15199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
15200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
15202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
15205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
15207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
15208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
15210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
15213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15214dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
15215dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
15216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
15217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
15218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
15219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
15220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
152211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
15222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
152231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
15224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
152258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
152261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
152281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
15231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
15233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
15235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1523607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1523707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
15238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
15239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
15241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
15242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
15243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
15244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
15245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
15247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
15248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
152508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
15251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
15252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
15253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
15255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
15256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152579e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            my $Style = "<i>$ParamName</i>";
152589e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
15259dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
15260dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
152619e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                $Style = "<span class=\'fp\'>$ParamName</span>";
15262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
152649e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                $Style = "<span class=\'color_p\'>$ParamName</span>";
15265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152669e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
152679e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Part_Styled=~s!(\W)$ParamName([\,\)]|\Z)!$1$Style$2!ig;
15268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
152871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
152901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
152921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
152931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
152948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
152958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
152968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
152978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
152988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1530107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1530307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1530407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1530507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1530607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1530707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1530807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1530907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1531007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1531107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1531207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1531307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1531607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1531807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
153201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
153211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
153241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
153251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1532607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
153271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
153281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
153291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
153311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
153321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
153331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
153351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
153381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1534107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1534207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1534307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1534407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1534507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1534607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1534707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1534807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
153521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
153551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
153571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
153581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
154071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15411850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15419850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15420850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15421850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
154221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15423850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15425850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15430850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15431850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15432850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
154331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15434850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15436850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
154541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
154650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15468850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15469850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15470850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15471850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1549381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    return path_format($Path, $OSgroup);
15494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15498f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15499f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15502f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15505f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15511f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15515f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1555054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1555154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if($TargetArch) {
1555254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        return $TargetArch;
1555354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
15554d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    elsif($CPU_ARCH{$LibVersion})
155551fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    { # dump
15556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1556254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
15563d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return getArch_GCC($LibVersion);
15564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1556652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkosub get_Report_Title($)
15567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
155681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
1556952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
155711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
155721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
155731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1557752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Title = "";
155781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
1557952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Source compatibility";
155801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
1558252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Binary compatibility";
155831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
1558552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "API compatibility";
155861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1558752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1558815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V1 = $Descriptor{1}{"Version"};
1558915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V2 = $Descriptor{2}{"Version"};
1559015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1559152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($UsedDump{1}{"DWARF"} and $UsedDump{2}{"DWARF"})
1559252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1559352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M1 = $UsedDump{1}{"M"};
1559452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M2 = $UsedDump{2}{"M"};
1559552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1559615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M1S = $M1;
1559715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M2S = $M2;
1559815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1559915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M1S=~s/(\.so|\.ko)\..+/$1/ig;
1560015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M2S=~s/(\.so|\.ko)\..+/$1/ig;
1560115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1560215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($M1S eq $M2S
1560315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        and $V1 ne "X" and $V2 ne "Y")
1560452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1560515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report for the <span style='color:Blue;'>$M1S</span> $TargetComponent";
1560615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1560752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1560852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        else
1560952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1561015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report between <span style='color:Blue;'>$M1</span> (<span style='color:Red;'>".$V1."</span>)";
1561115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " and <span style='color:Blue;'>$M2</span> (<span style='color:Red;'>".$V2."</span>) objects";
1561252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1561352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1561452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    else
1561552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1561614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $Title .= " report for the <span style='color:Blue;'>$TargetTitle</span> $TargetComponent";
1561715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1561852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1561952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1562052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title .= $ArchInfo;
1562152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
1562301e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko        $Title .= " (relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)";
15624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1562552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title = "<h1>".$Title."</h1>\n";
1562652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    return $Title;
15627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15629ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkosub get_CheckedHeaders($)
15630ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko{
15631ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my $LibVersion = $_[0];
15632ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15633ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my @Headers = ();
15634ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15635ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
15636ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
15637ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $File = get_filename($Path);
156381fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
15639ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not is_target_header($File, $LibVersion)) {
15640ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15641ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15642ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15643ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(skipHeader($File, $LibVersion)) {
15644ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15645ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15646ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15647ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        push(@Headers, $Path);
15648ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
15649ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15650ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    return @Headers;
15651ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko}
15652ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
15656ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15657ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Headers = get_CheckedHeaders(1))
15658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156590f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedHeaders = "<a name='Headers'></a>";
156600f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        if($OldStyle) {
156610f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedHeaders .= "<h2>Header Files (".($#Headers+1).")</h2>";
156620f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
156630f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        else {
156640f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedHeaders .= "<h2>Header Files <span class='gray'>&nbsp;".($#Headers+1)."&nbsp;</span></h2>";
156650f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
156660f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedHeaders .= "<hr/>\n<div class='h_list'>\n";
15667ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
1566862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15669ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15670ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15671ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15672ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedHeaders .= $Name.$Comment."<br/>\n";
15673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15674ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "</div>\n";
15675ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15676ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15677ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15678ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Sources = keys(%{$Registered_Sources{1}}))
15679ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
156800f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedSources = "<a name='Sources'></a>";
156810f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        if($OldStyle) {
156820f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedSources .= "<h2>Source Files (".($#Sources+1).")</h2>";
156830f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
156840f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        else {
156850f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedSources .= "<h2>Source Files <span class='gray'>&nbsp;".($#Sources+1)."&nbsp;</span></h2>";
156860f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
156870f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedSources .= "<hr/>\n<div class='h_list'>\n";
15688ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15689fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15690ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15691ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15692ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15693ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedSources .= $Name.$Comment."<br/>\n";
1569462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15695ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "</div>\n";
15696ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<br/>$TOP_REF<br/>\n";
15697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15698ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1569962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157010f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a>";
157020f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        if($OldStyle) {
157030f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedLibs .= "<h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2>";
157040f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
157050f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        else {
157060f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CheckedLibs .= "<h2>".get_ObjTitle()." <span class='gray'>&nbsp;".keys(%{$Library_Symbol{1}})."&nbsp;</span></h2>";
157070f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        }
157080f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $CheckedLibs .= "<hr/>\n<div class='lib_list'>\n";
157090f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}})) {
1571062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15715ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15718fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15720fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15721fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15722fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15723fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15724fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15725fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15726fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15729447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenkosub get_TypeProblems_Count($$)
15730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15731447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
15732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15733447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
15734447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges{$Level}}))
15735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15737447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges{$Level}{$Type_Name}}))
15738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15739447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges{$Level}{$Type_Name}{$Kind}}))
15740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15741447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                my $Target = $TypeChanges{$Level}{$Type_Name}{$Kind}{$Location}{"Target"};
157422489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15743447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
15744447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                if($Severity ne $TargetSeverity) {
15745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
157472489ef88760861175102e4508089608391beead3Andrey Ponomarenko
15748447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15749447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    next;
15750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15751447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
15752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
157621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
157631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
157648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $C_Problems_Low, $T_Problems_Medium, $T_Problems_Low, $I_Other, $T_Other, $C_Other) = (0,0,0,0,0,0,0,0,0,0,0,0);
157651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
157661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
157671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
157681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
157701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
157811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
157858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
157868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
157878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
157888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
157898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
157908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
157918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
157928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
157938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
157948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
157958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
157968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
157978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
157988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
157998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
158001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
158021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
158061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
158082489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
158091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
158121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
158152489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Severity;
15816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
158192489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity eq "Safe") {
15820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
158222489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "High") {
15823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
158252489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Medium") {
15826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
158282489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Low") {
15829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
158312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if(($Severity ne "Low" or $StrictCompat)
158322489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        and $Severity ne "Safe") {
158332489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15840447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
15841447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    my %MethodTypeIndex = ();
15842447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
158431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15845447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my @Kinds = sort keys(%{$CompatProblems{$Level}{$Interface}});
15846447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $Kind (@Kinds)
15847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15850447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                my @Locs = sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}});
15851447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                foreach my $Location (@Locs)
15852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
158531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
158541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
15855f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15856447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    if(defined $MethodTypeIndex{$Interface}{$Type_Name}{$Kind}{$Target})
15857447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    { # one location for one type and target
15858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15860447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $MethodTypeIndex{$Interface}{$Type_Name}{$Kind}{$Target} = 1;
15861447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $TypeChanges{$Level}{$Type_Name}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
15862447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
15863447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15864f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
158652489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(($Severity ne "Low" or $StrictCompat)
158662489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    and $Severity ne "Safe")
15867f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
15868447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        if(my $Sev = $TotalAffected{$Level}{$Interface})
15869f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
15870447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            if($Severity_Val{$Severity}>$Severity_Val{$Sev}) {
158712489ef88760861175102e4508089608391beead3Andrey Ponomarenko                                $TotalAffected{$Level}{$Interface} = $Severity;
15872f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            }
15873f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15874f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        else {
158752489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15876f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15877f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
158821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15883447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count("High", $Level);
15884447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count("Medium", $Level);
15885447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count("Low", $Level);
15886447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    $T_Other = get_TypeProblems_Count("Safe", $Level);
15887f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15888ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # changed and removed public symbols
15889ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $SCount = keys(%{$CheckedSymbols{$Level}});
15890ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($ExtendedCheck)
15891ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # don't count external_func_0 for constants
15892ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $SCount-=1;
15893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15894ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($SCount)
15895ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15896ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my %Weight = (
15897ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "High" => 100,
15898ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Medium" => 50,
15899ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Low" => 25
15900ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        );
15901ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach (keys(%{$TotalAffected{$Level}})) {
15902ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15904ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15905ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15906ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
15907ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 0;
15908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15909ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
159101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
159111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
159121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15916850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
159171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15918850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15922850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15923850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
159261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
159278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15928850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15929f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
159308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
159318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
159328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15933850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
159348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
159358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
159368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15937850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
159381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
159408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
159418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
159428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
159438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
159448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
159458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
159468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
159478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
159481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15950850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15951850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15952850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15953850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15954850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15955850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
159561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
159571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
159581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
159591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
159601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15975d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch1</arch>\n";
15976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15981d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch2</arch>\n";
15982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15989fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15991fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15992fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
16000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
16002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
16003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
16004fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
16005fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
16006fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
16007fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
16008fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
16009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
16012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
16013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
160148a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            # $Library .= " (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
16015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
16016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
16018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1601962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
16020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
16021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
160231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
16024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
16025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
16027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
16028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
16029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
16031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
16032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
16033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
16034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
16035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
16036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
16038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
16039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
16040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
160411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
16042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
16043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
160451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
16046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
1604752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
16048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
16049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
16051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
16055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
160561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
1605715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1605815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($TargetComponent eq "library") {
1605915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Library Name</th><td>$TargetTitle</td></tr>\n";
1606015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
1606115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        else {
1606215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Module Name</th><td>$TargetTitle</td></tr>\n";
1606315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
16064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
16066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
16067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
16068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
16069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
16070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
160711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
16072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
16075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
16076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
16077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
160798580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        if($Level eq "Binary"
160808580e858c582b97ac65413cea1c6067385020720Andrey Ponomarenko        and $GccV1 ne "unknown"
16081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
16082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
16083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
16084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
16085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
16086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
16087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
16090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
16091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
16092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
16095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
16096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
16097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
16098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
16099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
16100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
16101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
16102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
16103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
161041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
161051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
161071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
161081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
161101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
161111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
16114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
16116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
161171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
16118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161196ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        if(my @Headers = get_CheckedHeaders(1))
16120fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16121fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
16122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
16123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
16125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
16126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
16128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
16129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
16132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
16134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
16135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
16136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1613862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
16139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
161411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
161421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
161431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16144447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
16145ce36037cd5eadbc0cee77abd9215a89d4257e4e4Andrey Ponomarenko        my $BC_Rate = show_number(100 - $RESULT{$Level}{"Affected"});
16146447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
16147447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $TestResults .= "<tr><th>Compatibility</th>\n";
16148447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible")
16149447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        {
16150447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Cl = "incompatible";
16151447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if($BC_Rate>=90) {
16152447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $Cl = "warning";
16153447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
16154447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            elsif($BC_Rate>=80) {
16155447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $Cl = "almost_compatible";
16156447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
16157447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
16158447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $TestResults .= "<td class=\'$Cl\'>".$BC_Rate."%</td>\n";
161591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
161601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
16161447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $TestResults .= "<td class=\'compatible\'>100%</td>\n";
161621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
161631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
16164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
16165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
16167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
16168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
161691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
16170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
16171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
161731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
161741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
161761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
161771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
161791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
161801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
16183447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "Added", $Added).">$Added_Link</td></tr>\n";
16184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
161861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
161871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
161891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
161901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
161921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
161931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
161961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
16197447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "Removed", $Removed).">$Removed_Link</td></tr>\n";
16198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
162001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
16201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
162021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
16203447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "High", $T_Problems_High).">$TH_Link</td></tr>\n";
16204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
162061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
16207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
16208447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "Medium", $T_Problems_Medium).">$TM_Link</td></tr>\n";
16209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
162111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
16212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
16213447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "Low", $T_Problems_Low).">$TL_Link</td></tr>\n";
16214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
162161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
16217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
162181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
16219447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "High", $I_Problems_High).">$IH_Link</td></tr>\n";
16220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
162221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
16223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
16224447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "Medium", $I_Problems_Medium).">$IM_Link</td></tr>\n";
16225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
162271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
16228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
16229447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "Low", $I_Problems_Low).">$IL_Link</td></tr>\n";
16230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
162328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
162338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
16234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
162351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
16236447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        $Problem_Summary .= "<tr><th>Problems with<br/>Constants</th><td>Low</td><td".getStyle("C", "Low", $C_Problems_Low).">$ChangedConstants_Link</td></tr>\n";
16237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
16239ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($T_Other)
162401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
162411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
16242447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Data Types</th><td>-</td><td".getStyle("T", "Safe", $T_Other).">$TS_Link</td></tr>\n";
162431fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "type_changes_other:$T_Other;";
162441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
162451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16246ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($I_Other)
162471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
162481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
16249447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "Safe", $I_Other).">$IS_Link</td></tr>\n";
162501fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "interface_changes_other:$I_Other;";
16251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16253ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($C_Other)
162548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
162558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
16256447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "Safe", $C_Other).">$CS_Link</td></tr>\n";
162571fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "constant_changes_other:$C_Other;";
162588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
162598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
16261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
16262447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
16263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
16264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
162681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
162691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
162701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
16271447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "Added"=>"new",
16272447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "Removed"=>"failed",
16273447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "Safe"=>"passed",
16274447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "Low"=>"warning",
16275447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "Medium"=>"failed",
16276447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        "High"=>"failed"
162771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
16278447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
162791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
162801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
162811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
16282447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
162831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
162841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
162851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
16286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
16287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
16289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
162901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
162911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
162921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
162931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
162941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
162951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
162961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
162971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
162981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
162991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
16300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
16302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
16303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
16305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
163291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
163301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
163311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
163381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
163398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
163401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
163418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
163428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
163438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
163448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
163458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
163468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
163478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
163488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
163498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
163508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
163518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
163528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
163538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
16354f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($TargetSeverity ne $CompatRules{$Level}{$Kind}{"Severity"}) {
163558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
163568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
163578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
163588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
163591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
163631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
163661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
163698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
163708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
163718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
163728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
163738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16374fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
163758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
163768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
163778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
16378d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    if($Overcome) {
16379d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
16380d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    }
163818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
163828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16391447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $ProblemsNum = 0;
163921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
163958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
163978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
163988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
163998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
164008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
164018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
164028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
164039e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    $Report .= "<tr>\n<th>1</th>\n<td>".$Change."</td>\n<td>$Effect</td>\n</tr>\n";
16404447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $ProblemsNum += 1;
164058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
164068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
164078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
1640815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                    $Report = $ContentDivStart."<table class='ptable'>\n<tr>\n<th width='2%'></th>\n<th width='47%'>Change</th>\n<th>Effect</th>\n</tr>\n".$Report."</table>\n<br/>\n$ContentDivEnd\n";
164099e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    $Report = $ContentSpanStart."<span class='ext'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
164108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
164118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
164128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
164161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
164171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
164188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
164198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
164208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
164218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
164221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
164230f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            if($OldStyle) {
164240f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $CHANGED_CONSTANTS = "<h2>$Title ($ProblemsNum)</h2><hr/>\n".$CHANGED_CONSTANTS;
164250f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
164260f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            else {
164270f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $CHANGED_CONSTANTS = "<h2>$Title <span".getStyle("C", $TargetSeverity, $ProblemsNum).">&nbsp;$ProblemsNum&nbsp;</span></h2><hr/>\n".$CHANGED_CONSTANTS;
164280f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
164290f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
164351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
164361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
164371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
164381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
164398a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
164408a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    # if($Library and $Library!~/\.\w+\Z/) {
164418a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    #     $Library .= " (.$LIB_EXT)";
164428a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    # }
164438a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
164441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
164451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
164461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
164471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
164481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
164491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
164501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
164511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
164521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
164531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
164541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16455447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
164561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1645774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
164581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16459447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
164601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
164611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
164621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
164651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
164661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
164671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
164681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
164701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
164761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
164771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
164781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
164791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
164801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
164861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
164891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
164921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
165041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
165061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
165081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
165091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1651074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
165151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1652162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
165239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
165249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1652615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                                $ADDED_INTERFACES .= insertIDs($ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Interface</b>]</span>\n<br/>\n<br/>\n".$ContentDivEnd."\n");
16527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
165291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
165329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
165339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
165351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
165381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
165421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
165471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
165491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
165501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
165511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
165520f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            if($OldStyle) {
165530f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $ADDED_INTERFACES = "<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES;
165540f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
165550f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            else {
165560f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $ADDED_INTERFACES = "<h2>Added Symbols <span".getStyle("I", "Added", $Added_Number).">&nbsp;$Added_Number&nbsp;</span></h2><hr/>\n".$ADDED_INTERFACES;
165570f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
165580f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $ADDED_INTERFACES = $Anchor.$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
165661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
165671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
165681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16569850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16571850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
165731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16575850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16576850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
165771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
165781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
165791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
165801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16581850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
165871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
165901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16593850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16594850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
166041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
166051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
166061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
166071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
166081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
166091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
166101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1661174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
166131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
166151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
166161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1662362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
166261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1662815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                                $REMOVED_INTERFACES .= insertIDs($ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Symbol</b>]</span>\n<br/>\n<br/>\n".$ContentDivEnd."\n");
16629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
166341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
166351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
166371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
166481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
166491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
166501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
166511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
166521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
166531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
166540f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            if($OldStyle) {
166550f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $REMOVED_INTERFACES = "<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES;
166560f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
166570f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            else {
166580f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $REMOVED_INTERFACES = "<h2>Removed Symbols <span".getStyle("I", "Removed", $Removed_Number).">&nbsp;$Removed_Number&nbsp;</span></h2><hr/>\n".$REMOVED_INTERFACES;
166590f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
166600f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko
166610f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $REMOVED_INTERFACES = $Anchor.$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
166815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
166980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
167150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
167220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
167230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
167240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
167250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16740dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16741dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16742dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16743dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
1674428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1674528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(index($Content, $Macro)==-1) {
1674628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            next;
1674728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1674828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1674928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Kind!~/\A(Changed|Added|Removed)_Constant\Z/
1675028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Kind!~/_Type_/
1675128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Value=~/\s\(/ and $Value!~/['"]/)
16752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
167531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
1675428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            $Value=~s/\s[a-z]\w*(\)|,)/$1/ig; # remove parameter names
16755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
167840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16801dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
168031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
168041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
168051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
168062489ef88760861175102e4508089608391beead3Andrey Ponomarenko
168071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
168091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
168101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
168111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
168121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16813447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16814447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
16815447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16816447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        { # Symbol with Version
16817447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $DyLib = $Symbol_Library{1}{$VSym};
16818447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
16819447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not $DyLib)
16820447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        { # const global data
16821447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $DyLib = "";
16822447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
16823447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if($Level eq "Source" and $ReportFormat eq "html")
16824447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        { # do not show library name in HTML report
16825447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $DyLib = "";
16826447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
16827447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
168281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
168311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16833447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
16834447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Symbol}{$Kind}}))
16835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16836447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    if($Severity eq $TargetSeverity)
16837447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    {
16838447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $SymbolChanges{$Symbol}{$Kind} = $CompatProblems{$Level}{$Symbol}{$Kind};
16839447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
168452489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
168481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
168511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16854d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                my @SortedInterfaces = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$ReportMap{$HeaderName}{$DyLib}});
16855d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
16856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
168589e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
168630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16864f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16870d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16871d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16872d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            }
16873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
168871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
168921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1689374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
168951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
168971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
1689828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko                    my @SortedInterfaces = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} sort keys(%{$NameSpaceSymbols{$NameSpace}});
168991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
169011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
169021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
1690428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko                        foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
169061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
169081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
169090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
169111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
169169e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td>".$Change."</td>\n<td>".$Effect."</td>\n</tr>\n";
16917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
169231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
169259e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            my $ShowSymbol = $Symbol;
16926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
169279e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $ShowSymbol = highLight_Signature_Italic_Color($Signature);
16928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
169299e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
169309e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            if($NameSpace)
169319e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            {
169329e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $SYMBOL_REPORT = cut_Namespace($SYMBOL_REPORT, $NameSpace);
169339e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $ShowSymbol = cut_Namespace($ShowSymbol, $NameSpace);
16934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
169359e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
169360f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='ext'>[+]</span> ".$ShowSymbol;
169370f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            if($OldStyle) {
169380f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= " ($ProblemNum)";
169390f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            }
169400f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            else {
169410f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= " <span".getStyle("I", $TargetSeverity, $ProblemNum).">&nbsp;$ProblemNum&nbsp;</span>";
169420f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            }
169430f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanEnd."<br/>\n";
169441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
169459e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
169469e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            if(my $NSign = $NewSignature{$Symbol})
169471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
169489e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                if($NameSpace) {
169499e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                    $NSign = cut_Namespace($NSign, $NameSpace);
169509e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                }
169519e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "\n<span class='new_sign_lbl'>changed to:</span>\n<br/>\n<span class='new_sign'>".highLight_Signature_Italic_Color($NSign)."</span><br/>\n";
16952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
169539e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
169541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
169551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
169561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
169579e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
1695815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "<table class='ptable'>\n<tr>\n<th width='2%'></th>\n<th width='47%'>Change</th>\n<th>Effect</th>\n</tr>\n$SYMBOL_REPORT</table>\n<br/>\n";
169591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1696215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>\n";
16963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
169662489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
169691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
169701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
169711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
169750f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            if($OldStyle) {
169760f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $INTERFACE_PROBLEMS = "<h2>$Title ($ProblemsNum)</h2><hr/>\n".$INTERFACE_PROBLEMS;
169770f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
169780f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            else {
169790f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $INTERFACE_PROBLEMS = "<h2>$Title <span".getStyle("I", $TargetSeverity, $ProblemsNum).">&nbsp;$ProblemsNum&nbsp;</span></h2><hr/>\n".$INTERFACE_PROBLEMS;
169800f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
169810f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $INTERFACE_PROBLEMS = "<a name=\'".get_Anchor("Symbol", $Level, $TargetSeverity)."\'></a><a name=\'".get_Anchor("Interface", $Level, $TargetSeverity)."\'></a>\n".$INTERFACE_PROBLEMS.$TOP_REF."<br/>\n";
16982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
169879e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkosub cut_Namespace($$)
169889e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko{
169899e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    my ($N, $Ns) = @_;
169909e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    $N=~s/\b\Q$Ns\E:://g;
169919e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    return $N;
169929e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko}
169939e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
16994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
169961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
169971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
169982489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16999447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    my %ReportMap = ();
17000447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    my %TypeChanges_Sev = ();
170012489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17002447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    foreach my $TypeName (keys(%{$TypeChanges{$Level}}))
17003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17004447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
17005447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17006447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges{$Level}{$TypeName}}))
17007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17008447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges{$Level}{$TypeName}{$Kind}}))
17009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17010447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                my $Target = $TypeChanges{$Level}{$TypeName}{$Kind}{$Location}{"Target"};
17011f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
17012447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17013447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                if($Severity eq $TargetSeverity)
17014447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                {
17015447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $ReportMap{$HeaderName}{$TypeName} = 1;
17016447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $TypeChanges_Sev{$TypeName}{$Kind}{$Location} = $TypeChanges{$Level}{$TypeName}{$Kind}{$Location};
17017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
170212489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
170241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
17025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
170271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
17028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17029447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                my (%Kinds_Locations, %Kinds_Target) = ();
170305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
17031447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges_Sev{$TypeName}}))
17032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17033447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges_Sev{$TypeName}{$Kind}}))
17034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17035447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $Kinds_Locations{$Kind}{$Location} = 1;
17036447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17037447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        my $Target = $TypeChanges_Sev{$TypeName}{$Kind}{$Location}{"Target"};
17038447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        if($Kinds_Target{$Kind}{$Target}) {
17039447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            next;
17040447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        }
17041447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $Kinds_Target{$Kind}{$Target} = 1;
17042447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17043447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        my %Problem = %{$TypeChanges_Sev{$TypeName}{$Kind}{$Location}};
17044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
17045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
17046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
17047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
17048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
17049d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
17050d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
17051d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        }
17052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
17053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17055f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, \%Kinds_Locations);
17056f9f25c9b4ce17c950902c7e09935eccbca6309c5Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%Kinds_Locations)) {
17057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
17058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
17060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
17062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
17064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
17067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
170681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
17069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
170711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1707274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
17073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
17075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
170761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1707774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
17078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
17079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
17081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
17082447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    my (%Kinds_Locations, %Kinds_Target) = ();
170832489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17084447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges_Sev{$TypeName}}))
17085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17086447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges_Sev{$TypeName}{$Kind}}))
17087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
17088447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            $Kinds_Locations{$Kind}{$Location} = 1;
17089447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17090447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            my $Target = $TypeChanges_Sev{$TypeName}{$Kind}{$Location}{"Target"};
17091447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            if($Kinds_Target{$Kind}{$Target}) {
17092447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                                next;
17093447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            }
17094447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            $Kinds_Target{$Kind}{$Target} = 1;
17095447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17096447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            my %Problem = %{$TypeChanges_Sev{$TypeName}{$Kind}{$Location}};
17097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
17098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
17099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
171009e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $TYPE_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td>".$Change."</td>\n<td>$Effect</td>\n</tr>\n";
17101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
17102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
17103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
17104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
17107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
17108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17109447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, \%Kinds_Locations);
17110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
17111447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%Kinds_Locations)) {
17112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
17113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1711474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
171159e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        my $ShowType = show_Type($TypeName, 1, 1);
171169e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
171179e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        if($NameSpace)
171189e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        {
171199e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $TYPE_REPORT = cut_Namespace($TYPE_REPORT, $NameSpace);
171209e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $ShowType = cut_Namespace($ShowType, $NameSpace);
171219e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $Affected = cut_Namespace($Affected, $NameSpace);
171229e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $ShowVTables = cut_Namespace($ShowVTables, $NameSpace);
171239e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        }
171249e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
171250f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='ext'>[+]</span> ".$ShowType;
171260f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        if($OldStyle) {
171270f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            $TYPE_PROBLEMS .= " ($ProblemNum)";
171280f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        }
171290f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        else {
171300f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                            $TYPE_PROBLEMS .= " <span".getStyle("T", $TargetSeverity, $ProblemNum).">&nbsp;$ProblemNum&nbsp;</span>";
171310f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        }
171320f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanEnd;
171331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
171341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
171351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
171361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
17137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1713915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>\n";
17140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
171422489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
17144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
171451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
171461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
171471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
17148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
17149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
17150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
171510f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            if($OldStyle) {
171520f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $TYPE_PROBLEMS = "<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS;
171530f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
171540f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            else {
171550f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko                $TYPE_PROBLEMS = "<h2>$Title <span".getStyle("T", $TargetSeverity, $ProblemsNum).">&nbsp;$ProblemsNum&nbsp;</span></h2><hr/>\n".$TYPE_PROBLEMS;
171560f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            }
171570f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
17158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
17161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1716374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1716474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1716574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1716674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1716774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1716874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1716974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1717074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1717174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1717274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1717374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1717474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1717574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1717674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1717774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1717874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1717974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
171801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
171811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
171821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
171831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
171841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
171851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
171861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
171871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
171891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
171901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
171921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
171931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
171941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
171951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
171961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
171981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
171991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
172001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
172011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
172021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
17203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
17204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
17206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1720762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
17208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
17209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
17210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1721262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
17213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
17214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
17215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
17217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
172181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
17219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
172201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
172211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
17222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
17224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
17225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
17226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
172271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
172291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
172305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
172315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
17232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
17233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
17235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
172381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
17239ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<tr><th>Offset</th>";
17240ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
17241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
172421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
172458a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
172468a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $E1 = $Entries{$Index}{"E1"};
172478a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $E2 = $Entries{$Index}{"E2"};
172488a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
172498a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if($E1 ne $E2
172508a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    and $E1!~/ 0x/
172518a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    and $E2!~/ 0x/)
17252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
172531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
17254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
172551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
172561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
17257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
172591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
17260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
172621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
172631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
172641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
17265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
17267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
172681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
17269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
17271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
17274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
17277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
17279dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
17280dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
17281dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
17282dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17283ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
17284ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $VEntry=~s/ \[.+?\]\Z//; # support for ABI Dumper
17285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
17286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
17287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
17288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
17289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
17291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
17292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
17293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
17294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
17295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
17296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
17297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17299f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub adjustParamPos($$$)
17300f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17301f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $Symbol, $LibVersion) = @_;
17302f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol})
17303f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17304f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$Symbol}{"Static"}
17305f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        and $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
17306f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17307f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return $Pos-1;
17308f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17309f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17310f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Pos;
17311f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17312f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17313f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17314f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17315f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17316f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamPos($$$)
17317f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17318f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
17319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
17321f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"})
17322f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17323f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17324f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach (keys(%{$Info->{"Param"}}))
17325f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17326f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info->{"Param"}{$_}{"name"} eq $Name)
17327f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17328f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return $_;
17329f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17330f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17331f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17332f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17333f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17334f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17335f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17336f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamName($)
17337f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17338f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Loc = $_[0];
17339f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Loc=~s/\->.*//g;
17340f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $Loc;
17341f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17342f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17343447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenkosub getAffectedSymbols($$$)
17344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17345447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations) = @_;
17346ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
1734752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $LIMIT = 10;
17348ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    if(defined $AffectLimit) {
17349ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $LIMIT = $AffectLimit;
17350ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    }
17351f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17352ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my @Kinds = sort keys(%{$Kinds_Locations});
17353ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my %KLocs = ();
17354ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    foreach my $Kind (@Kinds)
17355f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
173569e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        my @Locs = sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$Kinds_Locations->{$Kind}});
17357ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $KLocs{$Kind} = \@Locs;
17358f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
1735952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1736052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymLocKind = ();
17361447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    foreach my $Symbol (sort keys(%{$TypeProblemsIndex{$Level}{$Target_TypeName}}))
17362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
173632489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(index($Symbol, "_Z")==0
173642489ef88760861175102e4508089608391beead3Andrey Ponomarenko        and $Symbol=~/(C2|D2|D0)[EI]/)
17365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
173682489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17369ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        foreach my $Kind (@Kinds)
17370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17371ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            foreach my $Loc (@{$KLocs{$Kind}})
17372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1737352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if(not defined $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}) {
17374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
173762489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17377ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                if(index($Symbol, "\@")!=-1
17378ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                or index($Symbol, "\$")!=-1)
17379ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                {
17380ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    my ($SN, $SS, $SV) = separate_symbol($Symbol);
17381ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17382ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    if($Level eq "Source")
17383ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    { # remove symbol version
17384ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                        $Symbol = $SN;
17385ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    }
17386ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17387ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    if($SV and defined $CompatProblems{$Level}{$SN}
17388ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    and defined $CompatProblems{$Level}{$SN}{$Kind}{$Loc})
17389ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    { # duplicated problems for versioned symbols
17390ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                        next;
17391ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    }
17392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
173932489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1739452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}{"Type_Name"};
173952489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Type_Name ne $Target_TypeName) {
173962489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    next;
173972489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
17398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1739952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymLocKind{$Symbol}{$Loc}{$Kind} = 1;
17400ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                last;
17401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1740452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17405ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    %KLocs = (); # clear
17406ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17407ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my %SymSel = ();
17408ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my $Num = 0;
17409ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymLocKind))
1741052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1741152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        LOOP: foreach my $Loc (sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$SymLocKind{$Symbol}}))
1741252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
17413ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            foreach my $Kind (sort keys(%{$SymLocKind{$Symbol}{$Loc}}))
1741452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
1741552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Loc"} = $Loc;
1741652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Kind"} = $Kind;
1741752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1741852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1741952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
17420ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17421ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $Num += 1;
17422ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17423ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        if($Num>=$LIMIT) {
17424ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            last;
17425ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        }
17426850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
1742752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
1742952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
1743352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1743452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1743681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            my $Kind = $SymSel{$Symbol}{"Kind"};
17437ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Loc = $SymSel{$Symbol}{"Loc"};
1743881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
1743952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $PName = getParamName($Loc);
1744081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $Kind, $Loc);
1744152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
1744352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($PName)
17444d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            {
1744552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Target .= " param=\"$PName\"";
1744652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Desc=~s/parameter $PName /parameter \@param /;
17447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1744852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Aretval(\-|\Z)/i) {
17449d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"retval\"";
17450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1745152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Athis(\-|\Z)/i) {
17452d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"this\"";
17453d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            }
17454d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1745552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Desc=~s/\AField ([^\s]+) /Field \@field /) {
17456d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " field=\"$1\"";
17457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17458d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17459d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            $Affected .= "        <symbol name=\"$Symbol\"$Target>\n";
1746052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Desc)."</comment>\n";
17461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
17462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
1746752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17469447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Kind = $SymSel{$Symbol}{"Kind"};
17470447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Loc = $SymSel{$Symbol}{"Loc"};
17471447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
17472447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $Kind, $Loc);
1747352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $S = get_Signature($Symbol, 1);
17474447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $PName = getParamName($Loc);
1747552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Pos = adjustParamPos(getParamPos($PName, $Symbol, 1), $Symbol, 1);
1747652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1747715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($S, $Pos, 1, 0, 0)."</span><br/>\n";
1747852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "<div class='affect'>".htmlSpecChars($Desc)."</div>\n";
17479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1748052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17481ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        if(keys(%SymLocKind)>$LIMIT) {
17482ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            $Affected .= " <b>...</b>\n<br/>\n"; # and others ...
17483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1748452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1748515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>\n";
17486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17488447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Num = keys(%SymLocKind);
17489447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $Per = show_number($Num*100/keys(%{$CheckedSymbols{$Level}}));
17490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
17491447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols: $Num ($Per\%)".$ContentSpanEnd.$Affected;
17492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
174942489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17498f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub cmpLocations($$)
17499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1750062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
17501f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($L2=~/\A(retval|this)\b/
17502f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and $L1!~/\A(retval|this)\b/)
17503f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17504f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($L1!~/\-\>/) {
17505f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17506f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17507f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($L2=~/\-\>/) {
17508f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17509f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17514f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getAffectDesc($$$$)
17515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
175161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
17517f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
175181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
17519f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17520f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Location_I = $Location;
17521f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Location=~s/\A(.*)\-\>(.+?)\Z/$1/; # without the latest affected field
17522f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17524f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17531f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %SymInfo = %{$CompleteSignature{1}{$Symbol}};
17532f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $METHOD_TYPE = $SymInfo{"Constructor"}?"constructor":"method";
17536f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$SymInfo{"Class"}}{"Name"};
17537f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17547f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $TypeID = undef;
17548f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17551f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17557f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17558f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Return"};
17559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17562f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17568f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17569f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Class"};
17570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17573f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17574f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17575f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = getParamPos($PName, $Symbol, 1);
17576f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17578f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in ".showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17581f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17583f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($PName) {
17584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "\'".$PName."\'");
17585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17586f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17587f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Param"}{$PPos}{"type"};
17588f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17589f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17590f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Location!~/this/)
17591f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17592f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(my %PureType = get_PureType($TypeID, $TypeInfo{1}))
17593dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17594f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($PureType{"Type"} eq "Pointer") {
17595dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17596dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17597f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    elsif($PureType{"Type"} eq "Ref") {
17598dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17599dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17602f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17606f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            else
17607f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17608f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Location_T = $Location;
17609f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $Location_T=~s/\A\w+(\->|\Z)//; # location in type
17610f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17611f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $TypeID_Problem = $TypeID;
17612f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Location_T) {
17613f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeID_Problem = getFieldType($Location_T, $TypeID, 1);
17614f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17615f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17616f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($TypeInfo{1}{$TypeID_Problem}{"Name"} eq $Problem{"Type_Name"}) {
17617f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17618f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17619f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                else {
17620f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17621f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1762562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
176268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17628d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17629d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my $Sent = join(" ", @Sentence);
17630d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1763152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Sent=~s/->/./g;
1763252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17633d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($ReportFormat eq "xml")
17634d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
17635d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Sent=~s/'//g;
17636d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
17637d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17638d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    return $Sent;
17639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17641f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getFieldType($$$)
17642f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17643f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Location, $TypeId, $LibVersion) = @_;
17644f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17645d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Fields = split(/\->/, $Location);
17646f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17647f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $Name (@Fields)
17648f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17649f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %Info = get_BaseType($TypeId, $LibVersion);
17650f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17651f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Pos (keys(%{$Info{"Memb"}}))
17652f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17653f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info{"Memb"}{$Pos}{"name"} eq $Name)
17654f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17655f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeId = $Info{"Memb"}{$Pos}{"type"};
17656f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                last;
17657f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17658f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17659f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17660f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17661f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $TypeId;
17662f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17663f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1767262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1767362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
176778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
176788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
176825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1768762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
176895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
176991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
177011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
177021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
177071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
177191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
177335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
177395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
177491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
177511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
177521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
177531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
177541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
177551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
177561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
177571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
177581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
177591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
177601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
177611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
1776762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1776862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1776962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
177701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
177711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
177721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
177751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
177761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
177781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
177791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
177801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
177811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
177831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
177841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
177861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
177871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
177881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
177891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
17790d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17791d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # additional symbols info (if needed)
17792d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # $Report .= get_Report_SymbolsInfo($Level);
17793d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
177941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
177951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
178001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
178011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
178021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
178031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
178041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
178051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
1780614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
1780741834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Keywords = $TargetTitle.", compatibility, API, ABI, report";
1780841834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Description = "API/ABI compatibility report for the $TargetTitle $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
178091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
178101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
178111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $BMetaData -\->\n<!-\- $SMetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."<body><a name='Source'></a><a name='Binary'></a><a name='Top'></a>";
1781252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title("Join")."
1781315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <br/>
1781415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <div class='tabset'>
178151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
178161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
178171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
178181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "<div id='BinaryTab' class='tab'>\n$BSummary\n".get_Report_Added("Binary").get_Report_Removed("Binary").get_Report_Problems("High", "Binary").get_Report_Problems("Medium", "Binary").get_Report_Problems("Low", "Binary").get_Report_Problems("Safe", "Binary").get_SourceInfo()."<br/><br/><br/></div>";
178191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "<div id='SourceTab' class='tab'>\n$SSummary\n".get_Report_Added("Source").get_Report_Removed("Source").get_Report_Problems("High", "Source").get_Report_Problems("Medium", "Source").get_Report_Problems("Low", "Source").get_Report_Problems("Safe", "Source").get_SourceInfo()."<br/><br/><br/></div>";
1782041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1782152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
178221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
178231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
178241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
178251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
178261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
1782714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
1782814b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Keywords = $TargetTitle.", ".lc($Level)." compatibility, API, report";
1782914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetTitle." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
178301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
178311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
178321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
178331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
178341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
178351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
178361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
178371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
1783852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title($Level)."\n".$Summary."\n";
178391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
178401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
178411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
1784241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/>\n";
1784341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1784452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
178451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
178461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
178481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
178491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
178501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
178511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
178521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
178530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
178541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
178561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
178571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
178581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
178591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
178601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
178621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
178631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
178641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
178661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
178671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1787141834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenkosub getReportFooter()
17872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1787341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    my $Footer = "";
1787401e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko
178758a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<hr/>\n";
178768a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<div class='footer' align='right'>";
178778a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<i>Generated by <a href='".$HomePage."'>ABI Compliance Checker</a> $TOOL_VERSION &#160;</i>\n";
178788a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "</div>\n";
1787941834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<br/>\n";
1788041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko
17881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178862489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my ($Severity, $Level) = @_;
1788752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
178882489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Severity, $Level);
178892489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Severity, $Level)) {
178901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17891dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1789252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1789352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($Severity eq "Low" or $Severity eq "Safe") {
1789452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Report .= get_Report_ChangedConstants($Severity, $Level);
178958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1789652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
179011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
179021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
179032489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
179041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
179051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
179061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
179072489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_".$Level."_Problems\'></a>".$Report;
179081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
179101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
179111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
179122489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
179131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
179141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
179151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
179162489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_Problems\'></a>".$Report;
179171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
179241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
179261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
179273ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
179283ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    my $Head = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
179293ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
179303ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<head>\n";
179313ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
179323ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta name=\"keywords\" content=\"$Keywords\" />\n";
179333ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta name=\"description\" content=\"$Description\" />\n";
179343ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<title>$Title</title>\n";
179353ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<style type=\"text/css\">\n$Styles</style>\n";
179363ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\n$Scripts\n-->\n</script>\n";
179373ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "</head>\n";
179383ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
179393ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    return $Head;
17940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17960a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1796174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
179621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1796374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17964a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
179651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17966a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17968a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17969a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17971a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17972a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1797374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1797474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1797574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1797674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1797774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1797874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1798574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1798674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1798874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1798974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1799074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17991a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1799274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
179934b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
18002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
18003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
18004fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18005fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
180064b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
18007a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
180084b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
180099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
18010a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
18011a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
18012a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
18013a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
18014a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
18015a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
18016fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
18017fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
18018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18019a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
18020a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
18021a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
18022a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
18023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1802574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1802674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1802774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1802874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1802974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1803074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1803174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1803274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1803374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1803474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1803574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1803674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1803774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1803874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1803974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1804074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1804174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
18042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
18044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
18045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1804674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1804774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1804874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1804974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1805074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
18051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
18052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1805374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1805474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
18055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
18058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18060a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
18061a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
18062a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
18063a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
18064a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
18065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
180671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
180681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
180691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
180701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
180711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
180721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
180731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
180741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
180771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
18078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
18079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
180801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
180811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
180821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
180831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
180841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
180851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
180861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
180871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
180891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
18090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
180911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
180921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
180931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
180941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
180951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
18096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
18097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
18099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
18100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
18101fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
18102fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
18103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
18105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
18106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
18108fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
18109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
18111fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18113fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18115fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18116fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18117fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
18119fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18120fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
18121fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
18123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
18124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
18127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
18128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18131fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18132fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
181339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
181349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
181359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
181369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
181379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
181389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
181399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
181409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
181419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
181429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
181439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
181449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
181459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
181469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
181479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
181489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
181499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
181509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
181519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
181529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
181539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
181549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
181559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
181569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
181579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
181589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
181599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
181609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
181619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
181629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
181639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
181649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
181659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
181669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
181679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
181689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
181699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
181709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
181719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
181729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
181739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
181749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
181759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
181769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
181779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
181789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
181799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
18180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
18181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
181828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
181838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
181848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
181858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
181878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
18188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
18189fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
18190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
18191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
181928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
181938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
181948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
181958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
181968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
181978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
181998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
182008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
182018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
182028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
182038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
182048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
182058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
182078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
182088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
182118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
182128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18215fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
18216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
18217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
18218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
18221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
18222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
182238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
18224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
182258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
182288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
182298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
182328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
18233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
182348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
182378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
182398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
182408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
18242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
182431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
18244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
18245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
18247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
18248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
182508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
18252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18253fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
18254fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
18255fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
18256fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18257fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18258fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18259fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
18260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
182628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
182648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
182668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
182678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
182718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
182728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
182738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
182748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
182758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
182798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
182808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
182818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
182858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
182878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
182888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
18290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
18291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
18292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
182938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
18295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
18297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
18298fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
18299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
18300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
18303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
18304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
18307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
18308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
18311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
18312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
18315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
18316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
183188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
18319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
18320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
18321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
18322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
183248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
183268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
183278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
183288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
183298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
183308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
183318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18334fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
18335fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18336fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
18337fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
18338fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
18339fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
18340fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18341fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18342fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
183438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
183478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
183488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
183528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
183538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
183578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
183588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
183598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
183608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
183671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
183711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
183751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
183831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1838662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
183871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18398570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
183994b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
184009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18401570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18402570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18403570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18404570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18405570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18406570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1840774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1840874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1840974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18410570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1841174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18412570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1841374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18414570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18415fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18416fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18417fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1842674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18431570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18432570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18433570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18434570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18435570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18437570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18438570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18439fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18440570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18441570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1844274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18443570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18444570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18445570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18447570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18448570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18449570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18450570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18451570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1845274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18453570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18461570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18462570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
184631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18464570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1846574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1846674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1846774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1846874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
184691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
184701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
184711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
184721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
184731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
184741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
184750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
184761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
184771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
184781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
184791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18481850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1848207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18483850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18487570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18489570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18490570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18491570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18492570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18493570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18494570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18495570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18496570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18498570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18499570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18500570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18501570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18506570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18507570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18509570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18511570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18512570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18513570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18514570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18515570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18519570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18525570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18526570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18527570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18528570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
185298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
185308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18531570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18535570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18536570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18538570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18539570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18540570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18541570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18543570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18578570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18579570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18580570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18581570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18582570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18583570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18584570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18585570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18595570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18597570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18598570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18599570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18600570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18601570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18602570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18603570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18604570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18605570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18606570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18607570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18608570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18609570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18610570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18611570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18612570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18613570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18614570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18615570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18616570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18617570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18619570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18620570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18621570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18622570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18623570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18624570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18625570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18628570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18629570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18630570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18631570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18632570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18636570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18638570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18639570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18640570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18641570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18642570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18643570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18644570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18645570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18646570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18647570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18648570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18649570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18650570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18651570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18654570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18655570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18659570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
186611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
186621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
186631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
186641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
186651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
186661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
186671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
186681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
186691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
186701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
186711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
186721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1867907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1868207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1868307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1868407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1868507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1868807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1869007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1869107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1869207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1869307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18694e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1869507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1869607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1869707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1869807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1869907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1870007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1870107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1870207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1870307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1870407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1870507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1870607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1870707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1870807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1870907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1871007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1871107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1871207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1871307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1871407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18715e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1871607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18717e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18718e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18719e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18720e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18721e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18722e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18723e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1872407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1872507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1872607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1872707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18728e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18729e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18730e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18734dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1873762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
187389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
187409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
187429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
187439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
187449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18746570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18747570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
187489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
187529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
187539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
187549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1875962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1876262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1876362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1876472930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1876562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1876662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1876762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
187689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1876962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1877062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1877162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1877262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1877362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1877462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1878062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1878362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1878462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
187859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1878662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1878762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1880162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
188199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
188471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
188509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
188526fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "macos")
18853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1885407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1885507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1885607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1885807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
188599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1886107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188676fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget eq "windows")
18868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18873a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
188749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18888f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        open(APP, "$ReadelfCmd -Ws \"$Path\" 2>\"$TMP_DIR/null\" |");
188899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
188929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
188939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
188949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
188959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
188969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
188979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
188999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
189009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
189019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
189039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
189059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
189069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
189079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
189089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
189179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
189189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
189199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
189209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
189219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
189239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
189249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
189259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
189269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
189279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
189289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
189309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
189319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
189329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
189339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
189359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
189369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
189379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
189389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18939fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
189409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
189419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
189509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
189519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
189529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
189539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1895474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
189559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
189569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
189579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
189589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
189599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
189609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
189629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
189639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
189649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
189679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
189699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
189709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
189719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
189729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
189769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
189771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
189789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
189809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
189819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
189821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
189839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
189849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
189859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
189879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
189889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
189901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
189919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
189929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
189939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
189941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
189969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
189979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
189989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
189999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1900007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
190019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1900207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
190039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1900407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
190059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1900607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
190079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
190099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
190109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
190119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19012570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
190139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
190149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
190159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1901674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
190171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
190189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19019e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
19020e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
19021e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
190229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
190239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
190249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
190269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
190281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
190299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
190309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
190319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
190321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
190331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
190349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
190359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
190361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
190371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
190389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
19039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
190409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
190419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1904274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1904381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    my $Real_Path = realpath_F($Lib_Path);
1904474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1904574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1904674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1904774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1904874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1904974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1905074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1905174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
19052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
19053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1905474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
19055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1905674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1905774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
190589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
190599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
190619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
190629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
190639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
19065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1906662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
19067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
19068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1906957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1907057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1907157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1907257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1907357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1907457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1907557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1907657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1907757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1907857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1907957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1908057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1908157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1908257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
19083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19085dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
19086a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
190871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
19088dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
190891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
190901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
19091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
19092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1909307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
190944b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
190954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
19096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1909707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19098a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
190991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
191001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1910107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
191021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
191031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
191051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1910607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
191071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19110570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
19111570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
19112570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
19113570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
19114570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
19115570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1911674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
19117570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
19118570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19119570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
19120570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
19121570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1912207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
19123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19124570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1912562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1912662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1912757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1912862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19129570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19130570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1913162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1913362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19135570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19136570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
191379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
191389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
19139570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
191409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
191419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1914707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
191489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
191499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
191509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
191519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1915207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1915307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
191544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
191554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1915607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1915707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
191589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
191599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
191609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
191619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
191629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
191639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
191649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
191669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
19171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
19172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
19173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
19174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
19175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
191761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
19177a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
191781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
191791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19180a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
191811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
191821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
191841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
191851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
191861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
1918881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        {
1918981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            my $realname = undef;
1919081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if($LIB_TYPE eq "dynamic")
1919181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            {
1919281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                # 1197 4AC 0000A620 SetThreadStackGuarantee
1919381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                # 1198 4AD          SetThreadToken (forwarded to ...)
1919481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                # 3368 _o2i_ECPublicKey
1919581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                # 1 0 00005B30 ??0?N = ... (with pdb)
1919681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*(?:=.+)?\Z/i
1919781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
1919881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                or /\A\s*\d+\s+_([\w\?\@]+)\s*(?:=.+)?\Z/)
1919981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                { # dynamic, static and forwarded symbols
1920081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $realname = $1;
1920181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                }
1920281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
1920381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            else
1920481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            { # static
1920581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                if(/\A\s{10,}\d*\s+([\w\?\@]+)\s*\Z/i)
1920681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                {
1920781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    # 16 IID_ISecurityInformation
1920881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $realname = $1;
1920981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                }
1921081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
1921181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
1921281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if($realname)
1921381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            {
1921462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1921562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1921657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1921762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1921862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1921962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1922062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1922262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
19225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
192269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
192279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
192289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
192299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
192309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
19236f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
192379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
192389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
192399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
192409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
192419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
192429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
192439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
192449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
192459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
192469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
192479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
19255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
19256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
19257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
19258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
19259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19260f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Cmd = $ReadelfCmd." -Ws \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19261a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
192621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
192631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19264f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            system($Cmd." >\"$DebugPath\"");
192651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
192661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
192671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
192681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
19269f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
192701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
192719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
19272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
19275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
192769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1927762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
192789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1927962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
192809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1928162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
192829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
192839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
19284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
19286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
192879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
19288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
192919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
19292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
192939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
19294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
19295570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
19296570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
19297570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1929874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
19299570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
19300570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19303c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
19304c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1930507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
19306c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
19307c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
19308c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
19309c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
19310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
193119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
193129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
193139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
19314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
19315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
19316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
19317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1931862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1931962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1932057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1932162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
193229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
193239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1932462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1932662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
193289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
193299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
193309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
193319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
193329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
193339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
193349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
193359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
193369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
193389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
193399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
193409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
193419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
193429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19346f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
19347f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        close(LIB);
19348f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19349f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Deps and $LIB_TYPE eq "dynamic")
19350f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # dynamic library specifics
19351f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Cmd = $ReadelfCmd." -Wd \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19352f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
19353f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19354f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            while(<LIB>)
19355f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
19356f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(/NEEDED.+\[([^\[\]]+)\]/)
19357f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # dependencies:
19358f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                  # 0x00000001 (NEEDED) Shared library: [libc.so.6]
19359f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $NeededLib{$1} = 1;
1936062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1936162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19362f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19363f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            close(LIB);
19364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
193679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
193689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
193699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1937374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
193759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
193769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
193789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19379a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
193809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
193819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
193829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
193839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19384fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
193859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
193869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19387a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19406fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19407fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19408fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19409fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19410fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19411fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19414fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19415fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
194239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1942674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1942774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1942874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1942974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1943074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
194319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
194419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
194429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
194439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
194449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
194459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
194469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
194479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
194509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
194519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
194529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
194539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
194549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
194559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
194569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19460e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19462e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19463e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19465e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19466e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19469e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
194702b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        my @Files = cmd_find($DevelPath,"f");
194712b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
194722b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        { # add symbolic links
194732b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if(-f $Link) {
194742b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                push(@Files, $Link);
194752b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
194762b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
19477e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19478ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for headers in /usr/lib
19479ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
19480ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
19481ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, @Headers);
19482e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19483e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19484e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19485e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
194869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19487e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19488e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19489e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19492e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19493ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"include"}})
19494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19495ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not -d $DevelPath);
19496ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for all header files in the /usr/include
19497ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # with or without extension (ncurses.h, QtCore, ...)
19498ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, cmd_find($DevelPath,"f"));
19499ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
19500ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # add symbolic links
19501ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(-f $Link) {
19502ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                push(@SysHeaders, $Link);
19503e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19506ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1950962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
195124b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
195214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
195278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
195311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
195321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
195471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
195501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
195578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
195588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
195598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
195608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
195618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
195638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
195648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
195658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
195668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
195678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
195688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
195698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
195708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
195718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
195728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
195738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
195748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
195758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
195768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
195778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
195808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
195818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
195828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
195858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
195868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
195888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
195898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
195908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
195918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
195928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
195948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
195958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
195968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
195978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
195988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
195998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
196008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
196018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
196028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
196038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
196048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
196058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
196068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
196078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
196088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
196098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
196118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
196128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
196138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
196148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
196158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
196168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
196178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
196188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
196198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
196208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
196218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
196228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
196238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
196248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
196258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
196268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
196288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
196298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
196318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
196328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
196358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
196388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
196398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
196408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
196418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
196428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
196438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
196448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
196468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
196478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
196488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
196498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
196508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
196548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
196558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
196568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1965762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1965862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1965962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1966062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1966162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1966262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1966362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
196648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
196658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
196668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
196678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
196688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
196718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
196728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1967362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1967462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1967562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1967662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
196811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
196821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19685f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $D (sort {$SkipHeaders{$LibVersion}{"Path"}{$a} cmp $SkipHeaders{$LibVersion}{"Path"}{$b}}
19686f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
196889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
196899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
196909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
196919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
196929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19695f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $P (sort {$SkipHeaders{$LibVersion}{"Pattern"}{$a} cmp $SkipHeaders{$LibVersion}{"Pattern"}{$b}}
19696f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1969862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1969962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1970062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1970162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1970262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1970362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1970462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1970562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
197088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
197129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19715570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
197199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
197268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
197279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
197299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
197309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
197319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
197329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
197339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
197349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1973554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
197369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1973707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
1973801e4122eddc2eef906a8032a358c05476349146fMattias Ellert    if($OStarget=~/linux|bsd|gnu/i)
197392768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
197402768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
197412768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
197422768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
197439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1974457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1974557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
197469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1974754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19748b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(not $CheckedArch{$LibVersion} and -f $Path)
1974954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19750d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $ObjArch = getArch_Object($Path))
1975154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
19752d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            if($ObjArch ne getArch_GCC($LibVersion))
19753d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            { # translation unit dump generated by the GCC compiler should correspond to the input objects
19754d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $CheckedArch{$LibVersion} = 1;
19755d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                printMsg("WARNING", "the architectures of input objects and the used GCC compiler are not equal, please change the compiler by --gcc-path=PATH option.");
1975654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1975754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1975854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1975954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko}
1976054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1976154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub getArch_Object($)
1976254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko{
1976354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $Path = $_[0];
1976454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1976554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my %MachineType = (
1976654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "14C" => "x86",
1976754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "8664" => "x86_64",
1976854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "1C0" => "arm",
1976954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "200" => "ia64"
1977054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    );
1977154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19772b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    my %ArchName = (
19773b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:31-bit" => "s390",
19774b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:64-bit" => "s390x",
19775b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common" => "ppc32",
19776b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common64" => "ppc64",
19777b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "i386:x86-64" => "x86_64",
19778b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "mips:3000" => "mips",
19779b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "sparc:v8plus" => "sparcv9"
19780b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    );
19781b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
197826fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "windows")
1978354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1978454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $DumpbinCmd = get_CmdPath("dumpbin");
1978554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $DumpbinCmd) {
1978654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
1978754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1978854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1978954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $DumpbinCmd." /headers \"$Path\"";
1979054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Out = `$Cmd`;
1979154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1979254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/(\w+)\smachine/)
1979354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1979454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(my $Type = $MachineType{uc($1)})
1979554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1979654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                return $Type;
1979754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1979854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1979954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1980001e4122eddc2eef906a8032a358c05476349146fMattias Ellert    elsif($OStarget=~/linux|bsd|gnu/)
1980154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1980254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
1980354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $ObjdumpCmd) {
1980454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
1980554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1980654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1980754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $ObjdumpCmd." -f \"$Path\"";
198086fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko
198096fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        if($OSgroup eq "windows") {
198106fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "set LANG=$LOCALE & ".$Cmd;
198116fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
198126fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        else {
198136fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "LANG=$LOCALE ".$Cmd;
198146fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
198156fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Out = `$Cmd`;
1981654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1981754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/architecture:\s+([\w\-\:]+)/)
1981854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1981954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $Arch = $1;
1982054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch=~s/\:(.+)//)
1982154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1982254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                my $Suffix = $1;
1982354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19824b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                if(my $Name = $ArchName{$Arch.":".$Suffix})
1982554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                {
19826b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                    $Arch = $Name;
1982754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                }
1982854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1982954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19830b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch=~/i[3-6]86/) {
1983154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86";
1983254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1983354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1983454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch eq "x86-64") {
1983554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86_64";
1983654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1983754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19838b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch eq "ia64-elf64") {
19839b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                $Arch = "ia64";
19840b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            }
19841b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
19842d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            return $Arch;
1984354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1984454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
19845737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    elsif($OStarget=~/macos/)
19846737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    {
19847737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        my $OtoolCmd = get_CmdPath("otool");
19848737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        if(not $OtoolCmd) {
19849737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"otool\"");
19850737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
19851737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
19852737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        my $Cmd = $OtoolCmd." -hv -arch all \"$Path\"";
19853737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        my $Out = qx/$Cmd/;
19854737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
19855737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        if($Out=~/X86_64/i) {
19856737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            return "x86_64";
19857737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
19858737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        elsif($Out=~/X86/i) {
19859737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            return "x86";
19860737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
19861737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
1986254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    else
19863737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    {
19864737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        exitStatus("Error", "Not implemented yet");
1986554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        # TODO
1986654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1986754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1986854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    return undef;
198699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
198709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
198719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
198729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
198739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
198749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
198759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
198769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
198779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
198789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
198799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
198809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
198819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19882a914cb546e74ff89ff5038d0a57d6e7032617d80Lénaïc Huard    my $SonameCmd = "$ObjdumpCmd -x \"$Path\" 2>$TMP_DIR/null";
198839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
198849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
198859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
198869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
198879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
198889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1988954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`)
1989054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
198919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
198929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
198939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
198949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
198959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
199018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
199099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
199109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1991662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19917570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19920570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
199249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1992581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $Libs{realpath_F($Path)} = 1;
19926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
199348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
199359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1993681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                $Libs{realpath_F($Path)} = 1;
19937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19940570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
199438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19946850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
199479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1994881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                        $Libs{realpath_F($Path)} = 1;
19949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1995362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1996081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenkosub realpath_F($)
1996181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko{
1996281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    my $Path = $_[0];
1996381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    return path_format(realpath($Path), $OSgroup);
1996481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko}
1996581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
199661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
199671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
199681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
199691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19972d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getGCC_Opts($)
19973d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19974d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19975d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19976d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my @Opts = ();
19977d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19978d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($CompilerOptions{$LibVersion})
19979d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # user-defined options
19980d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $CompilerOptions{$LibVersion});
19981d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19982d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GccOptions)
19983d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # additional
19984d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $GccOptions);
19985d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19986d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19987d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(@Opts) {
19988d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return join(" ", @Opts);
19989d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19990d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19991d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return undef;
19992d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19993d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19994b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenkosub getArch_GCC($)
19995d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{
19996d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19997d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19998d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(defined $Cache{"getArch_GCC"}{$LibVersion}) {
19999d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return $Cache{"getArch_GCC"}{$LibVersion};
20000d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
20001d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20002737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if(not $GCC_PATH) {
20003737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        return undef;
20004737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
20005737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
20006d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Arch = undef;
20007d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20008737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if(my $Target = get_dumpmachine($GCC_PATH))
20009737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    {
20010737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        if($Target=~/x86_64/) {
20011737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            $Arch = "x86_64";
20012737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
20013737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        elsif($Target=~/i[3-6]86/) {
20014737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            $Arch = "x86";
20015737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
20016737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        elsif($Target=~/\Aarm/i) {
20017737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            $Arch = "arm";
20018737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
20019737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    }
20020737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
20021737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko    if(not $Arch)
20022d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    {
20023d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n");
20024d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20025d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." test.c -o test";
20026d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
20027d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
20028d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
20029d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
20030d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20031d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
20032d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        system($Cmd);
20033d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
20034d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
2003581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        my $EX = join_P($TMP_DIR, "test");
2003681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2003781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if($OSgroup eq "windows") {
2003881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            $EX = join_P($TMP_DIR, "test.exe");
2003981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        }
2004081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2004181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        $Arch = getArch_Object($EX);
20042d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20043d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test.c");
2004481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        unlink($EX);
20045d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
20046d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20047d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Arch) {
20048d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check ARCH type");
20049d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
20050d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20051d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return ($Cache{"getArch_GCC"}{$LibVersion} = $Arch);
20052d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
20053d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
2005454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub detectWordSize($)
20055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2005654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $LibVersion = $_[0];
2005754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
20058d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Size = undef;
20059d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20060d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    # speed up detection
2006154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $Arch = getArch($LibVersion))
2006254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
20063b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        if($Arch=~/\A(x86_64|s390x|ppc64|ia64|alpha)\Z/) {
20064d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "8";
20065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20066d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        elsif($Arch=~/\A(x86|s390|ppc32)\Z/) {
20067d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "4";
20068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20070d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20071d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
2007254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
2007354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        writeFile("$TMP_DIR/empty.h", "");
20074d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20075d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." -E -dD empty.h";
20076d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
20077d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
20078d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
20079d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
20080d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20081d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
20082d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Defines = `$Cmd`;
20083d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
20084d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
2008554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        unlink("$TMP_DIR/empty.h");
2008654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
2008754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
2008854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 4
20089d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = $1;
2009054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
2009154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
2009254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 3
2009354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $PTRDIFF = $1;
2009454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($PTRDIFF=~/long/) {
20095d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "8";
2009654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
2009754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            else {
20098d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "4";
2009954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
2010054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
20101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2010254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
20103d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Size) {
20104d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check WORD size");
20105d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
20106d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
20107d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return $Size;
20108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20110d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getWordSize($)
20111d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
20112f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
20113f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
20114f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
20116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
20118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
20119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
20120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
20121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
201241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
20125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
20126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
20127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
20128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
20129570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
20130570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
20131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
20132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
20133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
20135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
20136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
20140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
20143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
201449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
20145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
20146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
20147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
20150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
201519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
201529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
201539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20155850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2015601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
20157850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2015801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
2015901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
2016001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
2016101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
2016201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
20163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2016401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
2016501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
2016601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
2016701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
2016801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
2016901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
2017001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2017101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
2017201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
2017301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
2017401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2017501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
2017601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
2017701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2017801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
2017901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
2018001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
2018101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
20184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
2018501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
20186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
20187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
20188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
20189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
2019152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $UsedDump{$LibVersion}{"M"} = $ABI->{"LibraryName"};
20192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2019399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($ABI->{"PublicABI"}) {
2019499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        $UsedDump{$LibVersion}{"Public"} = 1;
2019599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
2019699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
20197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
20198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
20199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
20200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
20201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
20202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
20205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
20207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
20208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
20209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
202116ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko
20212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
202136ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
202146ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)");
20215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
20218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
20219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
20220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
20221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
20223fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2022415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if(not $TargetComponent_Opt)
2022515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        {
2022615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            if($ABI->{"LibraryName"}=~/\.ko[\.\d]*\Z/) {
2022715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "module";
2022815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
2022915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            else {
2023015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "object";
2023115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
2023215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
20233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
202355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
202365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
202375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
202381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2023901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
202401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
202411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
202421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
202435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
202445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
202455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
202465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
20247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2024801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
2024901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
20250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
20251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
20252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2025374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
2025474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
2025574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2025674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2025701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
20258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
20260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
20261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2026262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2026301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
2026462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2026562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
20266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2026701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
2026862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
2026962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
2027001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
2027162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2027262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
2027362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
2027462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2027562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
2027662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2027762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
2027862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
20279177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
2028062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2028162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2028262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
2028362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
2028462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2028562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
2028662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
2028762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2028862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
2028962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
2029062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
2029162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2029262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2029362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
2029462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
20295177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
20296177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20297177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
20298177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
20299177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
2030062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2030162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2030262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2030362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
2030462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2030562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
2030662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2030762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2030862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2030962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
2031062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2031162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
2031262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
2031362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2031462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
2031562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
2031662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
20317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
2031862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
20319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
2032062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2032162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2032262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
2032362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2032501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
2032601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
20327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
20328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2032901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
20330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
20332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
20333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
20334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
20335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2033762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2033801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
20339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2034062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
2034162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2034201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
2034362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
2034401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
2034562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2034662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
2034762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
2034862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
2034962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
2035062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
2035162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2035262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
2035362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
2035462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2035601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
20357d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
20358d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if(my $V = $TargetVersion{$LibVersion}) {
20359d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $V;
20360d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20361d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    else {
20362d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
20363d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20364d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
2036581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if(not keys(%{$SkipTypes{$LibVersion}}))
2036699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    { # if not defined by -skip-types option
2036799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"SkipTypes"})
2036899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2036999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"SkipTypes"}}))
2037099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2037199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2037299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2037399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2037499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"OpaqueTypes"})
2037599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        { # support for old dumps
2037699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"OpaqueTypes"}}))
2037799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2037899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2037999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2038099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
20381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20382ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
2038381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if(not keys(%{$SkipSymbols{$LibVersion}}))
20384ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -skip-symbols option
2038581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if(defined $ABI->{"SkipSymbols"}) {
2038681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
2038781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        }
2038881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if(defined $ABI->{"SkipInterfaces"})
20389ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20390ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
20391ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
2039281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if(defined $ABI->{"InternalInterfaces"})
20393ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20394ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
20395ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
20396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2039701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
20398ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
20399ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if(not $TargetHeaders{$LibVersion})
20400ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -headers-list option
20401ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
20402ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
20403ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
2040401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
20405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2040601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
20407b3118d9752afef5233235b4f95359357b2e72432Andrey Ponomarenko
20408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2040901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
20410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
204112c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
20412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
2041301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
204142c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
204155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
204165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
20417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
20418850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
204193e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
204212c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
204222c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        if(not $ABI->{"PublicABI"})
204232c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        {
204242c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            foreach (keys(%{$Registered_Sources{$LibVersion}})) {
204252c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
204262c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            }
20427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2042901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
20430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
20431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
20432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
20433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
20434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2043701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
20438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
20439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
20440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
20441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
20442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
20443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
20445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
20446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
20447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
2044801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
20449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
20451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
20452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2045362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
20454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2045562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2045662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
20457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
20458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
20459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
204609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
204619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
204629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
204639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
204649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
20465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2046862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
2046962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2047062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
2047162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2047262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2047362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2047462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
204761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20478f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
2047962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2048062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
2048162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
2048262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
2048362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
20484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
20487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2048862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
2048962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
20491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20493fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
20494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
20495fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
20496fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
20497fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
20498fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
20499fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
20500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20501fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20502fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
20504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
20505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
20508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
20510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
20511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
205183e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
205193e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
205203e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
205213e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2053574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2053674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2053774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2053874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2053974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2054074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2054174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2054274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2054374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2054474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2054574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20546fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2054774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2054874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2054974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2055074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2055174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2055274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2055374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2055474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2055574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2055674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2055774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2055874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2055974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2056074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2056174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2056274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2056374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2056474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2056574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2056662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20567dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko    { # NOTE: order is important
2056862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2056962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2057062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2057162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2057262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2057462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2057562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2057862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2057962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2058062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2058162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
205829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
205839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
205849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
205859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2059001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2059101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2059201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20593dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
20594dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko        # support for old formatting of type names
20595dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko        $TypeInfo{$LibVersion}{$TypeId}{"Name"} = formatName($TypeInfo{$LibVersion}{$TypeId}{"Name"}, "T");
20596dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
2059762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2059862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2059962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
206001b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            foreach my $SubId (keys(%{$TInfo{"Base"}}))
206011b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            {
206021b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($SubId eq $TypeId)
206031b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                { # Fix erroneus ABI dump
206041b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$TypeId}{"Base"}{$SubId});
206051b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    next;
206061b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                }
206071b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko
206081b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$SubId}{$TypeId} = 1;
2060962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2061062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2061101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2061201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2061301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2061401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2061501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2061601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2061701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2061801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2061901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2062001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2062101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2062201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2062301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2062401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2062501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20626fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20627fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20628fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20630dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
20631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2063262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20633fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2063462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2063562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2063662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2063762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2063862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2063962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2064062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2064162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
206428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2064362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2064462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2064562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2064662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2064762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2064962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2065062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2065162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20652dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko            $TName_Tid{$LibVersion}{$TInfo{"Name"}} = $TypeId;
2065362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2065462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2065562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2065662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2065762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2065862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2065962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2066062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2066162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2066362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2066462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2066562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2066662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20669b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20670b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2067162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2067262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20677f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20678f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20679ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20680ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20681ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20682ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20683ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20684ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20685ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20686ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20687ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20688ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20689ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20690ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20691ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20692ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20693ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20694ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20695ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20696ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20697ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20698ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20699ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20700f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20701f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20702f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20703f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
207049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
207059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
207069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
207079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20708fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20709fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20710fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20711fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20712f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20713f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2071901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2072001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2072101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2072301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2072401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2072801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2073462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2073962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2074162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2074262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2074362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2075601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2075701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2076301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
207649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
207659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
207669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
207679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
207689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2077701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2077901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2078301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
207846ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2078601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20793fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
207946ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
208048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
208319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20837ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckHeadersOnly = 1;
20838ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20839ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==1) {
20840ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "X";
20841ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20842ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20843ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==2) {
20844ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "Y";
20845ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20846ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20872a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20873a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20874a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20875a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2087674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2087774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2087874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2087974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2088074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2088174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20899a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20900a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2090574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2090674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2090774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2090874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2090974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2091074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2091174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2091274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2091374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2091782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20931570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20940570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20946570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20948a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
209491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20950570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20951570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2095481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            my $Path = realpath_F($1);
20955570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20956570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20958570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20964570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20965570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20969570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20970570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20971570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20972570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20980570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
21000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
21002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
21003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21004570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
21005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
21006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
21007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
21008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21009570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
210106fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    { # <search_libs> section of the XML descriptor
210116fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko      # do NOT search for systems libraries
21012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
21013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
21015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
21016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
21017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
21018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
21019570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
21020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
21022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
21023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
21024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
21025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
21026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
21027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
21028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
21029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
21030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
21031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
21032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
21033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21034570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
21035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
21036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
21037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
21038570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
21039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
21041570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
21042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21044570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
21045570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21046570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
21048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
21049570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
21050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
21055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
21057570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
21058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
21060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
21061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
210624b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
210644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
210654b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
210664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
210674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
210684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
210694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
21070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
21073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21074570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
21075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
21076570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
21077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
21079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21080570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
21081570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
21082570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
21083570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
21084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
21087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
21090570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
21091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
21092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
21094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
21095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
21096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
21097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
21100570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
21101570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
21102570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21104570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
21105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21106570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
21107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
21109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
21111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
21112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
21113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
21114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
21115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
21117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
21118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
21119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
21122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
21125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
21129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
21130570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
21131570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
21132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
21133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2113401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2113501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
21136570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2113701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
211388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2113901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2114001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2114101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2114201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2114301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2114401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2114501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2114601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2114701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2114801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
21150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
21151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21152f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
211538a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        my $GCC_Ver = get_dumpversion($GCC_PATH);
211548a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($GCC_Ver eq "4.8")
211558a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        { # on Ubuntu -dumpversion returns 4.8 for gcc 4.8.4
211568a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $Info = `$GCC_PATH --version`;
211578a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
211588a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if($Info=~/gcc\s+(|\([^()]+\)\s+)(\d+\.\d+\.\d+)/)
211598a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            { # gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
211608a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko              # gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
211618a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                $GCC_Ver = $2;
211628a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
211638a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
211648a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
21165737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        if($OStarget=~/macos/)
21166737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        {
21167737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            my $Info = `$GCC_PATH --version`;
21168737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
21169737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            if($Info=~/clang/i) {
21170737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko                printMsg("WARNING", "doesn't work with clang, please install GCC instead (and select it by -gcc-path option)");
21171737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko            }
21172737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko        }
21173737aef59b7ef09bb0f7e3809e5dd7883c0a27adcAndrey Ponomarenko
211748a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($GCC_Ver)
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21176ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $GccTarget = get_dumpmachine($GCC_PATH);
21177ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21178ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GccTarget=~/linux/)
21179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21180ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "linux";
21181ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
21182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21183ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            elsif($GccTarget=~/symbian/)
21184ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            {
21185ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "symbian";
21186ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
21187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21188ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21189ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget, target: ".getArch_GCC(1).")");
21190ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21191ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            # check GCC version
21192ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GCC_Ver=~/\A4\.8(|\.[012])\Z/)
21193ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57850
211948a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko              # introduced in 4.8 and fixed in 4.8.3
211958a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                printMsg("WARNING", "Not working properly with GCC $GCC_Ver. Please update GCC to 4.8.3 or downgrade it to 4.7. You can use a local GCC installation by --gcc-path=PATH option.");
211968a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
21197ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $EMERGENCY_MODE_48 = 1;
21198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21200ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
21201ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "something is going wrong with the GCC compiler");
21202ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
21203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
21205ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
21206ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # GCC standard paths
21207ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($GCC_PATH and not $NoStdInc)
21208ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
21209ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my %DPaths = detect_inc_default_paths();
21210ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultCppPaths = @{$DPaths{"Cpp"}};
21211ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultGccPaths = @{$DPaths{"Gcc"}};
21212ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultIncPaths = @{$DPaths{"Inc"}};
21213ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            push_U($SystemPaths{"include"}, @DefaultIncPaths);
21214ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
21215ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21216ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # users include paths
21217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
21218dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
21219dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
21220dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
21221dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
21222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
21223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2122574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2122674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2122774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2122874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2122974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2123074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
21231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
21234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
21236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
21237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
21238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
21240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
21243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
21245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
21247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
21249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
21252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
21256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
21257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21258a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
21259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
21260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
21261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
21264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
21268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
21269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21270a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
21271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
21272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
21273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21275570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
21276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
21280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
21281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
21282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
21283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
21284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21285a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
21286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
21287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
21288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
21291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2129362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
21294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2129562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2129662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2129762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2129862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
21299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2130062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2130162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2130262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2130362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2130462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2130562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2130662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2130762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
21308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
21311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
213139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
21314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
21316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
21319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21320570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
21321570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21322570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
21323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21324570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
21325570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21326570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
21327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21328570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
21329570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
21330570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21331570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
21332570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21335570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
21336570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
21337570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21338570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
21339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
21340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
21341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
21343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21344570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
21345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21346570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
21347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
21349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
21350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
21352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21355570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
21356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
21359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
213609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
213619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
213629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
21363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
213649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
213659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
213669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
213679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
213689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
213699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
21370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
21372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
21373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
21375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
21376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21377fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
21379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
21380a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
21381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
21382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
21383a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
21384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
21386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
21391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
21392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21396a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
21397a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
21398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
21399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
21400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
21402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
21403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
21404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
21405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
21406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
21410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
21415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
21416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
21423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
21426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
21427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
21428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
21430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
21434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
21438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
21439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
21440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
21441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
21444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
21448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
21455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
21458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
21459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
21460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
21466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
21470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
21471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
21472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
21479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
21480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
21486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
21488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
21489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
21490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
21491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
21492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
21493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
21494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
21497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
21499ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
21501ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    prepareSymbols(1);
21502ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
21504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
21505ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
21507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
21508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
215101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
215131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
21514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
21515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
21518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
215191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
21523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
215241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
21528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
21529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
21531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
21532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
21533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
21534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
21536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
21538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2153974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
21540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
21542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
215431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
21544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
21545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
21546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
21547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2155062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
215551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SubReport = insertIDs($ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Symbol</b>]</span><br/><br/>".$ContentDivEnd."\n");
215569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2157662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2157762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2157862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2157962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2158062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2158262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
215831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
215841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
215851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
215891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
2159141834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    <br/><br/>\n".getReportFooter()."
2159252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    </body></html>";
21593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
215969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
215979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
215989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
215999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
216009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
216019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
216029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21606a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21607a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21608a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
2160981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if($OSgroup eq "windows") {
2161081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        $LName = lc($LName);
2161181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    }
21612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2164662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21651989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21652989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21653989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21654989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21655989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21656989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21657989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21659989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21660989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21661989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
217041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
217051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
217061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
217071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
217081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
217091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
217101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
217111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
217121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
217131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
217481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
217491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
217501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
217511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
217521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
217531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
217551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
217561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
217571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
217591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
217601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
217611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
217631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
217641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
217651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
217671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
217681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
217701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
217711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
217721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
217741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
217751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
217761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
217781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
217791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
217801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
217821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
217831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
217851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
217861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
217871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
217891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
217901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
217911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
217931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
217941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
217951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
217961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
217971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
217981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
217991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
218001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
218011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
218021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
218031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
218041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
218051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
218061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
218081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
218091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
218101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
218121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
218131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
218141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
218151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
218161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
218171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
218181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
218191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
218201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
218211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
218251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
218261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
218271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
218291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
218301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
218311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
218331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
218341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
218361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
218371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
218381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
218391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
218401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
218431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
218441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
218461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
218471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
218491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
218501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
218521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
218531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
218541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
218551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
218571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
218581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
218601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
218611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
218631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
218641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
218661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
218671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
218681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
218691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
218711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
218721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
218740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
218751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
218761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
218781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
218791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
218801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
218821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
218831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
218841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
218850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
218861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
218871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
218891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
218901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
218911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
218931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
218941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
218951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
218961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
218971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
218981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
218991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2190581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if(not $ENV{"VCINSTALLDIR"}
2190681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    or not $ENV{"INCLUDE"}) {
2190781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        exitStatus("Error", "can't start without VC environment (vcvars64.bat)");
21908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
219115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
219125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
219135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
219145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
219155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
219165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
219175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
219185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
219195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
219205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
219215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
219225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
219235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
219245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
219255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
219265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
219275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
219286bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenkosub defaultDumpPath($$)
219296bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko{
219306bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my ($N, $V) = @_;
219316bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    return "abi_dumps/".$N."/".$N."_".$V.".abi.".$AR_EXT; # gzipped by default
219326bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko}
219336bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko
21934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2193954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
21940ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($DumpAPI)) {
21941ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $DumpAPI);
21942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21943ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21944ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $DumpAPI));
21945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21948ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # set to default: N
21949ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $Descriptor{1}{"Version"} = "N";
21950fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2195474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
219556bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my $DumpPath = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
219568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
219578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
219588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2195974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
219608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
219618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
219628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
219638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
219648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
219658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
219668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
219678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
219688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
219698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2197074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
219718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
219728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
219738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
219748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
219758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
219768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
219778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
219788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
219798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
219808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2198174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2198274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2198374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2198401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2198501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2198601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2198701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2198801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2198901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2199001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2199101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21992ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2199354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
21994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2199501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2199601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2199701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2199801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2199901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
22000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22001850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
22002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
22003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
22004ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
22007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
22008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
22011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
22015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
22016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
22017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22018570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
22019570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
22020570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
22021570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
22022570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
22023570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
22024570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
22025570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
22026570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
22027570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
22028570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
22029570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
22030570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
22031570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
22032570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
22033570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
22034570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
22035570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
22036570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
22037570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
22038570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
22039570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
22040570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
22043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
22044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
22046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
22047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
22048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
22049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22050fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2205301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
22054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
22055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
22056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2205762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
22058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
22059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
22060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
22061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
22062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
22064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
22065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
22066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
22067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
22068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
22069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
22070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
22071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
22072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
22074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
22075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
22076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
220775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2207801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
220795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
220805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2208101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
220825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
22084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2208501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
22086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
220871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
220881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2208901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
220901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2209174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
22092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2209374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
22094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
22095fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2209674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
220975c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
220985c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
220995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
221005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
221015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2210201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
221035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
221041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
221051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2210601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
221071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
221105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
22111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
22112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
22113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
22116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
22117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
221185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
221195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
221205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
221215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
22122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
22123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
221255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
22126850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
22127850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
22129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
22130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2213107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2213207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
221335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2213407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
22135ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
221369e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            printMsg("INFO", "dump path: $OutputDumpPath");
22137ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
22138ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
221399e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            printMsg("INFO", "dump path: $DumpPath");
221405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
221419e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        # printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
22142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
22146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
2214781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko  # ~4 times faster than merging equal dumps
22148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
22149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
22150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
22151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
22152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
2215381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if($Descriptor{1}{"Path"} eq $Descriptor{2}{"Path"}
2215481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    or -s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
22155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22156447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $FilePath1 = $Descriptor{1}{"Path"};
22157447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $FilePath2 = $Descriptor{2}{"Path"};
22158447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
22159447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not isDump_U($FilePath1)) {
22160447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $FilePath1 = unpackDump($FilePath1);
22161447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
22162447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
22163447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not isDump_U($FilePath2)) {
22164447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $FilePath2 = unpackDump($FilePath2);
22165447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
22166447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
22167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
22168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2216901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2217001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2217101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2217201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2217301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2217401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2217501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
22176850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
22177850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22178850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
22179850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
22180850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
22181850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2218281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            my $Eq = 0;
2218381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2218481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if($FilePath1 eq $FilePath2) {
2218581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                $Eq = 1;
2218681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
22187850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2218881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if(not $Eq)
22189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2219081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                open(DUMP2, $FilePath2);
2219181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                my $Content2 = <DUMP2>;
2219281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                close(DUMP2);
2219381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2219481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                if($Content1 eq $Content2) {
2219581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $Eq = 1;
2219681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                }
2219781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
22198850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
22199850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
2220081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
2220181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2220281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if($Eq)
2220381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            {
2220481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                printMsg("INFO", "Input ABI dumps are equal, so generating quick empty report");
22205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
22206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
22207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
22209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
22210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
222129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
22213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
222151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
22216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
22217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
222191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
22220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
22221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
2222381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2222481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                foreach (keys(%{$Registered_Headers{1}})) {
2222581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $TargetHeaders{1}{$_} = 1;
2222681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                }
2222781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
22228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
22229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
22230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
222311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
222321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
222331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
222341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
22235447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                foreach my $S (keys(%{$ABIdump->{"SymbolInfo"}}))
22236447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                {
22237447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    if(my $Class = $ABIdump->{"SymbolInfo"}{$S}{"Class"})
22238447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    {
22239447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        if(defined $ABIdump->{"TypeInfo"}{$Class}{"PrivateABI"}) {
22240447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                            next;
22241447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        }
22242447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    }
22243447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
22244447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    my $Access = $ABIdump->{"SymbolInfo"}{$S}{"Access"};
22245447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    if($Access ne "private")
22246447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    {
22247447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $CheckedSymbols{"Binary"}{$S} = 1;
22248447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                        $CheckedSymbols{"Source"}{$S} = 1;
22249447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    }
22250447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                }
222511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
22252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
22253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
2225481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2225581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                if(defined $ABIdump->{"ABI_DUMPER_VERSION"})
2225681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                {
2225781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $UsedDump{1}{"DWARF"} = 1;
2225881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $UsedDump{2}{"DWARF"} = 1;
2225981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2226081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $UsedDump{1}{"M"} = $ABIdump->{"LibraryName"};
2226181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                    $UsedDump{2}{"M"} = $ABIdump->{"LibraryName"};
2226281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                }
2226381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
22264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
22265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
22271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
22274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
22275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
22276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
22277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
22278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
22281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2228281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    $LOG_PATH{$LibVersion} = join_P(get_abs_path($LOG_DIR), $LOG_FILE);
22283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
22284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
22285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2228674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2228774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2228874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2228974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2229074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
22291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2229235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
22293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
22296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
22298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
22300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
22304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
22307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
22308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2230935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2231035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2231135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
22312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
22316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
22320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
22324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22325b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz(\.\w+|)|\.zip|\.xml|)\Z/)
22326b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    { # NOTE: name.abi.tar.gz.amd64 (dh & cdbs)
223279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
223289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
223299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
223309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
223319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
223329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
223339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
22334b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)\Z/) {
22335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
22336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
22338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
223401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
22341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
22343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
223440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
22345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22346ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{1}{"Path"}) {
22347ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{1}{"Path"}."\'");
22348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22349ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
223510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
22352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22353ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{2}{"Path"}) {
22354ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{2}{"Path"}."\'");
22355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22356ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
2235881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko
2235981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    if(not defined $DisableQuickEmptyReport)
2236081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    {
2236181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if(isDump($Descriptor{1}{"Path"})
2236281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        and isDump($Descriptor{2}{"Path"}))
2236381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        { # optimization: equal ABI dumps
2236481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            quickEmptyReports();
2236581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        }
22366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22367ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
22369ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22370ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})) {
22371ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $Descriptor{1}{"Path"});
22372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22373ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
22374ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $Descriptor{1}{"Path"}));
22375ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22376ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22377ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{2}{"Path"})) {
22378ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(2, $Descriptor{2}{"Path"});
22379ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22380ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
22381ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(2, createDescriptor(2, $Descriptor{2}{"Path"}));
22382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22384fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
22385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
22386fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
2238715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #1 is not set (use --v1=NUM option)\n";
22388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
22391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
22392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
2239315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #2 is not set (use --v2=NUM option)\n";
22394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
223962c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{1}{"V"}) {
223972c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(1);
223982c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
223992c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
224002c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{2}{"V"}) {
224012c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(2);
224022c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
22403ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22404ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # check input data
22405ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}) {
22406ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d1");
22407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22408ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}) {
22409ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d2");
22410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22411ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22412ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $CheckHeadersOnly)
22413bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22414ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{1}{"Libs"}) {
22415ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d1");
22416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22417ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{2}{"Libs"}) {
22418ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d2");
22419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22421ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
22423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
22424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
224256bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath1 = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
224266bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath2 = defaultDumpPath($TargetLibraryName, $Descriptor{2}{"Version"});
2242774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2242874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2242974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2243074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
22431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
22432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
22433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
22434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
22435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
22436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
22437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
22439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
22440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22444dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22445dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22447dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22448dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22449dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22450dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22451dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
22460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
22461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22463850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22464850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22465850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22466850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22467850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2246862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2246962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2247062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2247101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2247201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2247301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22475f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22476f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22478850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22479850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2248062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22481850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2248374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
22484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
22488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
22489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
22490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
22491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
22492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
22494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
22495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22499dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22500dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22502dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22503dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22504dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22505dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22506dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
22515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
22516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22517850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22518850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22519850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22521850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22522850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2252362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2252462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2252562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2252601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2252701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2252801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22529f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22530f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22531f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22532850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22533850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2253562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22536850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2253874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
2254614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko
22547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2254874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2254974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
2255014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        if($TargetTitle ne $TargetLibraryName) {
2255114b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-title", $TargetTitle);
22552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2255935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2256035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22562dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22563dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22564dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
225671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
225681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
225691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
225701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
225711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
225721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
225731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
225741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
225751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
225761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
225771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
225781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22579f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22580f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22581f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22582f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22583f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22584f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22585f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22586f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22587f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2258862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2258962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2259062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2259162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22592850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22610ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2261154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
22612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22621ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(2);
2262254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize(2);
22623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2262762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2263262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2264162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2264262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22655ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # process input data
22656ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{1}{"Headers"}
22657ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{1}{"Dump"}) {
22658ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(1);
22659ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22660ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{2}{"Headers"}
22661ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{2}{"Dump"}) {
22662ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(2);
22663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22664850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22665850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22666850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22667850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22668850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
226691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
226701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
226711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22672850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
226731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
226741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
226751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
226761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
226771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
226781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2267962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2268062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
226811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
226821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
226831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
226841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
226851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
226861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
226871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
226881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
226891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
226901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
226911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
226921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
226931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
226941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
226951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
226961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
226971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
226981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
226991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
227001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
227011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
227021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
227031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
227041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
227051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
227061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
227071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
227081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
227091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
22710ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
227111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22712f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
22713ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
227141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
227151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
227161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
227171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
227181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
227191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22720ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
227211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
227221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
227241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
227251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
227281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
227291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
227301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
227311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22732ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22733ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    mergeSymbols($Level);
22734ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(keys(%{$CheckedSymbols{$Level}})) {
22735ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        mergeConstants($Level);
227361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22737f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
22738f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Cache{"mergeTypes"} = (); # free memory
22739f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
227401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
227411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
227421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
227431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
227441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
227451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
227461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
227471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
22748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22749447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
22750447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    foreach my $S (keys(%{$CompatProblems{$Level}}))
22751447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    {
22752447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $K (keys(%{$CompatProblems{$Level}{$S}}))
22753447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        {
22754447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            foreach my $L (keys(%{$CompatProblems{$Level}{$S}{$K}}))
22755447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            {
22756447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                if(my $T = $CompatProblems{$Level}{$S}{$K}{$L}{"Type_Name"}) {
22757447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                    $TypeProblemsIndex{$Level}{$T}{$S} = 1;
22758447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                }
22759447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
22760447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
22761447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    }
22762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
227649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
227809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
2278181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko    "CppCompat"=>$CppCompat,
227829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
227839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
227849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2278974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
228001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22802dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22803dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22804dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22805dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
228201fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
22821e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22822e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22823e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
228245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
228255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2282674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
228275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
228285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
228295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
228301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
228311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
228321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
228335e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        if(not $CmpSystems)
228345e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        {
228355e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $BinaryOnly = 0;
228365e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $SourceOnly = 0;
228375e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        }
228385e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
228391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
228401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
228415e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
228421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
228431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
228441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
228451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
228461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
228471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
228481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
228491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
228501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
228511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
228521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
228531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
228541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
228551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
228565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
228571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
228601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
228611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
228625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
228641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
228651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
228661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
228671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
228681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
228691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
228701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
228711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
228775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
228785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
228795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
228805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
228815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
228825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
228835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
228845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
228855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
228865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
228875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
228885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2288901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
228905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
228915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
228984b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22899570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22900570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
229058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
229068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
229078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
229088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22909570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22910570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22914ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if($InfoMsg)
22915ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
22916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22919570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22920570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2292181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        printMsg("INFO", "ABI Compliance Checker (ABICC) $TOOL_VERSION\nCopyright (C) 2016 Andrey Ponomarenko's ABI Laboratory\nLicense: LGPL or GPL <http://www.gnu.org/licenses/>\nThis program is free software: you can redistribute it and/or modify it.\n\nWritten by Andrey Ponomarenko.");
22922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22924570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22925570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22944989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2294562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2294662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2294762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2294862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2294962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22950989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2295681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath)))
2295781b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        {
2295881b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            if($OSgroup eq "windows") {
2295981b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                $TargetLibs{lc($Lib)} = 1;
2296081b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
2296181b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            else {
2296281b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko                $TargetLibs{$Lib} = 1;
2296381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            }
22964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
229731fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{1}{get_filename($Header)} = 1;
229741fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{2}{get_filename($Header)} = 1;
22975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
229791fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{1}{get_filename($TargetHeader)} = 1;
229801fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{2}{get_filename($TargetHeader)} = 1;
22981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22987f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
229880f946a4a86e5a831a9301cea7cd0305ac9afd1bfAndrey Ponomarenko        $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly, $OldStyle);
22989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
2299381b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        if(-d $MODULES_DIR."/Targets/"
2299481b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        and -d $MODULES_DIR."/Targets/".$OStarget) {
2299581b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko            $TargetSysInfo = $MODULES_DIR."/Targets/".$OStarget;
2299681b09e8848c6646369681f534e7157f87533612fAndrey Ponomarenko        }
2299752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not $TargetSysInfo) {
2299852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Error", "-sysinfo option should be specified to dump system ABI");
2299952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2300052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2300152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -d $TargetSysInfo) {
2300252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$TargetSysInfo\'");
2300352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2300452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
23005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
230069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
23007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
23008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
23009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
23010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23011e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
23012e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $SDesc = readFile($DumpSystem);
23013e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            if(my $RelDir = $RelativeDirectory{1}) {
23014e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko                $SDesc =~ s/{RELPATH}/$RelDir/g;
23015e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            }
23016e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
23017e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $Ret = readSystemDescriptor($SDesc);
230189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
230199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
23020570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
23021570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
23022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
23024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
23025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
23028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
23029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
23030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
23031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
23032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
23033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
23035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
23036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
23038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
23039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
23041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
23042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
23043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
23044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
23045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
23046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
23047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
23048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
23049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
23050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
23051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
23052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
23053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
23055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
23056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
23058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
23059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
23060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
23061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
23062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
230639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
23064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
23065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23066447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
23068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
23069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
23070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
230719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
23072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
23073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23074447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23075447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    if(not $CountSymbols)
23076447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    {
23077447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not $TargetLibraryName) {
23078447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            exitStatus("Error", "library name is not selected (-l option)");
23079447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
23080447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        else
23081447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        { # validate library name
23082447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if($TargetLibraryName=~/[\*\/\\]/) {
23083447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
23084447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23087447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
2308814b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko    if(not $TargetTitle) {
2308914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $TargetTitle = $TargetLibraryName;
23090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23091ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
23092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
23093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
23094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
23095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
23096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
23098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
23099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2310152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($TypesListPath)
2310252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
2310352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -f $TypesListPath) {
2310452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TypesListPath\'");
2310552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2310652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($TypesListPath))) {
2310752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $TypesList{$Type} = 1;
2310852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2310952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
23110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
23111fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
23112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
23113fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
23114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
23115a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath)))
23116a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        {
23117a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{1}{$Interface} = 1;
23118a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{2}{$Interface} = 1;
23119fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
23120fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
2312199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($SkipTypesListPath)
2312299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    {
2312399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(not -f $SkipTypesListPath) {
2312499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipTypesListPath\'");
2312599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2312699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($SkipTypesListPath)))
2312799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2312899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{1}{$Type} = 1;
2312999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{2}{$Type} = 1;
2313099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2313199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
23132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
23133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
23134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
23135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
23136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
231381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
231391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
231401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
23141b3118d9752afef5233235b4f95359357b2e72432Andrey Ponomarenko
23142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
23143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
23144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
23145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
23148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
23149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
23150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
23151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
23153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
23154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
23155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
23156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2315762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2315862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
23159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
23160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
23161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
23162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2316362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2316462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
23165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
23166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
23167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
23168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
23169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
23170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
23171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23173447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
23175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
23176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
23177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
23178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23179ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
23180ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        detect_default_paths("bin|gcc");
231811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
23182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
23183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23185447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23186447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    if($CountSymbols)
23187447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    {
23188447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        if(not -e $CountSymbols) {
23189447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            exitStatus("Access_Error", "can't access \'$CountSymbols\'");
23190447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
23191447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23192447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        read_ABI_Dump(1, $CountSymbols);
23193447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23194447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $Id (keys(%{$SymbolInfo{1}}))
23195447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        {
23196447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            my $MnglName = $SymbolInfo{1}{$Id}{"MnglName"};
23197447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if(not $MnglName) {
23198447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $MnglName = $SymbolInfo{1}{$Id}{"ShortName"}
23199447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23200447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23201447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if(my $SV = $SymVer{1}{$MnglName}) {
23202447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $CompleteSignature{1}{$SV} = $SymbolInfo{1}{$Id};
23203447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23204447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            else {
23205447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $CompleteSignature{1}{$MnglName} = $SymbolInfo{1}{$Id};
23206447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23207447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23208447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if(my $Alias = $CompleteSignature{1}{$MnglName}{"Alias"}) {
23209447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                $CompleteSignature{1}{$Alias} = $SymbolInfo{1}{$Id};
23210447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23211447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
23212447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23213447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        my $Count = 0;
23214447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
23215447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        {
23216447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
23217447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                next;
23218447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23219447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Private"}) {
23220447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                next;
23221447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23222447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
23223447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko                next;
23224447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            }
23225447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23226447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko            $Count += symbolFilter($Symbol, 1, "Affected + InlineVirt", "Binary");
23227447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        }
23228447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23229447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        printMsg("INFO", $Count);
23230447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko        exit(0);
23231447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko    }
23232447e7d5ea2291eb53e44578e7062edfa3db7082fAndrey Ponomarenko
23233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
23234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
23235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
23236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
23237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
23238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
23239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
23240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
23241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
232421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
232431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
232441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
232451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
232461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
232471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
232481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
232491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
232501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
232511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
232521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
232531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
23254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
23255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
23256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
23257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
23258