abi-compliance-checker.pl revision 1b597c3d39a3d4c9ae37f618a0db277021d56c95
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
31b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko# ABI Compliance Checker (ABICC) 1.99.14.1
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
98bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko# Copyright (C) 2012-2015 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)
24ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
25ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Mac OS X
26570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko#    - Xcode (g++, c++filt, otool, nm)
27f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
28ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
29ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  MS Windows
30c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - MinGW (3.0-4.7, 4.8.3, 4.9 or newer)
31ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - MS Visual C++ (dumpbin, undname, cl)
32850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Active Perl 5 (5.8 or newer)
33ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Sigcheck v1.71 or newer
34ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Info-ZIP 3.0 (zip, unzip)
35f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
3674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#    - Add tool locations to the PATH environment variable
37ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Run vsvars32.bat (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
38ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
39ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko# COMPATIBILITY
40ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko# =============
4199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko#  ABI Dumper >= 0.99.12
42ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko#
43ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko#
44ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is free software: you can redistribute it and/or modify
45ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# it under the terms of the GNU General Public License or the GNU Lesser
46ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# General Public License as published by the Free Software Foundation.
47ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
48ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is distributed in the hope that it will be useful,
49ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# but WITHOUT ANY WARRANTY; without even the implied warranty of
50ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# GNU General Public License for more details.
52ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
53ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# You should have received a copy of the GNU General Public License
54ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# and the GNU Lesser General Public License along with this program.
55ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# If not, see <http://www.gnu.org/licenses/>.
56ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
57ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Getopt::Long;
58ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetopt::Long::Configure ("posix_default", "no_ignore_case");
59ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Path qw(mkpath rmtree);
60ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Temp qw(tempdir);
61ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Copy qw(copy move);
6274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkouse Cwd qw(abs_path cwd realpath);
63177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkouse Storable qw(dclone);
64ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Data::Dumper;
652fba63087b6e973c04b6d235fe10363657985263Andrey Ponomarenkouse Config;
66ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
671b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenkomy $TOOL_VERSION = "1.99.14.1";
68177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ABI_DUMP_VERSION = "3.2";
69d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenkomy $XML_REPORT_VERSION = "1.2";
70f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy $XML_ABI_DUMP_VERSION = "1.2";
71ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OSgroup = get_OSgroup();
72ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ORIG_DIR = cwd();
73ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TMP_DIR = tempdir(CLEANUP=>1);
746fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenkomy $LOCALE = "C.UTF-8";
75ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
76ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Internal modules
77ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MODULES_DIR = get_Modules();
78ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkopush(@INC, get_dirname($MODULES_DIR));
79ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Rules DB
80ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RULES_PATH = (
81ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Binary" => $MODULES_DIR."/RulesBin.xml",
82ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Source" => $MODULES_DIR."/RulesSrc.xml");
83ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8414b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenkomy ($Help, $ShowVersion, %Descriptor, $TargetLibraryName,
85ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TestTool, $DumpAPI, $SymbolsListPath, $CheckHeadersOnly_Opt, $UseDumps,
86ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko$AppPath, $StrictCompat, $DumpVersion, $ParamNamesPath,
8714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko%RelativeDirectory, $TargetTitle, $TestDump, $LoggingPath,
886ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko%TargetVersion, $InfoMsg, $CrossGcc, %OutputLogPath,
89ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$OutputReportPath, $OutputDumpPath, $ShowRetVal, $SystemRoot_Opt, $DumpSystem,
90ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$CmpSystems, $TargetLibsPath, $Debug, $CrossPrefix, $UseStaticLibs, $NoStdInc,
91ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TargetComponent_Opt, $TargetSysInfo, $TargetHeader, $ExtendedCheck, $Quiet,
9207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko$SkipHeadersPath, $CppCompat, $LogMode, $StdOut, $ListAffected, $ReportFormat,
931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko$UserLang, $TargetHeadersPath, $BinaryOnly, $SourceOnly, $BinaryReportPath,
9452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko$SourceReportPath, $UseXML, $SortDump, $DumpFormat,
95177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko$ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath,
961fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$CheckInfo, $Quick, $AffectLimit, $AllAffected, $CppIncompat,
971fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$SkipInternalSymbols, $SkipInternalTypes, $TargetArch, $GccOptions,
9899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko$TypesListPath, $SkipTypesListPath);
99ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CmdName = get_filename($0);
101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_LibExt = (
102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic" => {
1039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"so",
104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "macos"=>"dylib",
105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"dll",
1069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"dso",
1079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"so"
108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static" => {
1109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"a",
111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"lib",
1129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"lib",
1139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"a"
114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_Archive = (
118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"zip",
119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"tar.gz"
120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ERROR_CODE = (
123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Compatible verdict
124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compatible"=>0,
125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Success"=>0,
126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible verdict
127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Incompatible"=>1,
128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Undifferentiated error code
129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Error"=>2,
130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # System command is not found
131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Not_Found"=>3,
132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot access input files
133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Access_Error"=>4,
134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot compile header files
135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Cannot_Compile"=>5,
136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Header compiled with errors
137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compile_Error"=>6,
138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Invalid input ABI dump
139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Invalid_Dump"=>7,
140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible version of ABI dump
141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Dump_Version"=>8,
142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot find a module
143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Module_Error"=>9,
144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty intersection between
145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # headers and shared objects
146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Intersection"=>10,
147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty set of symbols in headers
148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Set"=>11
149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
151ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkomy $HomePage = "http://lvc.github.io/abi-compliance-checker/";
152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
153b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenkomy $ShortUsage = "ABI Compliance Checker (ABICC) $TOOL_VERSION
1541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey PonomarenkoA tool for checking backward compatibility of a C/C++ library API
15552b2e35f3dfda9369631beeb5d5480df65c47950Andrey PonomarenkoCopyright (C) 2015 Andrey Ponomarenko's ABI Laboratory
156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoLicense: GNU LGPL or GNU GPL
157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUsage: $CmdName [options]
159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey PonomarenkoExample: $CmdName -lib NAME -old OLD.xml -new NEW.xml
160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOLD.xml and NEW.xml are XML-descriptors:
162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/headers/
169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/libraries/
173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMore info: $CmdName --help\n";
176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkoif($#ARGV==-1)
178570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $ShortUsage);
180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit(0);
181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetOptions("h|help!" => \$Help,
184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "i|info!" => \$InfoMsg,
185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v|version!" => \$ShowVersion,
186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dumpversion!" => \$DumpVersion,
187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# general options
188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l|lib|library=s" => \$TargetLibraryName,
189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d1|old|o=s" => \$Descriptor{1}{"Path"},
190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d2|new|n=s" => \$Descriptor{2}{"Path"},
191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump|dump-abi|dump_abi=s" => \$DumpAPI,
192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# extra options
193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "app|application=s" => \$AppPath,
194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "static-libs!" => \$UseStaticLibs,
195d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-path|cross-gcc=s" => \$CrossGcc,
196d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-prefix|cross-prefix=s" => \$CrossPrefix,
197d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-options=s" => \$GccOptions,
198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysroot=s" => \$SystemRoot_Opt,
19915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v1|vnum1|version1|vnum=s" => \$TargetVersion{1},
20015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v2|vnum2|version2=s" => \$TargetVersion{2},
201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "s|strict!" => \$StrictCompat,
202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "symbols-list=s" => \$SymbolsListPath,
20352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  "types-list=s" => \$TypesListPath,
204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "skip-symbols=s" => \$SkipSymbolsListPath,
20599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  "skip-types=s" => \$SkipTypesListPath,
206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "headers-list=s" => \$TargetHeadersPath,
207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "skip-headers=s" => \$SkipHeadersPath,
208fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "header=s" => \$TargetHeader,
209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "headers-only|headers_only!" => \$CheckHeadersOnly_Opt,
210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "show-retval!" => \$ShowRetVal,
211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "use-dumps!" => \$UseDumps,
212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "nostdinc!" => \$NoStdInc,
213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-system=s" => \$DumpSystem,
214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysinfo=s" => \$TargetSysInfo,
215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "cmp-systems!" => \$CmpSystems,
216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "libs-list=s" => \$TargetLibsPath,
217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "ext|extended!" => \$ExtendedCheck,
218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "q|quiet!" => \$Quiet,
219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "stdout!" => \$StdOut,
220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-format=s" => \$ReportFormat,
2215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko  "dump-format=s" => \$DumpFormat,
2221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "xml!" => \$UseXML,
223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "lang=s" => \$UserLang,
22454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  "arch=s" => \$TargetArch,
2251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "binary|bin|abi!" => \$BinaryOnly,
2261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "source|src|api!" => \$SourceOnly,
2272489ef88760861175102e4508089608391beead3Andrey Ponomarenko  "limit-affected|affected-limit=s" => \$AffectLimit,
228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
23207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
2332b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  "cpp-incompatible!" => \$CppIncompat,
234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
23862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
24714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  "title|l-full|lib-full=s" => \$TargetTitle,
2481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
249570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
250570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
253177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
254e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "quick!" => \$Quick,
256d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  "all-affected!" => \$AllAffected,
2571fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-symbols|skip-internal=s" => \$SkipInternalSymbols,
2581fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-types=s" => \$SkipInternalTypes,
259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko) or ERR_MESSAGE();
260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ERR_MESSAGE()
262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "\n".$ShortUsage);
264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{"Error"});
265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_TYPE = $UseStaticLibs?"static":"dynamic";
268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLIB_TYPE = $LIB_TYPE;
269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoif($OSgroup!~/macos|windows/ and $SLIB_TYPE eq "dynamic")
270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # show as "shared" library
271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SLIB_TYPE = "shared";
272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_EXT = getLIB_EXT($OSgroup);
274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $AR_EXT = getAR_EXT($OSgroup);
275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $BYTE_SIZE = 8;
276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMMON_LOG_PATH = "logs/run.log";
277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HelpMessage="
279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoNAME:
280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  ABI Compliance Checker ($CmdName)
2810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  Check backward compatibility of a C/C++ library API
282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoDESCRIPTION:
284b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko  ABI Compliance Checker (ABICC) is a tool for checking backward binary and
2851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  source-level compatibility of a $SLIB_TYPE C/C++ library. The tool checks
2861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  header files and $SLIB_TYPE libraries (*.$LIB_EXT) of old and new versions and
2871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  analyzes changes in API and ABI (ABI=API+compiler ABI) that may break binary
2881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  and/or source-level compatibility: changes in calling stack, v-table changes,
2891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  removed symbols, renamed fields, etc. Binary incompatibility may result in
2901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  crashing or incorrect behavior of applications built with an old version of
2911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  a library if they run on a new one. Source incompatibility may result in
2921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  recompilation errors with a new library version.
293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
294dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  The tool is intended for developers of software libraries and maintainers
295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  of operating systems who are interested in ensuring backward compatibility,
296dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  i.e. allow old applications to run or to be recompiled with newer library
297dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  versions.
298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  Also the tool can be used by ISVs for checking applications portability to
300dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  new library versions. Found issues can be taken into account when adapting
301dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  the application to a new library version.
302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  This tool is free software: you can redistribute it and/or modify it
304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  under the terms of the GNU LGPL or GNU GPL.
305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUSAGE:
307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  $CmdName [options]
308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXAMPLE:
3100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  $CmdName -lib NAME -old OLD.xml -new NEW.xml
311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  OLD.xml and NEW.xml are XML-descriptors:
313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/header(s)/
320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/header(s)/
321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/library(ies)/
326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/library(ies)/
327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoINFORMATION OPTIONS:
331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -h|-help
332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print this help.
333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -i|-info
335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print complete info.
336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -v|-version
338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print version information.
339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -dumpversion
341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print the tool version ($TOOL_VERSION) and don't do anything else.
342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGENERAL OPTIONS:
34407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l|-lib|-library NAME
345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Library name (without version).
346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d1|-old|-o PATH
348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 1st (old) library version.
349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      It may be one of the following:
350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         1. XML-descriptor (VERSION.xml file):
352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <version>
354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  1.0
355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </version>
356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <headers>
358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/header(s)/
359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/header(s)/
360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </headers>
362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <libs>
364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/library(ies)/
365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/library(ies)/
366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </libs>
368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
36901e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko                 ...
370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         2. ABI dump generated by -dump option
372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         3. Directory with headers and/or $SLIB_TYPE libraries
373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         4. Single header file
374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
37501e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko      If you are using an 2-4 descriptor types then you should
376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      specify version numbers with -v1 and -v2 options too.
377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      For more information, please see:
3791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        http://ispras.linuxbase.org/index.php/Library_Descriptor
380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
38107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d2|-new|-n PATH
382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 2nd (new) library version.
383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
38407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump|-dump-abi PATH
385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create library ABI dump for the input XML descriptor. You can
386570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      transfer it anywhere and pass instead of the descriptor. Also
387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      it can be used for debugging the tool.
388570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
3896ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko      Supported versions of ABI dump: 2.0<=V<=$ABI_DUMP_VERSION\n";
390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub HELP_MESSAGE() {
392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $HelpMessage."
393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFO:
394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko     $CmdName --info\n");
395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub INFO_MESSAGE()
398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "$HelpMessage
400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXTRA OPTIONS:
40107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -app|-application PATH
40252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify the application that should be checked
403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for portability to the new library version.
404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -static-libs
406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check static libraries instead of the shared ones. The <libs> section
407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the XML-descriptor should point to static libraries location.
408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4098bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-path PATH
410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to the cross GCC compiler to use instead of the usual (host) GCC.
411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4128bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-prefix PREFIX
413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      GCC toolchain prefix.
4148bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko
4158bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-options OPTS
4168bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko      Additional compiler options.
417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
41807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysroot DIR
419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify the alternative root directory. The tool will search for include
42007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      paths in the DIR/usr/include and DIR/usr/lib directories.
421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v1|-version1 NUM
423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 1st library version outside the descriptor. This option is needed
424bd1767ac0e8d4a913683bf84e6305bed1850a427Mathieu Malaterre      if you have preferred an alternative descriptor type (see -d1 option).
425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      In general case you should specify it in the XML-descriptor:
427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <version>
428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              VERSION
429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </version>
430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v2|-version2 NUM
432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 2nd library version outside the descriptor.
433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
434c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko  -vnum NUM
435c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      Specify the library version in the generated ABI dump. The <version> section
436c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      of the input XML descriptor will be overwritten in this case.
437c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko
438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -s|-strict
439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Treat all compatibility warnings as problems. Add a number of \"Low\"
440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      severity problems to the return value of the tool.
441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -headers-only
443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check header files without $SLIB_TYPE libraries. It is easy to run, but may
444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without detecting of added/removed symbols.
446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <libs> section
448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -show-retval
454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Show the symbol's return type in the report.
455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
45607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -symbols-list PATH
45752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of symbols (mangled
45852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      names in C++) that should be checked. Other symbols will not be checked.
45952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
46052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  -types-list PATH
46152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of types that should
46252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      be checked. Other types will not be checked.
463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -skip-symbols PATH
46599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of symbols that should not be checked.
46699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
46799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  -skip-types PATH
46899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of types that should not be checked.
469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
47307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
484570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
48707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
49407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
54752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option should be used with -dump-system option to dump
54852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      ABI of operating systems and configure the dumping process.
54952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      You can find a sample in the package:
550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          modules/Targets/{unix, symbian, windows}
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.
6191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
62452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
63207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
63707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
63807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
63907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
6402b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
6412b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  -cpp-incompatible
6422b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko      Set this option if input C header files use C++ keywords.
643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
64407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
65407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
65807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
66107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6645c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
66607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
66962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
67062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
67107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
67407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
67607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
6771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
67907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
6821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
6831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
68407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
6851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
68607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
70107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
72152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
72214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  -title NAME
72307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
72507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
72607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
72707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
729570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
731570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
732570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
733570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
734570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
7438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          3 - skip headers that iclude non-Linux headers
7448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
748177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
749177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
750177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
751e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
752e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
753e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
754d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
7551fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-symbols PATTERN
7561fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check symbols matched by the pattern.
7571fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
7581fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-types PATTERN
7591fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check types matched by the pattern.
76062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
76307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
76607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
76707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
774ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    ".$HomePage."\n");
775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
82762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
82862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
82962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
83062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
83162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
83262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
83362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
83462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
83562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
83662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
83762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
83862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
83962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
84062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
84162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
842177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
84362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
84462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
84562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
84662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
84762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
84862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
84962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
85062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
85162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
85262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
85662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
85762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
85862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
85962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
86062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
86162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
8628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
8638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
86462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
86562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
9288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
9298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
979e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
983f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $EMERGENCY_MODE_48 = 0;
98407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
1000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
1001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
1002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
1003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
1004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
1005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
1006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
1007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
1008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
104562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
104662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
104762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
104862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
104962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
105062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
105162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
105262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
105362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
105462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
105562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
105662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
105762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
105862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
105962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
106062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
106162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
106262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
106362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
106462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
106562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
106662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
11119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
11349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
11359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
11369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
11379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
11389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
11399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
11409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
11419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
11429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
11439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
11459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
11469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
11479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
11489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
115074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
115174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
115274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
115374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
115474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
115574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
115674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
115774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
115874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
115974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
116074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
116174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
116274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
116374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
116474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
116574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
116674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
11679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
11689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
11699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
11709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
11719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
11729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
11739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
11749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1185570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1189570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1191570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1200570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1202570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
12289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
12299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
12309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
12358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
1238570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1239570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
124015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenkomy $TargetComponent = undef;
1241dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1242dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1243dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1244dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy $TOP_REF = "<a class='top_ref' href='#Top'>to the top</a>";
12511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
12551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
126882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
127174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
127274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
127374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1274177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1277177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1279177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1280177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1281177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1282177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
12931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
12991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
13024b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
130362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1305177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1306177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
131362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
131462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
13159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1328a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1329a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1330a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
133252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy %TypesList;
1333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
133562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
133662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
133762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
133862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
133962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
134062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
134162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
134262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
134362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
134462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
13489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
135062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
135107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1352fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1353fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1356570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1357570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
135874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1361570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1362570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1365fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
13828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1393f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
13949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
13959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
139707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
140601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
140701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
140801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
14119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
141207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
14139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
14149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1416d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkomy %CheckedArch;
1417d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1420570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
14219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1425570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
14441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
144562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
14481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
14491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
14501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1451f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $CurrentSymbol; # for debugging
1452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1453f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1454f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1461f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
14626fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Filters
1463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14666fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Format of objects
1467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Compliance Report
1471dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Type_MaxSeverity;
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
14768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1482570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1483570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1484570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1485570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
14968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
1497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"section_affected\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"section_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
15101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
15111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15132489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy %Severity_Val=(
15142489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "High"=>3,
15152489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Medium"=>2,
15162489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Low"=>1,
15172489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Safe"=>-1
15182489ef88760861175102e4508089608391beead3Andrey Ponomarenko);
15192489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
153274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
153374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
154901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
155301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
155401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
155501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
156101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
15740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1576dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1577dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1578dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1579dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1580dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1581dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1582dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
160874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
160974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
161374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
163362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
165162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
165262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
16731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
16791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
16881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
170974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
171362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
172362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
172462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
172562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
172762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
172862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
172962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
173062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
173162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
173262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1735a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
173662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
174062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1742570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
174362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
174562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
174662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1747a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
174862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
174962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1751570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
175474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/[\*\[]/)
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # wildcard
1765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\*/.*/g;
1766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\\\\/g;
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
17875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1791570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1811ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $DHeaders = parseTag(\$Content, "headers");
1812ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $DHeaders) {
1813ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1814ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
1815ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    elsif(lc($DHeaders) ne "none")
1816ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # append the descriptor headers list
1817ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Headers"})
1818ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # multiple descriptors
1819ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1821ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
1822ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1823ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
1824ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1825ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
1826ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not -e $Path) {
1827ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$Path\'");
1828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1831ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
1846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
1848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
1856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1862570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
1863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
1865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1871570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
1872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
1874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
1881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
1882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
1884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
1885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1886570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
1887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
1888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1894570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
1895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1896570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
1897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_include_paths")))
1898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1904570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"AddIncludePaths"}}, $Path);
1905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
19078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
19088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
19098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
19108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
19118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
19128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
19138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
1914570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
1915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
19178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
1918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
1920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
192274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
192374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
19248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
19258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
192674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
192774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
1930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
1931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
1933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
1935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
1938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
1943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
1945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
1946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
1947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
1953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
1959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
19601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
1964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
19651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
1966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
1967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
1969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1971a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
1972a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
1973a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
1974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
1975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
1976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
19801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
1982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
1985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
198901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
1990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
199101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
199201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
199301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
199401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
199501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
199601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
199701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
199801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
199901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
200001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
200101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
2002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
200301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
200401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
200501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
200601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
200701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
200801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
200901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
201001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
201101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
201201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
201301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
201401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
201501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
201601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
201701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
201801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
201901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
202101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
202201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
202301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2026850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2027850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2028850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2029850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
20334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
203474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
20354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
20364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
20374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
204082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
204201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2050850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2051850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2052850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
20544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2055850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
205662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
205762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
205862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
205962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
206074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2061570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
206374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
206474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
206574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2066570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2067570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2070570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2081177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2082177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2083570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
208462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
208562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2091850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2092850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2093850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2094850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2095850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2096850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2097850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2098850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2099850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2100850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2101850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2102850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2103d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Lines = split(/\n/, $Content);
2104850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2105850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2106850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2107850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2108177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2109850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2110850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2111850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
211262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
2116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3;
2117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2125850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2126850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
212782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
212882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
212982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
213082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2131fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2132fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2133fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2134fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2136fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
213782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
213882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
213982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
214082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2145f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2146f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2147f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2148f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2149f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2150f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2151f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2152f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2153f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2154f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2155f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2156f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2157f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2158f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2159f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2160f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2161f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2162f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2163f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2164f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2167b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2169b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
217062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
217162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
217262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
217362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
217462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
217562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
217662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2177f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
217862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
217962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
218062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
218162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
218262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
218362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2184f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2186f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2187f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2188f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2189850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2190f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2192f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2193f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2194f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2195f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
21969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2197f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2198f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2199850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2203b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2204b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22084b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
22094b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
22104b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
22114b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
22124b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
22134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
22144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
22154b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
22164b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
22174b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
22184b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
22194b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
22204b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2234989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2236989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
223862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2239177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
224062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2241177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2242177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2243177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2244177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2245177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2246177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2247177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2248177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2249177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2250177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2251177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2252177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2253177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2254177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2255177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2256177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2257177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2258177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2259177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2260177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2261177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2262177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2263177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2264177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2265177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2266177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2267177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2268989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
227162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2273850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2274850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2275850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2277850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2279850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2282177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2284177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2285177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2286177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2288989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2290989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2298989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2299989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2300989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2301989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2302989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2303177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2304177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2305989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2306989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2307850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2308850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
230962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2310177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2311989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
231462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2315177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2316989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
232462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2325dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
232662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
232762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
232862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
232962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
233262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
233362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2334dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
233662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
234162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
234862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
23500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
235462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
235762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
235862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
235901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
236062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
236162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
236201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
236362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
236401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
236562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
236662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2370177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2371177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2372177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2373177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2374177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2375177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2376177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2377177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2378177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2379177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2380177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2381177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2382177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2383177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2384177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2385177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2386177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2387177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2389177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2390177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2391177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2392177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2393177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
23991b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        if($NBid ne $Bid
24001b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        and $NBid ne $Tid)
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2408177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2409177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2410177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2412177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2415177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2417082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2419e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2421177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2423177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2427be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2428be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2429be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2430be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2450e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2458e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2480177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2496e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2497e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2500177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2506e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2507e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2509e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2511e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
25151b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($NBid ne $Bid
25161b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                and $NBid ne $New)
2517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2518e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2519e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2524e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2526be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2527be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2528be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2529be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2530be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2534e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2536e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2537e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2541e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2542e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2545e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
255162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
255662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
255862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
257162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2575b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
257662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
257862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2584b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2585b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2586b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2597b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2601b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
260562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
260762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2609b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2613b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2616b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2620b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2625b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2626b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2627b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
263062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2631b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2633b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2634b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2635b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2636b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
264362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
264462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
264562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
264662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
264762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
264862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
264962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
265362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2655b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2656b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2657b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2659b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
266662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
266862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
266962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
267062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
267262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
267362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
267462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
267562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
267662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
267862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
268062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
268562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
268662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
268762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
268862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
269062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
269162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
269262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
269362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
269662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
269762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
269862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
269962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
270062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
270162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
270262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
270362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
270462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
270562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
270662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
270762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
270862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
271062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
271162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
271462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
271762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
271962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
27200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
272162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
272262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
272362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
272462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
272662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
272762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
272862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
272962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
273062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
273162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
273262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
273462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
273562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
273662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
273762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
273862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
273962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
274062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2741177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2742177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2743177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2744177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2745177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2746177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
274762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
274862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
274962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
275062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
275162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
275262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
275362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
275462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2755177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2756177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2757177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2758177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2759177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2760177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2761177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2762177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
276862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2769989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2770989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
277162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2772989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2773989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2774989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2775989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2776989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2777989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
278162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
278262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
27830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
27840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2785f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2786f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2787f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
278962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
279162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
279262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
279362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
27940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2795989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
279662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
279762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
279862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
27990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2800989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2801989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2802989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2804989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2806989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2807989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2808989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
28090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2810989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2811989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2812989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2814989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
28169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
28170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
28180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
282062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2821989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2822989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2826177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
282862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
28290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
28300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
283162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2832177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2833177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2834177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
28350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
28360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
28370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
28380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
28390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
28400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
28410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
28420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
28430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
2847177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2848177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
2849177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2850177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2851177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2852177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
2853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
2862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
2864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
2865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
2866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
2876989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
287762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
287862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
28790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
288262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
2883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
288462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
2885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
288662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
2887fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
288862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2891fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
28920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
289362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
2894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
2897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
2898fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
289962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
2900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
2901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
2904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
29060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
2907989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
29080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
2909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
2910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
29120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
2913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
29160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
2917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
2919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
292174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
292274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
292374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
292474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
292574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
2927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
2928850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
2929850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
29308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
29318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
29328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
29338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
29348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
29358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
2936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
2937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
2939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
2940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
2941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
2942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
2943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
2946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
2948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
2949989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2950989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
2951989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
2952989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
29530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
29540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
2955989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
2956989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
2957989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
29580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
2960989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
29610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
2962989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
29630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
2964989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
2965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
2966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
2967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
29710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
2972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
29730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
29740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
29750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
29760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
29770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
29780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
29790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
29800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
2982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
2986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
2988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
2990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
2991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
29930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
2994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2996f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2997f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2998f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
29999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
30000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
30010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
3002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
300362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
30040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
3005989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
3006989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
3007989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3008989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3009989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
301562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
301662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
301762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
301862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
301962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
302062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
302162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
302262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
302362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
302462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
302562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
302662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
302762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
303162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
303262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
303362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
303462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
303662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3037b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
304062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
304362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
304662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
304762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
304962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
305062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
305162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
305262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
305362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
305462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
305562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
305662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
305762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
305862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
305962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
306762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3068b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3069b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
307062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3072b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3073b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3074b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
30791477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
308662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
308862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3102f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3106f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3107f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3108f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3109f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3110f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
31129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
311862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3124dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
312662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3133dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3134dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
313562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3151dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
315401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
315501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
315601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
315701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
315801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
315901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
316001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
316101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
316201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3163dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
316862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
317062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
317762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
318001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
318101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
318201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
318301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
318462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3186f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3187f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3188f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
319262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3193989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3194989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3195989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
320362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
320462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
320562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
320662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3207989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
321662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3234989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
323501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3236989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3239989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
324162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
324262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3243989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3244989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3245989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3246989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3247989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3248989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
325062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3251989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
325201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3253989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3254989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
325562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
325662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3257989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3258989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3259989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3260989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3261989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3262989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3263989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
32750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
32760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
32780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
32800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
32810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
32820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
32830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
32840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
32914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
32920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
32930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
32980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
33000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
33050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
33060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
33090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
33120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
33130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
33200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
33260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
33270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
33350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
33390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
33470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
33510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
33550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
33580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
33600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
33610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
33630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
33640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
33670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
33680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
33700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
33710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
33730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
33740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
33760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
338274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
338374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
338474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
338574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
338674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
338774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
338874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3392dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3393dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3395dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3396dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3397dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3398dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3399dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3400dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3401dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3402dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3403dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
34090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
34110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
34120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
34140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
341662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
34170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
341862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
341962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
342062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
34210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
342262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
342362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
342462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
34250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
34299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
34300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
343162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
34320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
343362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
343462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
34350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
34360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
34380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
34390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
34400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
34439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
34449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
34459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
34469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
34480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
34490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
34510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
34520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
34530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
34540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
34560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
345862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
345962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
346162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3468e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3469e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3470e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3471e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3472e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3473e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3474e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3475e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3476e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
347862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
347962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
348062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
348162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
348262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
348362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
348562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
348662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
348762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
348862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
348962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
349062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
349462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
349562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
349662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
349762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3498dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
350062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
350162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
35020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
350362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
350462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
350562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
350662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
350762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
350962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
351162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
35140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
351562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
352062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
352662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
353262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
354462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
359262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3598dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
360401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3605dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3606dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3607dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3608dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3609dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
361762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3623850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3627f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3628f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3629f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3630f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3631f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3632f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3633f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3634f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
36369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
36430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
36460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
36470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
36480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
36490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
36500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
365262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
36530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3654177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3655177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3656177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
36570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
36580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
36590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
366062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
366162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
36620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
36630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
36640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
366762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
366862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3669177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3670177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3671177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
367262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
367362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
367462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
367562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
367635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
367735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
367935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3681dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3683850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
36865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
36875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
36885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
36895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
36915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
36925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
36935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
36945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
36955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
36975c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
36985c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
36995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
37049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3723850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3724850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3725850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3726850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3728850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
373162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
373262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
373362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
373462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
373562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
373662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
373762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
373862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
37419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
374774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
374874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
374974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
375074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3753850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3754850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3755850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
375662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3757850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3758f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3760850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3771dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
377262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
37741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
37751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
37761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
377701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
37781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
37791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
37801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
37811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
37821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
37831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
37841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
37851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
37862956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
37871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
37881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
37891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3790177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
37911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
37921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
37931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
37941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
379501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
37961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
37971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
37981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
37991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38022956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
38071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3808dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3810dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3811dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3812dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3814b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3815b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3817b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type")) {
3818b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3819b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3820b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
3821b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."<...>", "T");
3822b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
382762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
382962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
383062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3831850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3832177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3833177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3834850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3835850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3836177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
383762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3838850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38462489ef88760861175102e4508089608391beead3Andrey Ponomarenko
384762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
3849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
3851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
3853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
3854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
38562489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Intrinsic")
38572489ef88760861175102e4508089608391beead3Andrey Ponomarenko    {
38582489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(defined $TypeAttr{"Header"})
38592489ef88760861175102e4508089608391beead3Andrey Ponomarenko        {
38602489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if($TypeAttr{"Header"}=~/\Adump[1-2]\.[ih]\Z/)
38612489ef88760861175102e4508089608391beead3Andrey Ponomarenko            { # support for SUSE 11.2
38622489ef88760861175102e4508089608391beead3Andrey Ponomarenko              # integer_type has srcp dump{1-2}.i
38632489ef88760861175102e4508089608391beead3Andrey Ponomarenko                delete($TypeAttr{"Header"});
38642489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
38652489ef88760861175102e4508089608391beead3Andrey Ponomarenko        }
38662489ef88760861175102e4508089608391beead3Andrey Ponomarenko    }
38672489ef88760861175102e4508089608391beead3Andrey Ponomarenko
3868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
3869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
387062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
38711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
3872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
3873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
387462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
38751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
3876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
3877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
3879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
3880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
3882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
3884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
3886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
3887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
3888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
3892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
3894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
3896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
3898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
3899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
3905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
3907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
3909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
3911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
3912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
3918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3919e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
3920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3921e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
3922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3923e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
3924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
3926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
3927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3928e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3929e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
3930e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
3931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
3932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
3933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
39361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
39371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
39381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
3939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
3941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
394201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
394301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
394401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
394501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
3946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
3948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
3950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
3952177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
3953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
3954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
3955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
39579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
395874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
396074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
3961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
3963850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
3964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
3966850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
3967850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
396862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
3969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
3970850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
3971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3973f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3974f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3975f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
397774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
397874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
397974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
398074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
3981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
398274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
398374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
398474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
398574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
398674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
398774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
398874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
3990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
3991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
3993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
3994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
3996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
3997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
3998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
400182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
400282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
400382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
400482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
400582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
400682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
400782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
400882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
40098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
401082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
40118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
401282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
401382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
40148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
40158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
40248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
402582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
402682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
402782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
402874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
40294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
40304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
40314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
40324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
40334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
403482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
406962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
40701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
40741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
407562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
407862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
408162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
409662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
409862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4100177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4108b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
41091b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            if($ClassId eq $TypeId)
4110b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            { # class A<N>:public A<N-1>
4111b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko                next;
4112b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            }
4113b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4118177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
41214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
41244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
412701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
41291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
41334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4136850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
4142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Info=~/type[ ]*:[ ]*@(\d+) /;
4143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $1;
4144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4175f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $PName = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"name"};
4176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
4178f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
4179f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($PName eq "this"
4180f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method")
4181f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
4182f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
4183f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
4184f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
418562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
418762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
420962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
422762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
422862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4236f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
42419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
42531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
42561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4262b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko{ # TODO
4263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
42711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
430107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
43021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
430335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
43041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
430535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
430635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
430735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
43081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
43091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
43101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
43111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
431207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
43221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
43231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
43241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
43261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
43271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
43281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
43291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
43471477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4359850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4360850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
43611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4395f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/C1([EI])/C2$1/;
4396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4401f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D0([EI])/D1$1/;
4402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4404f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D1([EI])/D2$1/;
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
441007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
44121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
44141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
44181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
44191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
44221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
44231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
44241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
44261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
44271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
44281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
44361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
447362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
447574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
447907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
448062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
45091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
451035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
45111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
451235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
451335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
451435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
45151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
45161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
45171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
45181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
451907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4655dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
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 = macro_mangle($Repl->{$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 delete_keywords($)
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
474162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
47529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
475862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
476062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
476162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
476262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
476862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
47769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
478262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
47839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4793989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4794989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4795989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4796989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4797989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4798989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4799989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4800989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4801989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4802989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4803989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
48070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
48120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
48140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
48158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
48168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
48170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
48188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
48198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
48200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
48218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
48228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
48230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
48240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
48250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
48280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
48290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
48350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
48360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
48410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
48430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
48440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
484562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
48460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
48470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
48480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
48500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
48520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
48530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
485401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
485501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
485601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
485701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
485801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
485901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
48600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
4865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
4866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4868989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
4869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4870989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
4871dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
4872989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
4873989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
4874989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
4875989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
4876989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
4877989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4878989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
4879989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
4880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4881dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
4882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
4885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
4886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
4887570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
4888fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
4889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
4890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
4893fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
4894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
4897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
4899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
4900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
4901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
4903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
4905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
4906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
4910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
4911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4912850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
4913850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
4914850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
4915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
4916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
4921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
4922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
4923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
492562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
4926f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"})
4927f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or $EMERGENCY_MODE_48)
4928f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
4929f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
4930f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.8 doesn't mangle anything
49311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
4932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
4934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
4935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
49371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
4938f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or not $BinaryOnly
4939f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or $EMERGENCY_MODE_48)
49401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
49411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
49421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
49431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
49441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
49451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
4946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
4951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
4953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
4954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
4955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
4959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
49601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
4961989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
4962989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
4963989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
49641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
49651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
4966a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
4967a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
49721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
4973a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
4974a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
497874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
49791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
4980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
498162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
4982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
4983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
4984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
498562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
498662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
498762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
4988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
498962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
499062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
499162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
499262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
499362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
499462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
499562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
499662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
499762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
4998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
50001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5002a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
5003a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
500474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
500574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
500674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
500774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
500874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
500974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
501074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5011a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5015a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5016a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5020a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5021a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5022a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
50231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
50501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
50521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
50531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
50541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
50551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5056b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(@TParams) {
5057b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".join(", ", @TParams).">";
5058b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
5059b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
5060b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<...>";
5061b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
50629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
50661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5068f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5069f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5070f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5071f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5072f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5073f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5074f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5075f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5076f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5077f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5078f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5079f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5080989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
50811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
50829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
50841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
50891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
509007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
509107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
50921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5101fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5102fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
510662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
510762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5108177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5109177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5110177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
511162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
511262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
511362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
511462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
511535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
511635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
51171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
511835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5120dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
51221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
51261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
51271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
51291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
51301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
51321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
51341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
51351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5140dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5142dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5152fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
51548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
51558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
51568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
51578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
51588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
51598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
51608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
51618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
51638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
51648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
51658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
51698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
51718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
51728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
51768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
51788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
51798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
51821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
51841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5187989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5188a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5189989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5190989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5191989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5192989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5193989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5194989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5195989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5196989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5197989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
52001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
520282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5203e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5204e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
52051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5209b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
521162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5214850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5215850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5216570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5217570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5218570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5223850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
52261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
52271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
52281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
52319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
52321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
52401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
52441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
52491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
52521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
52561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
52601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5264dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5265dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
52669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
52679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5268dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5269dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5270dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5271dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5273f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
52741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
52751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
52781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
528007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
528107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
528207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
528307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
528474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
528574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
528674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
528774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
528874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
528974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
529074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
529174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
529274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
529374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
529474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
529574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
529674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
529774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
529874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
529974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
530074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
530174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
530274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
530374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
530474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
530574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
530674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
530774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
530874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5323e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5324e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5325e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5326e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5327e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5328e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5329e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5330e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5331e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5332e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5333e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5336dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5337dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5338dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5339dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5340dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5342dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
53490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
535074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53534b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
53544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
53574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
535862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
53594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
53604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
53610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
53674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
53704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5371989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5372989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
537374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
537474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
537574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
537674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
537774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
537874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
53794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
53824b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
53841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
538901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
53914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
54014b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54044b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
540562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
540662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
540762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
540862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
540962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
54120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
54130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
54144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
54151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
54160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
54170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
54180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
54190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
54200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5423f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5424f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
54254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5426f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
54270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5430f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5439f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
54404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
54410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
544474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
544574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
54501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
545162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5452f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5453f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5454f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5455f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
545762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
545862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5459850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
546062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5461850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
546362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5464850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5465850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5467850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5468850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5469850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5471ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5472ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5474f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos, $Vtt_Pos) = (0, 0, -1);
5475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
54760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
547762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
547862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
547962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
548062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
5481f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $ParamName = "p".($PPos+1);
5482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
548362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
548462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
548562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
548662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
548762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
548862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
548962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
549362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5494989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5495989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5496989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5497989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5498989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5499989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
550162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
55030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
55070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
551762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
551862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
551962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
55220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
55250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5526f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($ParamName ne "this" or $FType ne "Method") {
5527f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5528f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
5529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
553101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
55381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
55391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
554062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
5541f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
5545f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        # skip "this"-parameter
554646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
55490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
55500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
55510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
5553f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos) = (0, 0);
5554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
55550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
55560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
55570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
55580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
556462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
556562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5566dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
557046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
557246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
557346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
557446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
557546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
557646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
5577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($PPos+1);
557846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
557946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
558046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
558146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5582e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
558346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
558446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
558546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
558646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
558746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
558846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
558946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
559046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
559146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
559246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
559346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
55940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
55950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
559662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
55970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
559801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
559901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
56008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
56018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
56028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
56038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
560401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
560501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
560601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
560701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
5611f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Pos!=0 or $FType ne "Method") {
5612f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5613f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
56140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
561962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
562062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
562162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
562262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
562362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
562462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
562562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
562662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
562762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
562862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
562962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
563062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
563162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
563262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
563362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
563462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
563562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
563662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
563762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
563862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
563962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
564062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5641e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5642e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5643e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5644e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5645e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5646e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5647e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5648e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5649e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5650e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5651e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
565262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
565362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
565462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
565562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
565662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
565762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
565862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
565962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
566062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
566162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
566262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
566362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
566462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
566562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
566662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
566762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
566862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
566962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
567062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
567162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
567262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
567362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
567462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
567562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
567662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
567762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
567862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
567962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
568062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
568162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
568262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
568362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
568462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
568562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
568662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
568762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
568862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
568962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
569062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
569162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
569262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
569362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
569462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
569562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
569662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
569762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
569862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
569962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
570062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
570162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
570262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
570362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
570462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
570562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
570662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
570762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5709dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5710dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
571462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
571562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
571662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
571762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
571962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
572062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
572162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
572262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
572362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
572462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
572562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
572662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
572762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
572862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
572962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
573062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
573162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
573262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
573362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
573462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
573562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
573662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
573762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
573862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
573962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
57408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
57418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
57428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
57438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
57448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
57458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
57468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
57478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
57488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
57498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
57508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
575162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
575262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
575362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
575462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
575562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
575662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
575762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
575862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
575962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
576062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
576162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
576262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
576362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
576462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
576562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
576662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
576762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
576862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
576962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
577062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
577162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
577262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5773177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5774177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5775177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5776177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5777177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5778177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5779177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5780177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5781177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5782177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5783177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
578462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
578562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
578662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
578762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
578862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5789dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5790dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5797dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5798dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5799dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/low[ ]*:[ ]*([^ ]+) /) {
5800dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5801dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5808dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5810dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5811dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5812dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5813dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5814dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5815dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5816dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5817dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5818dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5820dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5821dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5824dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5825dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
58341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
58361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
58391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
5847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
5848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
5849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
5851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
5852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
5856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5857dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5858dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5859dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
5860dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
5861dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5862dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
5863dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
5864dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5865dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
5866dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
5867dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5871989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
5872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5873dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5874dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5875dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
5876dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5877dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5878dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
5879dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5880dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5881dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
5882dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5883dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5884dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5885dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
5886dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
5894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5895dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5896dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5897dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
5898dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
5899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5900dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
5901dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5904dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
590774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
5908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
590974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
591074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
591174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
591274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
591374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
591474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
591574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
591674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
5917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
591874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
5919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
592074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
592174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
592274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
592374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
592574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
592674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
592774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
592874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
592974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
593374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
593474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
593774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
5938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
5940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
594174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
5942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
594374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
594474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
594574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
594674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
594874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
594974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
595074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
595174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
595274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
595674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
5960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
596174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
596274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
5963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
596462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
5965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
596662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
5967dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
596862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
596962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
597062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
597162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
597262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
597362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
597462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
597562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
597662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
597762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
597862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
597962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
598062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
598162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
598262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
5983dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
5984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
598662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
598762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
598862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
598962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
5990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5992dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
5996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5997dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5999dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
6000dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
6001dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
6002dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
6003dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
6004dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
6005dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6006dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6007dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6008dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6009dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6010dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6011dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6019dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6020dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6021dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6022dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6023dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6025dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6031dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6032dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6033dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6036dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6039f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6041dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6042dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6043dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6044dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6045dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6047dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
605062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
605262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
605362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
605562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
605662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6058dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
606162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
606262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
606462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
606562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
606762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
606862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
606962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
607162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
607262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
607562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
607662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
607762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
607862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
60798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
60808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
60818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
60828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
60838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
60848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
60858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
60868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
60878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
60888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
60898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
60908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
60918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
609262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
609362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
609462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
609562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
609662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
609762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
609862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
609962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
610062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
610162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
610262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
610362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
610462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
610562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
610662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
610762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
610862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
610962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
611062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
611362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
61148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
611562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
61168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
611762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
612062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
612162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
612262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
612362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
612462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
612562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
612762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6136f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6138850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6139850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6147850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6148850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6158570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6163570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
61769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
61848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
62049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
62199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6224850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6225850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6226850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6227850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6228850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
623674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6237850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
62384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
623974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
624074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
624174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
624274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
624374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
624474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
624574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
624674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6247850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
624874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
624974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
625074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
625374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
625474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
625574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
625674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
625774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
625874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
625974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
626074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
626174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
62918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
62948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
62958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
62968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
62978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
62988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
63018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
63069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
63179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
63229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
63279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
63329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
63369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
63379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
63419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
63429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
63469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
63478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
63488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
63498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
63508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
63528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
63548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
63568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
63588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
63598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
63608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6367570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6372570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6381a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6382a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6383a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6384a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6385a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6386a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
63968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6397570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6398570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6401570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6405570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
64168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6421570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
64248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6435850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6436850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6437850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6438850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
644962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6456570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
646062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
64649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
64659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
64768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
64778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
64788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
64808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
64818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
64828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
64838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
64848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6485dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6486dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6487dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6489dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6490dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6491dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6493dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6494dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
649562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6496570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6497dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6498dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6499dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6500dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
65206fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko                { # all names are different with current prefix
6521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6530850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6531850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6532850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6533850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
65368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6575850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6576850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6602850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6603850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6604850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6605850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6606850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6607850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6608850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6609850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6610850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
661462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
661762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
66239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
66249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
66259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
66269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
66338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
66348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
66358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
66368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
66378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
66388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
66398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
66408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6641850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
664674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6650fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6654fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
666774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6682fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
669874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
669974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6705570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6709570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6710570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6712570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
671374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6724850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6726850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
672874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
673074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $HPath = realpath($Candidate);
6731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
67341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
673774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
674362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
67509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
67519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
675274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
675374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
675474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
675574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
67569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
67579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6768850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6769850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6770850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6771850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6772850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6773850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6774850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6822570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6823570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6824570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6825570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
6849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
6850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
6857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
6858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
6861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
6862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
6868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
68698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
6870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
68718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
6873a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
68758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
68778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
68788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6879a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
68808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
6882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
68838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
68848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
68858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
68868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
68878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
68888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
68898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
6890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
6891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
6898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
6900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
6901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
6902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
6903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
6905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
6906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
6908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
6910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
6911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
6912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
6925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
6929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
6930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
6956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
69659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
6966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
6967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
6968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
69729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
69739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
69749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
69759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
69769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
69779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
6978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
6979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
6980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
6981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
6982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
6990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
6998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
6999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
7000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
703262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
703362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
703462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
703562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
703662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
703762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
703862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
703962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
704262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
704362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
704462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
704562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
704662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
704762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
704862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
705062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
705162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
705262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
70569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
70579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
705862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
70619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
70629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
70639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
70649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
706574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
706974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
707074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
707174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
707274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
707474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
707507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
707674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
707774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
707874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
707907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
708007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
708107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
708262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7083570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
708674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7089e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
709062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7091e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
709762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
710062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
710162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
711062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7131570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
713462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
713562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
713762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
713862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
714062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
714162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
714262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
714462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
714762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
715974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7169dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
717174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7173570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
718162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
718262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
718362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
718462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
718562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
718662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
718774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
718862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
718962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
719162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
719262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7198dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7199dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
72009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7201dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
72030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7208989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7209dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7210dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7211dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7212dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7213dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7214dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7215dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
72168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
72178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
72188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
72198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
72208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
72218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
72228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
72238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
72248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7225dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7226dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7227dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7229dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7234989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7236989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7237989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
723907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7240570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7241570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7242989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7243989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7244989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7246989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7254989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7256570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7257989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
725962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
726062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
726162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
726262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
726362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
726462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
726562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7266989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7267989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7268989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
726962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
727062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
727162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
727262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
727362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
727462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
727562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
727662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
727762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
727862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7279989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7280989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7284989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7285989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7286989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7296989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7298989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7299989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7300989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7308989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7309989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7310989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7311989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7312989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7314989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7326a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
73349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
73359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
73369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
73379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
73389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
73409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
73419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
73429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
73439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
73449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
73459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
73469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
73479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
73489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
73499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
73509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
73519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
73529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
73559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
73619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
73629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
73699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
73709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
73739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
738262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
738362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
738462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
738562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
738762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7389f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/C1[EI]/) {
7390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7392f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/C2[EI]/) {
7393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
739662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7398f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/D1[EI]/) {
7399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7401f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D2[EI]/) {
7402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7404f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D0[EI]/) {
7405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Symbol=~/C1[EI]/) {
7412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7414f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/C2[EI]/) {
7415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7417f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D1[EI]/) {
7418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7420f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D2[EI]/) {
7421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7423f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D0[EI]/) {
7424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
74310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
74320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
74330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
74340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
74350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
743662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
74370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
74380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
74390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
74400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
744362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
744462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
744562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
744762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
74488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
7449ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
745062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
745162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7455aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
7456aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $ClassName=~s/\bstruct //g;
7457aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $Signature .= $ClassName."::";
7458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
746362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
746907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
747007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
747762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Pos eq "");
748062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
7481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ParamTypeId);
748262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
74888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
74898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
74908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7494f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($ParamName eq "this"
7495f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $Symbol=~/\A(_Z|\?)/)
7496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7497f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
7498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7499f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
750562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
750662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
75078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
751162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
75138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
75158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
751662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
751762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
75188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
752062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
752162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
75228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
752462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
752562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
752674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
75278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
753162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
75328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
75358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
75378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7543989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7544989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7560989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7561989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7562989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7563989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7564989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7565989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7566989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7567989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7568989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7569989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7570989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7571989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7572989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7573989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7574989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7575989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7576989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7578f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7583989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7584989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7585989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7586989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7587989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7589989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7593989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7594989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
75979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
759862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
75999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
76009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
760162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
760262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7603f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
760462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
76069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
76089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
76099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
76109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
76119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
76129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
761362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
761499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    $N=~s/\b(const|volatile) ([\w\:]+)([\*&,>]|\Z)/$2 $1$3/g; # "const void" to "void const"
761599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
7616f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
761762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7618f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7619f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
762062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7621f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
762262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7623f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
762462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
76269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
76289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
76299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
76309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
763162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
763299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    $N=~s/,/, /g;
763399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
76349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7698570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7708989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7709989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7710989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7713989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7717989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7718989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7719989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7720989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7721989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7722989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7723989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7724989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7725989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7726989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7727989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7728989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7729989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
773074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
773174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
773274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
773374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
773474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
773574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
773674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
77501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
776074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
776974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
777174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
77721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
77731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
777774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
777874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
77881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
77901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
780362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
7816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
7817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
7818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
7822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
7825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
7826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
7827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
7828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
7831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
7832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
7835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
7836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
7838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
7839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
7840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
7841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
7842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
7843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
7844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
7845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
7846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
7847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
7848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
7849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
7850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
7851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
7852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
7853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
7854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
7868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
7878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
7879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
7880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch eq "x86") {
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
7882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "x86_64") {
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
7887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
7890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
7895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
7896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
7897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
7901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
7902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
7903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
7904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
7905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
7906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
7907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
7908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
7909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
7910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
7911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
7912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
7913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
7914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
7915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
7916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
7917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
7918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
7919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
7920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
7921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
7922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
7923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
792482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
7925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
7926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
7927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
7928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
7929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
7930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
7931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
7932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
7933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
7934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
7935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
793601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
793782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
7938570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
793974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
794074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
794182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
794282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
794382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
794482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
794582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
794682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
794782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
794882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
794982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
795082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
7951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
7952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
7954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
7956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
7957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
7958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
7959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
7961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
7962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
7963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7964f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
7965f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($EMERGENCY_MODE_48)
7966f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # workaround for GCC 4.8 (C only)
7967f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $GccCall .= "c++";
7968f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
7969f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    elsif(check_gcc($GCC_PATH, "4"))
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
7971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
7972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
7978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
7980d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # platform-specific options
7981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
7982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
7984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
798501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
798601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
7987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
7988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
7990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
7991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7992d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(my $Opts_GCC = getGCC_Opts($Version))
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
7994d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $GccCall .= " ".$Opts_GCC;
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7996a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
7997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
7998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
7999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
8002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
800401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
8005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
800601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
8007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
8008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
8009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
8010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
80119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
80129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
8013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
80159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
80169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8021bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8022bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
80239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8024850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8027850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8028850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
80309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
803301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
803401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
803501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
80369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
803701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
803801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
803901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
804001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
804101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
804201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
804301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
804401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
80459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
80469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
80479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
80489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
80499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
80509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
80519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
80529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
805301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
805401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
805501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
805601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
80579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
805801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
805901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
80609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
806101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
806201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8063f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8064f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8065f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8066f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8067f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8068f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8070570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8071570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8072570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8073570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8074570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8076570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8077570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8078f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8079570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8080570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8081570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8082570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8083570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8084f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8085f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8086bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
808782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
808882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8089bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8090bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8091bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8092bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8093bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8094bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8095bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8096bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8097f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8098bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8099f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
81009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8101f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8102f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8103f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8104f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8105f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8106f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
81079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
81089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
81099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
81109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8111f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8112f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
81139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
81149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
81159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8117f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8118f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
81199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8120f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
81219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
81229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
81239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
81249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
81269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
81289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
81319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
81349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8137f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8138f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8139f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8140f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8141f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8142f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
81438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
814401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
81458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
81469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
81478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
81488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
814907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
81548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
81718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
81758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
81778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
81781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8179570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
81808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8187bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8188bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8189bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8190d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*([\,\)\;\.\[]|\-\>|\:\s*\d))/$1$2c99_$3$4/g)
8191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8193d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko          # int foo(char template[], char*);
8194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
819707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8198bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
820607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8207bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
821607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8217bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
822407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8225bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
823307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8234bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
824107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8242bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
82489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
82509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
825107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8252bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
825307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
82548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
82558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
82568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
82578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
82588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
82598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
82608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
826107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
826207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
826307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8264bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8265bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8266bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8267bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
826807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
82728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
82739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
82749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
82759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
82769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
82779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
82789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
82798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8283fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8284fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
82859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
82869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
82879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
82889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
829007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
82938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
829407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
82968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
82978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
82988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
82998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
83008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
83038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
83048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
83068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
83078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
83088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
83098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
83128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
83138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
83158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
83178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
83188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
83208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
83218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
83228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
83248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
83258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
83278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
83288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
83338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
83378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
83418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
83428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
83448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
83458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
83478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
83488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
83498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
83508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
83518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
83528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
83538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
83578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
83588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8360850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8361850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
83628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
83638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
83648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
83658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
83678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
83688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
83698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
83708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
83728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
83738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
83748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
83788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
83818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
83828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
83838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
83858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
83868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
83898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
83908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
83918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8392850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
839607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
840262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8416f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8432a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8433a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8434a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8435a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
84391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8442f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8443f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8444f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8445f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8446f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
84478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8449f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8450f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8451570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8452f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8453f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8454f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8456f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8457570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8458570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8459570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8461570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8462570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
846382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
846482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
846582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
846682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
846782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
846882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
846982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
847082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
847182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
847282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
84749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
84759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
84769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
84779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
84789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
84799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
84809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
84819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8482f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8483f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8484f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
84858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
8491d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($UserLang eq "C") {
8492d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TUdump .= " -U__cplusplus -D_Bool=\"bool\"";
8493d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
849407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
84988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8501a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
850601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
850701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
850807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
85092b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and index($Errors, "c99_")!=-1
85102b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and not defined $CppIncompat)
851101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
851207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
85132b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
85142b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                if($Debug)
85152b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                {
85162b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                    # printMsg("INFO", $Errors);
85172b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                }
85182b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
851907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
852001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
852101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
852201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
852401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
85259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
852601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
852701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
85289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
853101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8535570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
854201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
854301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
854401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
854501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
855901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
856001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
856101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
856201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
856301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
856401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
856501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
856601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
856701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
856901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
857001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8578f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
85798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8580570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8581570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8582570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8583570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8584570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8585570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8607989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8629a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8630a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8631a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8632a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8633a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8634a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8639570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8644570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8649570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8650570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8651570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8654570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8655570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8659570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8661570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8662570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8663570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8664570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8665570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8666570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8667570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8677f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8678a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8679dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
86824b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
86926fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Cmd = "dir \"$Path\" /B /O";
8693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
869974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
870074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
870174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8702570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
87048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
87058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
87068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
87078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
87098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
87118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
871774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8749570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8750570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8751570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
87539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
87548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
87559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
87569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8757570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8758570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
87608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8761570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
87624b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
878374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
878574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
878874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
879274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8794fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8796b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko      # *.tar.gz.amd64 (dh & cdbs)
8797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8809a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
881374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
881574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
881974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
882374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
882674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
8827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
883274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
8833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
883474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
883774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
884174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
88495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
88505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
88515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
8852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
8853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
8855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
8857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
8860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
8861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
8862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
8864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
8866a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
8867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
8869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
8879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
8881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
8883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
8884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
8885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
8889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
8898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
8910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
8914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
8924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
8928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
893162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
8932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
8933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
8936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
8942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
8946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
8954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
8955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8958570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
8959850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
8960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
8961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
89681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
8969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
8971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
8972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
897446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
89759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
89769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
89779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
89789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
89799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
8980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
8981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
8983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
8985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
8986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
898746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
8988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
8994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
8995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
8996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
8997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
8998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
8999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
9001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
9002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
9004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
9008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
9012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
9013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
90541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
906262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
906562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
906762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
906862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
906962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
907062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
907162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
907262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
907362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
907462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
907762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
908062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
908462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9086f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
908762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
908901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
909062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9091f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
909201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
909301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
909462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
909562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
909662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
909762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
910362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
910662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9108f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
910962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
911162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
911262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
911362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
911462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
911562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
91221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
91251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
91261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
91271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
9128ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
91291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
91301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
91311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
91321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
91341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
91351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
91371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
91381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
914062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
914162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
916362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
91641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
916662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
91670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
91680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
91690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
91700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
91710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
91720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
91730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
917462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
91750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
91760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
91770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
91780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
91790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
91800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
91810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
91820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
91830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
91840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
91850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
91860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
91871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
91891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
91901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9191082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
91971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9198850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
91991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9200850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9201989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
92021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
920362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
920462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
92051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9213850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9214850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9215850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9216850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9217850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9218850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9219850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9220850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9221850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
92245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
92255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
92265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
92275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
92285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
92295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
92305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
92315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
92325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
92335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
92345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
92355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
92365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
92375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
92385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
92395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
92405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
92415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
92421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
92491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
92541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
92561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
92571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
92581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
92591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
92601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
92611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
92631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
92711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
92781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
92791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
928162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
92901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9292850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9293fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9296fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9297fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9298fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
93021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9314850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
93189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9319850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
932162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9327850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9332850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9334850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9336850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9337850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9338850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9339850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9341850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9342850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9343850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9344850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9345850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
934862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9349850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
93521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9354850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
935662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9357850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9358850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
936062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9372850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
937562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
937762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
93791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
93801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9381850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
93821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
93831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9384850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
93851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
93909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
93919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
93929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
939574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
93969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9398dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
940074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
940174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
940262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
940374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
94081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
94091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
941062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
94111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
941262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
94131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
941462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
941562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
94161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
941762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
94181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
941962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
942062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
94211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
942262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
942362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
94241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
94251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
94261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
94271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
94281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9450177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9480177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
949262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9494989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9496989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9498989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
950062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9501850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9513850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9514989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9517989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9518850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9519850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9521850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9523850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9524850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
95251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9526850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9527989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9532989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
95331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9538850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9540989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9542989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9545989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9546989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9564850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9565989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
95721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
95761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
95771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
95781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
95791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9580850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
958135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9582850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9583850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
958435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
958535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
958635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
958735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
958835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
958935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
959035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
959135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
959235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9593850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9594850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9595850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
95960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9598850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9599850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9600850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
96028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
96038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9604c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
96058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
96068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
96078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9609850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9610850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9611850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9614850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
96150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
96170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
96180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
96190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
96230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9634850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9635850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9641850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9642850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
964535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
964635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
964735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
964835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
964935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
965035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
965135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9652850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
965435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
965535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9656850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9658850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9659850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9660850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9661850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9662850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
966301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
9664ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($SInfo, $LibVersion))
966535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
966635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
966735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
966835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
96690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
96700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9671850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9672850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9673850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9674850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9675850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9676850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9677850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9678850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9679850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
96800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
96810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
96820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
96830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9684850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
96871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9689177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9690177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9691177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9692177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9693177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
96941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9695177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9696177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
96971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9701177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9702177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9703989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9704989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9705989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9707850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
97081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
971301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
971401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
971501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9716f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId}{"Type"});
9717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
971862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9720177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9721177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9722177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9723177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9724177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
972501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
972662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
972862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
972962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
973201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
973301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
973401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9735850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
973662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
973762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
973828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub pickType($$)
973962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
974062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
97419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
97429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
97439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
97449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
97459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
97469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
97479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
97489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
97499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
97509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
97519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
97529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
975328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"};
975428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
975528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isBuiltIn($THeader)) {
975628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
975728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
975828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
975928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/) {
976028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
976128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
976228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
976328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"})) {
976428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
976528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
976628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
976728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(selfTypedef($Tid, $LibVersion)) {
976828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
976928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
977028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
977128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(not isTargetType($Tid, $LibVersion)) {
977228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
977328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
977428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
977528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 0;
977628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko}
977728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
977828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub isTargetType($$)
977928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko{
978028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
978128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
978228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/)
978328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    { # derived
978428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 1;
978528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
978628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
978762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
9788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
978928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(not is_target_header($THeader, $LibVersion))
979028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        { # from target headers
979128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
9792850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9793850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
97942c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    else {
97952c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        return 0;
97962c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
979728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
97981fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalTypes)
97991fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
98001fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$Tid}{"Name"}=~/($SkipInternalTypes)/)
98011fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
98021fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            return 0;
98031fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
98041fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
98051fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
980628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 1;
9807850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9808850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9809177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9810850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9811850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9812177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9813177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9814177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9815177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9816850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9817177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9818177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9819177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9820177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9821177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9822177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9823177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9825177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9826177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9827177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
982828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            if(pickType($Tid, $LibVersion))
9829177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9830177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9831177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9832177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9833177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9834177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9835177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9836177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9837177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9838177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9839177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9840177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9841177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9842177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9843177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9844177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9845177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9847177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9848177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9849177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9850177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9851177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9852177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9860989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
9863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
9865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
9866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
9868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
9873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
9874850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9875850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9876989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
9880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
9885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
9886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
9889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
9890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
9894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
9897989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
9898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
9902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
9904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
9908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
9910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
9912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
9913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
9915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
9917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
9918850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
992262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
9923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
9924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
992562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
9926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
9928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
9929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
9931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
9933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
9935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
9936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
9939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
9942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
9945177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
9946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
9948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
9951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9952850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
9957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
9960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
9963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
996462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
996562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
9966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
9967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
9968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9969177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
9970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
9971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
9975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9977850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9978177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
9979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
9982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
9984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
9986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
9987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
9989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
9991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
9992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9994850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
999562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
9996850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
999762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
999862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
9999850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
10000dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
10001f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
10002850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
10003850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10004850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
10005850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
10006850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10007850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
10008850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10009850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
10010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
10011850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
10012850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10013850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10014dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
10015dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
10016850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
10017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
10020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1002428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(pickType($Tid, $LibVersion))
10025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
100268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
100278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
100288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1002962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1003062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1003162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1003262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1003362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1003462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1003562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1003662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
100378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
100388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
100398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
100428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
100438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
100448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1005062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1006562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10073e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10074e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10075989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10076989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10084e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10085e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
101011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1010362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
101051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
101061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
101121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
101281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
101291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
101301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
101311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
101321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10133850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10134850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10135850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10136850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10137850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10138850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10139850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10141850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10162fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10163fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10175fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10176fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10177fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10179fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10180fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10181fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
101861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
101891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1021662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
102341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1024062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10241850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10242850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10243850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10249fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1026762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1028462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10285dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10286dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10288dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10289dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
102961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
102981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
102991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
103001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
103021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
103031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
103041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
103081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
103091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
103101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
103141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
103151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
103161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
103171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
103181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1032462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10334dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10335dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10339dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10345a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko    foreach my $MemPos (sort {int($a)<=>int($b)} keys(%{$TypePtr->{"Memb"}}))
10346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10367d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused|dummy)[_\d]*\Z/i) {
10368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
10383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by name in C language
10384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: add other methods to detect private members
10385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
10386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MName=~/priv|abidata|parent_object/i)
10387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C-styled private data
10388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(lc($MName) eq "abi")
10391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # ABI information/reserved field
10392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isReserved($MName))
10395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # reserved fields
10396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
10401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
104081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
104101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
104111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1041262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
104131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
104141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
104151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
104161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
104181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
104201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
104211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
104231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
104241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
104251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
104261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
104281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
104331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
104451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
104461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10447dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
104481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
104491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
104501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
104521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
104591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
104611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
104621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
104641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
104661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10467ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
104701fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
104711fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($Entry1=~/ 0x/ and $Entry2=~/ 0x/)
104721fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        { # NOTE: problem with vtable-dumper
104731fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            next;
104741fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
104751fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
10476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10490989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10491989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10492989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10493989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10494989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10495989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10496989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10497989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10498989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
104991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
105071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
105191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
105291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
105301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
105321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10534dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10537dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
105381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
105391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10540dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
105411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
105421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
105431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
105441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10545dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
105461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10550dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10553dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
105541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
105551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10556dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
105571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
105581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
105591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
105601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10561dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
105621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
105671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1056862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
105691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
105701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
105711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
105721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
105741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
105751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
105761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
105771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
105781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
105791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
105821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
105841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
105851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
105881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
105891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
105901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
105911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
105921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
105931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
105941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
105951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
105961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
105979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
105989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
105999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
106009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
106011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
106029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
106031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
106041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
106061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
106071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
106109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
106119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
106121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
106131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
106141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
106151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
106161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1062162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1062262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
106231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
106249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
106271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
106291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1064062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
106411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10642850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1064562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10646850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10647850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10648850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10649850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10650850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10651850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10652850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10653f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10656850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10658850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10659850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10660ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10661ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $Class_New{"Size"} or not $Class_Old{"Size"})
10662ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # incomplete info in the ABI dump
10663ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
10664ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
10665ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10666ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10669f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10670f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10671f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10672f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10674f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10675f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1067674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1067774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10680f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1068562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10686f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10689f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1069074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
106941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
106951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
106961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
106971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
106981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
106991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
107061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10715f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10716f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10717f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10718f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10719f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10720f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
107279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
107281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1074162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10742f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10745f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1074674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
107501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
107511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
107521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
107531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
107541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
107551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
107621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10771f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10772f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10773f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10774f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10775f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10776f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
107839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
107841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
107941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
107951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
107961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10797f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10798f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
107991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1080162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10802f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
108031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10804f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10805f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
108061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
108071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
108081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
108141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
108161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
108171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
108181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
108211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
108221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
108231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
108291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
108341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
108351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
108361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
108421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
108481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
108491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
108501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
108511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
108521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1085362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1085462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10855f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
108561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
108571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
10859d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        my $ProblemType = undef;
108601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
108611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
108631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
108641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
108661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
108671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
108681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
108691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
108701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
108711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
108721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
108731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
108741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
108751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
108781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
108791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
108819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
108851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
108861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
108871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
108881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
108891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10893f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
108941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
10895f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
108961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
108971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
108981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
108991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
109001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
109011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
109021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
109031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
10904f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
109051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
10906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1090762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
10908f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
109091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
109101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
10911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
109131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
109141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
10915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
10916850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
10917f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
10918f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
109191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
109201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
10921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10922850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
109231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
109241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
10927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
109281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
109301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
109311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
109321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
109331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
109351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
109361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
109371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10938850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
109391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
109401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
109411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
109431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
109441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
109461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
109471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
109481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10949850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
109501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
109511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
10952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
10955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
10963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1096562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
10966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
10967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
10971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
10972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
10975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
10976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
10977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
109821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
10983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
109841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
10985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
10986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
10987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1098962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1099062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
10991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
10992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
109971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
10998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
109991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
110001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
11001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
11002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
11003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
11004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
11005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
11006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
11007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
110091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
110101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1101262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
110131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
110141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
110151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
110171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
110181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
110191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
110201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
110211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
110221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
110230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
110241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
110251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
110260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
110270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
110280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
110290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
110300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
110310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
110320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
110330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
110340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
110350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
110360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
110400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
110410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
110420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
110430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
110440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
110480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
110490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
110500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
110510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
110521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
110531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
110541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
110551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
110561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
110571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
110581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
110591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
110601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
110631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11065dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11066dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
110671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
110681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
110691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
110701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
110731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
110771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
110781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
110799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
110801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
110811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
110821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
110831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
110841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
110851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
110861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
110871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
110881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
110891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
110901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
110911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
110921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
110931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
110941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
110951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
110961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
110971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
110981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
110991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
111031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
111061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11107dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11108dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
111091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11110dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11111dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11113dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
111141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11115dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11116dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11117dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
111209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11123dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11124dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11127dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1112862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
111291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
111331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
111341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
111351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
111371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
111391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
111401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
111411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
111421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
111439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
111441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
111451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
111471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
111481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
111491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
111501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
111511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11160dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11162dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
111631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11164dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11166dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
111691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
111701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11172dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11174dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11175dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11176dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11177dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11178dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11179850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11180850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
111819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11182850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11183850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11187dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11188dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11189dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11190dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11191dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11192dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1119362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
111941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
112001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
112011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
112021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
112031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
112041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
112051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
112061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
112071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
112081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
112101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
112141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
112161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
112558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
112578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1125962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1126062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
112688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
112708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
112718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
112728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
112731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
112748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11282f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1128662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11287f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1128962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1129062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1129362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1129462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1129562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1129762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1129862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1129962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1130162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1130262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1130362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1130562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1130662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1130762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/last|count|max|total/i)
11318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11336fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11337fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11338fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11339fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11340fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11341fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11342fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11343fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11344fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11345fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11352fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11353fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11380fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11381fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11382fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11384fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11386fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11387fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1140462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1140662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
11407f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Id or not $Type2_Id);
11408f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1140962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
11411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id};
11412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11413f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1141462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1141562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
114161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
11417f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
114181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11421f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11422f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11423f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my %SubProblems = ();
11427f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
114351fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if(not defined $UsedDump{1}{"DWARF"}
114361fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and not defined $UsedDump{2}{"DWARF"})
114371fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                {
114381fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
114391fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Target"=>$Type1_Pure{"Name"},
114401fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
114411fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                }
11442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11443f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11450850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11454f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return {};
11455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11456850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
114578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11459f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
11460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11461f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11462f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1_Pure{"Name"}});
11463f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1{"Name"}});
11464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
114651fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(not isTargetType($Type1_Pure{"Tid"}, 1)) {
114661fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return {};
1146728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1146828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
11469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11482fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11493fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11495fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11496fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11497fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11498fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11499fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1150062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1150162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11502fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
115036ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    if(%Typedef_1 and %Typedef_2
11504dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11505dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11507f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11509850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11510850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11511850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
11512850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or differentDumps("V"))
11513850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11514850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11515850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11516850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11517850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11518850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
115199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
115209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11521850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
115261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
11527d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            and $Type1{"Size"} and $Type2{"Size"}
115281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
115368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
115378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
11538fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
115398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11540fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11541fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11542fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11543fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11544fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11545fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11546fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11547fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11548fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11549fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11550fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11551fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11552fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11553fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11554fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11555fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
115568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1156174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1156274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1156374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1156474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1156574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1156774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1156874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1156974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1157074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1157174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1157274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1157374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1157474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1157574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1157674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1157774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1157874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1157974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1158074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11582f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
115848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
11585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
115891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
11590d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        and $Type1_Pure{"Size"} and $Type2_Pure{"Size"}
115911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
115951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11616f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE);
11617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11619fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11620fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
116210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11622f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11623f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
11624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11625f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}})) {
11626f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
11627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1164562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11651082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11652082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11656082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11670082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11671082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11674082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11679082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
116981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1169962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11722082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11734082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
117571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
117581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
117591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
117621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
117631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1176562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1176762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
117851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11788082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
117918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
117928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
117938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
117948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
117958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
117968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
117978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
117988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
118099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
118109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
118119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
118129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
118139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
118149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
118159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
118169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
118331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
118341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
118351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
118361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
118371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
118401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11841fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11845fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1186074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
118641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
118651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1186974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
11874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1187574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
11881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
11882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
11884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
11888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
11889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
11890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
11894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
11895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
11896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
11898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
11899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
11900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
11902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
11903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
11908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
11909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
11914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
11915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
11917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
11918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
11920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
11921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
11922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
11924fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
11925fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
11926fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11927fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
11928fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
11929fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
11930fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11931fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
11933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1193462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
11935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
11936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
11937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1193862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
11939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
11940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
11941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1194262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1194362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
119441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11945d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                and $SizeV1 and $SizeV2
119461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
11947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
11949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
11950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
11951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
11952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
11953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
11954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
11957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
11958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
11959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
11960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
11963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
11964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
11966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
11968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
11969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
11972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
11973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
11976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
11977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1197846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1197946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1198046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1198146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1198246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1198346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1198446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
11985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
11986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
11987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
11988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
11989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
11990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
11991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
11992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
11996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
11997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
11998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1200062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
120010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
120020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
120030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
120040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
120050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
120060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1200774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
120080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
120090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
120100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
120110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
12012fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
120130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1201474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
120150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
120160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
12017f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my %Sub_SubChanges = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
12018f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12020f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12021f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12022fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12023fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
12024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
12025fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
12026fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
12027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1202862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
12029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
12031f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
120320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12034f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
12035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
120370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
120380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
120390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
12040f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Added_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12043f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
120460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
120470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
120480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
12049f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Removed_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12052f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12059fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12060f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubChanges))
12061fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12062f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12063f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12065fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12066fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
12068f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                delete($Sub_SubChanges{$ProblemType});
120690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12074f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
120781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12083fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12100d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        # TODO: Private_Field_Type rule?
12101d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
12102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1211274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1211374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12114f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubChanges{$ProblemType_Init}}))
12115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12116f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubChanges{$ProblemType_Init}{$Attr};
12117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12124f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # checking member type changes
12125f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12126f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12127f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my %DupProblems = ();
12128f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12129f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
12130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12131f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}}))
12132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12133f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12134f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12135f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                if(defined $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}}) {
12136f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    next;
12137f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                }
12138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12139f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12140f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12141f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
12142f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12143f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12144f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12145f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}} = 1;
12146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12149f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12150f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %DupProblems = ();
12151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12159082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
121661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
121671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
121681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
121691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
121701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
121731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1219374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
121971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
121981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1220274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1220874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1221874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12222f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12224f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
12225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1223174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12232dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12233dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1223474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1223574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1223674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1223774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1223862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1223974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12241dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12242dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12243dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1224462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1224662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
122471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1224862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1224962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1225162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1225262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12256fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12257fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1225962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1227162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12273f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12274f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12275f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12276f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12278f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12279f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12280f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12281f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12284fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12286f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1229062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1229262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1229462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1229562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1229762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1229862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1231062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1231262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1231462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1231562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1231762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1231862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1232162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1232562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1232762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1232962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12331fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12347fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1235162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12353f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12354f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12355f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12356f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12357f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12358f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12359fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12360fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12361f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12362f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12363f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12364f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12365f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12366f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12367f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12368f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12369f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12370f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12371f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1237462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1237662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12377dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1237862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1237962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12382989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
123830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12388ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isInLineInst($$) {
1238901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1239001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1239101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
12392ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateInstance($$)
12393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12394ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
12395ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12396ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
1239762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12398ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1239962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
12400ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(index($ClassName,"<")!=-1) {
12401ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 1;
1240262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1240362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1240462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12405ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ShortName = $SInfo->{"ShortName"})
1240662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12407ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(index($ShortName,"<")!=-1
12408ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        and index($ShortName,">")!=-1) {
12409ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            return 1;
1241062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1241162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12412ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1241362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12416ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateSpec($$)
12417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12418ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
1241901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1242162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1242501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
124331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
124351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12436ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12437989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12441d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
124421fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(defined $SkipInternalSymbols)
12443d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
124441fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return 0 if($Symbol=~/($SkipInternalSymbols)/);
12445d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
12446d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1244728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($Symbol=~/\A_Z/)
1244828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    {
1244928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Symbol=~/[CD][3-4]E/) {
1245028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
1245128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1245228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1245328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1245462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1246062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12467850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12469ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"};
12470ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12475ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12476ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12477ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols
12478ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not $TargetHeadersPath or not $Header
12479ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or not is_target_header($Header, 1))
12480ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # -symbols-list | -headers-list
12481ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 0;
12482ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
12483ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12484ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12485ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12486ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols (in application)
12487ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            return 0;
12488ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12489ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12490ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12491ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
124921fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($ClassId)
124931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
124941fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            if(not isTargetType($ClassId, $LibVersion)) {
124951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                return 0;
124961fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            }
124971fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
124981fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
12499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1250262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12516ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Header)
12517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1251862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12525ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($TypesListPath and $ClassId)
1252652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        { # user defined types
1252752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1252852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1252952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if(not $TypesList{$CName})
1253052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
12531ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(my $NS = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"})
12532ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12533ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    $CName=~s/\A\Q$NS\E\:\://g;
12534ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
12535ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12536ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(not $TypesList{$CName})
12537ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12538ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    my $Found = 0;
12539ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12540ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    while($CName=~s/\:\:.+?\Z//)
12541ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    {
12542ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        if($TypesList{$CName})
12543ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        {
12544ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            $Found = 1;
12545ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            last;
12546ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        }
12547ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12548ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12549ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    if(not $Found) {
12550ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        return 0;
12551ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12552ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
1255352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1255452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
12555ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12556850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12557850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12558850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12559850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
125601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12562ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
12563ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
125641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12565ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
12566ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline virtual methods
12567ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if($Type=~/InlineVirt/) {
12568ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        return 1;
12569ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    }
12570ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
12571ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable)
12572ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    { # check bases
12573ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
12574ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        {
12575ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            if(not isCopyingClass($DCId, $LibVersion))
12576ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            { # exists a derived class without default c-tor
12577ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                $Allocable=1;
12578ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                last;
125791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12582ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable) {
125831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
125841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12586ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                else
12587ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline non-virtual methods
12588ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    return 0;
12589ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                }
12590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
125981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1260862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
126111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
126171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1262662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
126291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
126351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
126361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12639ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"});
12640c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
126411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
126431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12646ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"});
126479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12650dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12651dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12652dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12653dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
126540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12655dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12656dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12660c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
126661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1267062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
126711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1267262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1267362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1267462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1267562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1267662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
126771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
126781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
126791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
126811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
126841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
126851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
126861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
126871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12688b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12689b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12690b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12691b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12692b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
126931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
126941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
126951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
126961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
126971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1269862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
127021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
127031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
127041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
127051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1270662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
127071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
127081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
127091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
127101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
127111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12713850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
127201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
127221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
127231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
127240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
127251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
127261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
127271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
127291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
127301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
127311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
127411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
127421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
127431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
127441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
127451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
127461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
127471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
127481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
127491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1275062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
127541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12755850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
127561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
127571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1275862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
127601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
127611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
127621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
127631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
127641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12767850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12768850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12769850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12770850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12771850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
127721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
127741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
127751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
127761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
127771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
127781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
127791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
127811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
127821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12783b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12784b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12785b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12786b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12787b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12788b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12789b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
127909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
127919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
127929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
127939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
127949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
127959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
127969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
127979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
127989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
127999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
128009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
128019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
128029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
128039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
128049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
128051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
128061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
128071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
128081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
128091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
12815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
128171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
128209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
128219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
12822850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12824850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
12825850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12826850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
12827850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12828850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12829850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12830850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
128311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
128331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
128341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
128351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
128361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
128371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
128401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
128439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
128449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
12845850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12846850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12847850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
12848850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12849850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
12850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12851850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12852850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12853850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
128541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
128561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
128570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
128580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
128590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
128600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
128610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1286262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
12863f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{"this"}}=(
1286462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1286574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
128660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
128670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
128680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
128690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
128700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
128711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
128721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
12878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
12880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
12881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
12882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
12883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
12885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
12886850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
12887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
12888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
12889850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
12890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
12891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
12892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
12894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
12895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
12898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
12899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
12906989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
12907989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
12908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
12909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
12911989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
12912989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
12913989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
12914989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
12915989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
12916989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
12917989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
12918989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
12919989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
12920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
12921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
12926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
129281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
12929570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
129301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
129311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
12932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
12933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
12934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
12936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
12939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
12941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
12942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
12943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1294462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
12945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
12947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
129501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
129511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
129521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
129531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
129541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
129551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
129561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
12957dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
129581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
12959dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
129601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12961dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
12962dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
129631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
129641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
129651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
129661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
129681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
129691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
129701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
129711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
129721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
12975dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
12976dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
12977dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12978dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
12979dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
12980dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
12981dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
12982dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
12983dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
12984dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
12985dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
12986dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
12987dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
12988dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
12989dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
12990dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
12991dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
12992dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
12993dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
12994dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
12995dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
129961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
129971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
129991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
130001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
130011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
130020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
130030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
130040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
130050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
130060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
130070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
130080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
130090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
130100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
130110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
130120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
130130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
130140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
130150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
130168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
13017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
130181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
13019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
13020f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
130211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
130221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
13023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
130241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
130261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
13027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
130300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
130310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
130320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
130331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13034850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
130351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
130361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
130391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
130421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1304362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1304462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
130450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
130470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
130490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
130500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
130510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
130520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
130530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
130540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
130550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1305674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
130570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
130621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
130631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
130641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
130680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
130690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
130700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
130711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
130731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
130741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
130751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13076850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
130771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
130781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
130801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
130811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1308262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1308362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
130850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
130860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
130880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
130890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
130900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
130910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
130920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
130930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
130940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1309574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
130960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
131016fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        and $OStarget eq "windows")
13102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1310362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1310562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1310762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1310962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
131101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
131111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
131121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
131131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1311462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
131161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
131171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
131191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
131201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1312162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1312462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1312662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
131271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
131281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
131291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
131301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1313162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
131331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
131341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
131361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
131371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1313862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1314162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1314262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1314362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1314462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1314562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
131481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
131511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
131521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1315362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1315462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
131551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1315662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
131631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
131651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1316762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
131681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
131691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13170f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(C[1-2][EI])/)
13171989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
13173f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(C[1-2][EI])/$CtorType/g;
13174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
131761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
131771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13178f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(D[0-2][EI])/)
13179989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
13181f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(D[0-2][EI])/$DtorType/g;
13182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1318562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
131881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1318962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1319262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
131931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1319462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1319662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
131981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1319962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
132010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
132021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1320362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
132041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1320562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
132071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13211fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
132121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1321362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
132141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1321562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
132171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1321862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
132200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
132211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1322262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
132231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1322462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1322662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
132281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
132291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1323062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
132311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1323262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
132381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
132391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
13240f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $CurrentSymbol = $Symbol;
13241f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
132421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
132431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
132441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
132451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
132461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
132481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
132491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
132501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
132511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
132521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
132531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
132541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
132551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
132561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
132571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
132581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
132591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
132601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
132611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
132661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
132671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
132681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
132691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
132701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
132761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
132771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
132781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
132811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
132821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
132861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
132919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
132929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
132939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
132949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
132959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
132969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
132979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
132989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
132999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
133009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
133019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
133029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
133039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
133049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
133059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
133069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
133079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
133089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
133099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
133109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1331162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
133120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
133140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
133150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
133160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
133170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
133180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
133190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
133200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
133210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
133220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
133230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
133240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
133250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
133260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
133270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
133280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
133290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
133300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
133310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
133320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
133330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
133340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13335850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
133360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
133370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
133390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
133420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
133430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
133450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
133480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
133490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
133510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
133551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
133561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
133601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1336162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1336562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
133661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
133679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
133731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
133749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
133759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
133761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
133771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
133781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
133819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
133829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
133841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
133851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
133881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
133901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13392dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13393dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
133951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1339662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13397dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13398dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
133991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1340062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
134011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
134021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
134031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
134041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
134051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
134071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
134089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
134091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
134109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
134119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
134129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
134139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
134141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
134151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
134161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1341774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
134181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
134191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
134261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13430ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
134311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
134321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
134341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13436ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
134411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13443dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1344462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1344562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1344662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1344762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1344962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1345162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1345262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1345862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
134621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1346562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
134680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1346962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13470f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1347162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
134721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13476f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1347762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13478f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1347962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1348062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1348262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
134840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1348562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13486f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1348762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1348862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1348962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
134901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1349662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
134990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1350062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13501f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1350262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
135031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
135081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13510dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
135111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
135131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13515dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
135161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1351762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1351862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13519ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
135231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13525dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1352662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1352762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13528ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13529ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13531ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1353362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1353462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13540ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
135441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13547ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
135500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13551ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13552f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1355362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
135541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
135561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13558f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1355962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13560f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1356162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13562ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13564ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
135660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13567ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13568f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1356962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13570ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13571ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
135721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13578ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
135810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13582ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13583f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1358462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
135851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
135921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
135931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
13594f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %RC_SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13596f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubProblemType (keys(%RC_SubProblems))
13597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13598f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $New_Value = $RC_SubProblems{$SubProblemType}{"New_Value"};
13599f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Old_Value = $RC_SubProblems{$SubProblemType}{"Old_Value"};
13600fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13601f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13615fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13616fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13619fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13620fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13621fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13622fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13623fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13624fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13625fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13626fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13627fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13630fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13632fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13633fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13634fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13635fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13636fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13637fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13640fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13641fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13642fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13644fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13645fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13648fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13650fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13654fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
136609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13674f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13675f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13676f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13677f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13678f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13679f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13680f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13681f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13682f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13683f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13685f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13686f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13687f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13688f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13689f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13690f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13691f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13692f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13693f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13694f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13695f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13696f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13697f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13698f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13699f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13700fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13701f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13702f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13703fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13704f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13705f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13706f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13707f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13708f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13709f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13710f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13711f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13712fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13713f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13714f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13716f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13717f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13718f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13719f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13720f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13721f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13722f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13723f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13724f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13725f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13726f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13727fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13728f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13729f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13730fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13731f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13732f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13733f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13734f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13735f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13736f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13737f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13738f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13739f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13740fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13741f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13742f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13743fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13744f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13745f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13746fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13747f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13748f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13749f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13750f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13751f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13752f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13753fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13754fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13758fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13760fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13761f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"} = $RC_SubProblems{$SubProblemType};
137629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
13767f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Sub_SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13768f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13769f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $AddProblems = {};
13770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
1377733ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        if(defined $Sub_SubProblems->{"DataType_Size"})
13778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13779d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1378033ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            foreach my $Loc (keys(%{$Sub_SubProblems->{"DataType_Size"}}))
1378133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            {
1378233ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                if(index($Loc,"->")==-1)
13783d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                {
13784d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    if($Loc eq $Sub_SubProblems->{"DataType_Size"}{$Loc}{"Type_Name"})
13785d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    {
13786d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        $AddProblems->{"Global_Data_Size"}{$Loc} = $Sub_SubProblems->{"DataType_Size"}{$Loc}; # add a new problem
13787d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        last;
13788d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    }
1378933ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                }
13790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13793f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if(not defined $AddProblems->{"Global_Data_Size"})
13794fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13798fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
13799fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
13800fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
13801fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
13802f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"}{"retval"} = {
13803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
13804f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE };
13805fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13806fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13810f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13811f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$AddProblems}))
13812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13813f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$AddProblems->{$SubProblemType}}))
13814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1381533ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1381633ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1381733ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1381833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13819f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $AddProblems->{$SubProblemType}{$SubLocation};
13820f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
13821f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
13822f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13823f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13824f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
13825f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13826f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                {
1382733ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1382833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1382933ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1383033ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13831f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
13832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1383762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1383862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1383962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
138401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
13841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1384262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1384362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
13844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
13845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
13847f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Sub_SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
13848f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13850f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
13853f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
13854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
138591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
138601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
138611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
13862850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
13863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
13864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
13865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
138670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
138680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
138700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
138710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
138720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
138730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
138740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
138750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
138760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1387762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
138789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
138790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
138800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
138810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
138840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
138860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
138870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
138880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
138890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
138920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
13894fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
138950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
13898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
138991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
13900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
139010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
139020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
139040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
139050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
139060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
139070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
139080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
139090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
13910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
13911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1391262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
139130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
139140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
139150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1391662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
139170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
139180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
139190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
139210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
139220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
139230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
139240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
139250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
139260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
139270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
139280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
139290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
139300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
13931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
13934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
139360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
139370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
139380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
139390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
139400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
139410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
1394462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~/(\w+)/ and $1 ne $Qual) {
1394562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Value=~s/\b$1\b//g;
139460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
139480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
139500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
139510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
139520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
139530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
139540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
139550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
139560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
139580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
139590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
139600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
139610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
139620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
139630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
139640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
139650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
139680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
139690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
139714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
139724b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
139734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
139744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
139754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
139764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
139774b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
139784b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
139794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
139800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
139810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
139820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
13983f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
13984a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1398501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1398601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1398701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1398801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1398901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1399001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
139914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
139920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
139930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
139940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
139960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
139970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
139980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139994b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
140004b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
140014b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
140024b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
140030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
140040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14006fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
14007fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
14008fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
14009fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14010fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
14011fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14012fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
14013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
14014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14015ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
14016fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
14017fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14019fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14020fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
14021fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
140221fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    elsif(defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}
140231fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}
140241fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}{"offset"})
140251fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
140261fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return "unknown";
140271fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
14028fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
14030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
14031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14032ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
14033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14034ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
140350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
140360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
140370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14038dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
14039dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
14040dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
14041dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
140420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
140430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
140440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
140450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14046ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14047f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
14048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14052ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14053ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1405462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1405562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1405652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1405752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %PureType1 = get_PureType($PType1_Id, $TypeInfo{1});
1405852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1405962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1406062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
1406152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
140620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14063ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
140641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
140651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1406662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
140671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
140681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
140691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
140701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
140711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14072dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14073f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
140741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
140751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
140761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
140771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
140781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14079dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14080f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
140811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14083fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14084fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
140911fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
140921fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if($Old_Regs ne "unknown"
140931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and $New_Regs ne "unknown")
14094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
140951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    if($Old_Regs and $New_Regs)
140961fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
140971fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        if($Old_Regs ne $New_Regs)
140981fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        {
140991fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
141001fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Target"=>$PName1,
141011fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141021fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Old_Value"=>$Old_Regs,
141031fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "New_Value"=>$New_Regs  );
141041fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        }
141051fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
141061fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif($Old_Regs and not $New_Regs)
14107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
141081fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
141091fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Target"=>$PName1,
141101fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141111fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Old_Value"=>$Old_Regs  );
141121fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
141131fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif(not $Old_Regs and $New_Regs)
141141fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
141151fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14116fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14117f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14119fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14120fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
141211fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
14122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14127f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start1 = $CompleteSignature{1}{$Symbol}{"Param"}{0}{"offset"};
14128f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start2 = $CompleteSignature{2}{$Symbol}{"Param"}{0}{"offset"};
14129f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14130f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $Old_Offset = $Old_Offset - $Start1;
14131f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $New_Offset = $New_Offset - $Start2;
14132f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14133f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if($Old_Offset ne $New_Offset)
14134f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
14135f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14136f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Target"=>$PName1,
14137f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14138f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Old_Value"=>$Old_Offset,
14139f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "New_Value"=>$New_Offset  );
14140f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
14141fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14143fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14144fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14146177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14147177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14149177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
141500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
141510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1415262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1415362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
141540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
141550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
141560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
1415752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Name"} eq "bool"
141580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
141590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
141600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
141610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
141620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
141630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1416601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1416701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1416801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1416901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1417001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1417101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1417201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1417301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
141740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
141760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
141770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
141790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
141800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
141810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
141821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14184f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
141860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
141911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
141920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
14193f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
141970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
141980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
141990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
142000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
142010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
14202f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
142030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
142040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14206ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14207ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14208ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14209ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14210ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14211ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14212ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14213ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14214ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14215f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14216ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14217ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14218ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14219ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14220ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14222ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14224dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14225f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1423662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
142390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
142401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14256fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14261fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14262fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14263fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14264fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14265fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14266fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14267fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14268fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14283fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14284fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14286fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14287fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14293f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14294f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14314f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14317f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14318f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14320f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14323f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14324fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14325f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14326f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14327f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14328f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14329f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14330f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14331f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14332f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14333f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14334f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14336f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14337f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14338f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14339f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14340f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14342f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14343f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14344f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14345f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14346f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
143491fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            elsif($Conv1{"Method"} ne "unknown"
143501fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            and $Conv2{"Method"} ne "unknown")
14351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14352f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14353f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14355f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14356f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14359f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14360f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14364f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
143661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14368f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14370f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
14372f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Sub_SubProblems = mergeTypes($PType1_Id, $PType2_Id, $Level);
14373f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14375f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1438052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Type"}!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
14386f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
143931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
143941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
143961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
143971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
144071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
144091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
144131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
144141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1441562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14424e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14425e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
144288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
144298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
144308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
144318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
144328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
144338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
144348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
144358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
144368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
144378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
144388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
144398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
144408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
144418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
144428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
144438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
144448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
144458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
144471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
144488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14449f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14450f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
144518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
144569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
144579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
144589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
144599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
144658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14482fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14495fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14507fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
145131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
145141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
145151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
145161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
145171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
145181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
145191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14526fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14527fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14528570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14529570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14530570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14535fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
145498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
145501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
145511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
145521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
145531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
145541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
145551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
145561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
145578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
145598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
145608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
145628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
145638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
145648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
145658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
145668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
145688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
145698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
145708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
145718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
145738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
145748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
145758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
145778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
145788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
145798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
145808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
145848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
145858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
145868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
145878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
145921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14595dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14596dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14597dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1459962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1460062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14601f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14602f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
14603f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14604f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1460574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1460662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1460762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
146159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
146169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
146179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
146189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
146199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
146209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
146219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
146229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
146239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
146249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
146259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
146269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
146279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
146289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
146299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
146309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
146341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
146358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
146368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14642f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
146468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14651f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14652f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14659f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14660f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14669f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14674f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14681f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE);
14682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
146851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14686dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14687dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14693f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
146978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14702f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14703f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14710f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14711f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
147221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
147231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
147241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
147281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
147291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14730fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14731fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
147321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
147331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
147341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
147351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14736fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14737fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
147381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
147391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
147401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
147411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14745ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array"
14746ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    and $Type1_Pure{"BaseType"})
14747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
147491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
147650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
147660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
147670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
147680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
147690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
147700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
147710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1477274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1477374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
147740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
147750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
147760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1477774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
147780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
147790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
147800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
147818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
147838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
147848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147852b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
147862b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
147872b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
147880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
14789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
1479062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
147910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
14792f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
14793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1479462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
147950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
14796f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
14797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14798850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
14799850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
14800850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
14801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
14802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
148040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1480562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1480662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
148070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
148080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1480974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
148100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
148110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
148120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
148130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1481462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1481562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
148160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1481762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1481874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1481974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1482074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1482174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1482274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1482374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1482474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
14825d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        { # added type prefix in 2.20
1482674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1482774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
14828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
14829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
148328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
148338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
148348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
148358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
148368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
148378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
148388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
148398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
148408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
148418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
148428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
148438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
148448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
148458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
148468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
148478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
148482b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
148492b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        if($TT1 eq "FuncPtr"
148502b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        and $TT2 eq "FuncPtr")
148512b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        {
148522b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN1_C = $TN1;
148532b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN2_C = $TN2;
148542b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
148552b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN1_C=~s/\b(struct|union) //g;
148562b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN2_C=~s/\b(struct|union) //g;
148572b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
148582b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if($TN1_C eq $TN2_C) {
148592b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                return 0;
148602b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
148612b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
148628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
14863d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14864d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my ($N1, $N2) = ($TN1, $TN2);
14865d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N1=~s/\b(struct|union) //g;
14866d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N2=~s/\b(struct|union) //g;
14867d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14868d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($N1 eq $N2)
14869d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    { # QList<struct QUrl> and QList<QUrl>
14870d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        return 0;
14871d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
14872d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
14874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
148761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
148781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
14879989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
14880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
14881989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
14882dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
148831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
14884dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
14885dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
14886dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
14887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
14888989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
14889dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
148901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
14891dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
14892dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
14893dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
14894dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
14895dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
14896989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
14897dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
148981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
14899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14900989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
14901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
14904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
14905dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
14906dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
14907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
14908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
14911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
149135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
149145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
14915dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
14917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
14918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
14919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
149208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
149218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
14922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
149238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
14924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
14925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
14926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
14927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
14928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
149305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
149315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
149325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
149335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
149345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
149355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
149365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
149375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
149385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
149395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
149405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
149415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
149425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
149435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
149445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
149455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
149465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1494701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1494801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1494901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1495001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1495101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1495201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1495301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1495401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1495501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1495601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1495701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1495801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1495901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1496001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1496101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1496201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1496301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
14964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
14965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
14967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
14968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
14971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
14973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
14974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
14977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
14979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
14980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
14983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
14985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
14986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
14987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
14988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
14990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
14993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
14995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
14996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
14998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
15001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15002dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
15003dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
15004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
15005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
15006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
15007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
15008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
15010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
150111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
15012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
150138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
150141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
15015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
150161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
15019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
15021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
15022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
15023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1502407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1502507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
15026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
15027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
15029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
15030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
15031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
15032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
15033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
15035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
15036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
150378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
150388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
15039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
15040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
15041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
15043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
15044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
150450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            my $Style = "param";
15046dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
15047dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
150480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "focus_p";
15049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
150510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "color_p";
15052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
150530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Part_Styled =~ s!(\W)$ParamName([\,\)]|\Z)!$1<span class=\'$Style\'>$ParamName</span>$2!ig;
15054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
150701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
150731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
150761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
150791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
150808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
150818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
150828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
150838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
150848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1508707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1508907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1509007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1509107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1509207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1509307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1509407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1509507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1509607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1509707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1509807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1509907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1510207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1510407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
151061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
151071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
151101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
151111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1511207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
151131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
151141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
151151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
151171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
151181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
151191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
151211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
151241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1512707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1512807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1512907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1513007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1513107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1513207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1513307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1513407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
151381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
151411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
151431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
151441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
151931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15197850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
152081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15216850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15217850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15218850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
152191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15220850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15222850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
152401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
152490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
152510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15255850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15256850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15257850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
15280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15284f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15285f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15288f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15291f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15294f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15297f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15301f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1533654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1533754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if($TargetArch) {
1533854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        return $TargetArch;
1533954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
15340d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    elsif($CPU_ARCH{$LibVersion})
153411fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    { # dump
15342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1534854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
15349d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return getArch_GCC($LibVersion);
15350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1535252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkosub get_Report_Title($)
15353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
153541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
1535552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
153571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
153581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
153591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1536352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Title = "";
153641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
1536552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Source compatibility";
153661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
153671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
1536852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Binary compatibility";
153691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
153701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
1537152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "API compatibility";
153721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1537352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1537415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V1 = $Descriptor{1}{"Version"};
1537515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V2 = $Descriptor{2}{"Version"};
1537615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1537752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($UsedDump{1}{"DWARF"} and $UsedDump{2}{"DWARF"})
1537852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1537952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M1 = $UsedDump{1}{"M"};
1538052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M2 = $UsedDump{2}{"M"};
1538152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1538215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M1S = $M1;
1538315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M2S = $M2;
1538415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1538515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M1S=~s/(\.so|\.ko)\..+/$1/ig;
1538615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M2S=~s/(\.so|\.ko)\..+/$1/ig;
1538715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1538815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($M1S eq $M2S
1538915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        and $V1 ne "X" and $V2 ne "Y")
1539052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1539115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report for the <span style='color:Blue;'>$M1S</span> $TargetComponent";
1539215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1539352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1539452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        else
1539552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1539615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report between <span style='color:Blue;'>$M1</span> (<span style='color:Red;'>".$V1."</span>)";
1539715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " and <span style='color:Blue;'>$M2</span> (<span style='color:Red;'>".$V2."</span>) objects";
1539852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1539952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1540052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    else
1540152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1540214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $Title .= " report for the <span style='color:Blue;'>$TargetTitle</span> $TargetComponent";
1540315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1540452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1540552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1540652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title .= $ArchInfo;
1540752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
1540901e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko        $Title .= " (relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)";
15410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1541152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title = "<h1>".$Title."</h1>\n";
1541252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    return $Title;
15413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15415ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkosub get_CheckedHeaders($)
15416ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko{
15417ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my $LibVersion = $_[0];
15418ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15419ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my @Headers = ();
15420ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15421ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
15422ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
15423ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $File = get_filename($Path);
154241fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
15425ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not is_target_header($File, $LibVersion)) {
15426ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15427ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15428ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15429ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(skipHeader($File, $LibVersion)) {
15430ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15431ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15432ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15433ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        push(@Headers, $Path);
15434ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
15435ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15436ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    return @Headers;
15437ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko}
15438ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
15442ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15443ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Headers = get_CheckedHeaders(1))
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15445ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders = "<a name='Headers'></a><h2>Header Files (".($#Headers+1).")</h2><hr/>\n";
15446ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<div class='h_list'>\n";
15447ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
1544862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15449ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15450ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15451ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15452ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedHeaders .= $Name.$Comment."<br/>\n";
15453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15454ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "</div>\n";
15455ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15456ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15457ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15458ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Sources = keys(%{$Registered_Sources{1}}))
15459ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15460ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources = "<a name='Sources'></a><h2>Source Files (".($#Sources+1).")</h2><hr/>\n";
15461ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<div class='h_list'>\n";
15462ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15464ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15465ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15466ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15467ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedSources .= $Name.$Comment."<br/>\n";
1546862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15469ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "</div>\n";
15470ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<br/>$TOP_REF<br/>\n";
15471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15472ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1547362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a><h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2><hr/>\n";
1547662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<div class='lib_list'>\n";
1547762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
1547862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1547962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
1548062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1548162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1548262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1548362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15485ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15493fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15495fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15496fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TypeProblems_Count($$$)
15500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeChanges, $TargetPriority, $Level) = @_;
15502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges}))
15504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges->{$Type_Name}}))
15507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges->{$Type_Name}{$Kind}}))
15509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges->{$Type_Name}{$Kind}{$Location}{"Target"};
155112489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
155122489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next if($Severity ne $TargetPriority);
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
155162489ef88760861175102e4508089608391beead3Andrey Ponomarenko
155172489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target})
155182489ef88760861175102e4508089608391beead3Andrey Ponomarenko                {
155192489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
155202489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    { # select a problem with the highest priority
155212489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        next;
155222489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    }
15523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
155341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
155351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
155368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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);
155371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
155381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
155391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
155401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
155421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
155441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
155531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
155578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
155588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
155598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
155608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
155618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
155628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
155638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
155648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
155658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
155668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
155678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
155688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
155698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
155708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
155718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
155721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
155741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
155781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
155802489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
155811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
155841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
155872489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Severity;
15588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
155912489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity eq "Safe") {
15592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155942489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "High") {
15595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155972489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Medium") {
15598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
156002489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Low") {
15601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
156032489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if(($Severity ne "Low" or $StrictCompat)
156042489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        and $Severity ne "Safe") {
156052489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeChanges = ();
156131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15619f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
156211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
156221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
156232489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15624f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target};
15625f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
156262489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($MaxSeverity and $Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
15627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
15628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15630f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
156312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(($Severity ne "Low" or $StrictCompat)
156322489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    and $Severity ne "Safe")
15633f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
15634f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if(defined $TotalAffected{$Level}{$Interface})
15635f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
156362489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            if($Severity_Val{$Severity}>$Severity_Val{$TotalAffected{$Level}{$Interface}}) {
156372489ef88760861175102e4508089608391beead3Andrey Ponomarenko                                $TotalAffected{$Level}{$Interface} = $Severity;
15638f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            }
15639f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15640f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        else {
156412489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15642f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15643f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15644f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15645f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeChanges{$Type_Name}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
15646f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15647f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($MaxSeverity)
15648f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
156492489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$Severity}>$Severity_Val{$MaxSeverity}) {
156502489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15651f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15652f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15653f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    else {
156542489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
156601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count(\%TypeChanges, "High", $Level);
15662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count(\%TypeChanges, "Medium", $Level);
15663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count(\%TypeChanges, "Low", $Level);
15664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Other = get_TypeProblems_Count(\%TypeChanges, "Safe", $Level);
156651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15666f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    %TypeChanges = (); # free memory
15667f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15668ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # changed and removed public symbols
15669ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $SCount = keys(%{$CheckedSymbols{$Level}});
15670ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($ExtendedCheck)
15671ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # don't count external_func_0 for constants
15672ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $SCount-=1;
15673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15674ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($SCount)
15675ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15676ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my %Weight = (
15677ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "High" => 100,
15678ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Medium" => 50,
15679ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Low" => 25
15680ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        );
15681ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach (keys(%{$TotalAffected{$Level}})) {
15682ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15684ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15685ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15686ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
15687ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 0;
15688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15689ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
156901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
156911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
156921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
156971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15701850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
157061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
157078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15708850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15709f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
157108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
157118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
157128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15713850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
157148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
157158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
157168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
157181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
157198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
157208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
157218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
157228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
157238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
157248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
157258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
157268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
157278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
157281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
157291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15732850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15734850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15735850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
157361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
157371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
157381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
157391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
157401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15755d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch1</arch>\n";
15756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15761d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch2</arch>\n";
15762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15777fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15779fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15781fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
15782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15784fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
15785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
15789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
15792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
15793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
15795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
15796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
15798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1579962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
15800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
15801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
158031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
15804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
15805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
15808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
15809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
15811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
15812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
15813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
15814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
15815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
15816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
15818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
15819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
15820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
158211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
15822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
15823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
158251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
15826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
1582752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
15829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
15831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
15834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
158361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
1583715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1583815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($TargetComponent eq "library") {
1583915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Library Name</th><td>$TargetTitle</td></tr>\n";
1584015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
1584115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        else {
1584215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Module Name</th><td>$TargetTitle</td></tr>\n";
1584315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
15844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
15846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
15847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
15848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
15849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
15850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
158511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
15852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
15856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
15857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GccV1 ne "unknown"
15860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
15861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
15862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
15863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
15864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
15865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
15866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
15870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
15871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
15874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
15875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
15876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
15877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
15878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
15879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
15880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
15881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
15882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
158831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
158841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
158851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
158861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
158871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
158891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
158901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
15893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
158961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
15897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158986ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        if(my @Headers = get_CheckedHeaders(1))
15899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
15901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
15902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15906fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
15907fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
15908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
15911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
15913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
15914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
15915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1591762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
15918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
159201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
159211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
159221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "<tr><th>Verdict</th>";
15924850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible") {
159251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Red;'><b>Incompatible<br/>(".$RESULT{$Level}{"Affected"}."%)</b></span></td>";
159261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
159271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
159281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Green;'><b>Compatible</b></span></td>";
159291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
159301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
15931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
15932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
15934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
159361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
15937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
15938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
159401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
159411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
159421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
159431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
159441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
159461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
159471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
159501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "A", $Added).">$Added_Link</td></tr>\n";
15951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
159531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
159541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
159551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
159561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
159571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
159591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
159601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
159611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
159631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
159641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "R", $Removed).">$Removed_Link</td></tr>\n";
15965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
159671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
15968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
159691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
159701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "H", $T_Problems_High).">$TH_Link</td></tr>\n";
15971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
159731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
15974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
159751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "M", $T_Problems_Medium).">$TM_Link</td></tr>\n";
15976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
159781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
159801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "L", $T_Problems_Low).">$TL_Link</td></tr>\n";
15981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
159831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
15984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
159851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
159861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "H", $I_Problems_High).">$IH_Link</td></tr>\n";
15987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
159891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
15990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
159911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "M", $I_Problems_Medium).">$IM_Link</td></tr>\n";
15992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
159941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
15995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
159961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "L", $I_Problems_Low).">$IL_Link</td></tr>\n";
15997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
159998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
160008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
16001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
160021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
160031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Problems with<br/>Constants</th><td>Low</td><td".getStyle("C", "L", $C_Problems_Low).">$ChangedConstants_Link</td></tr>\n";
16004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
16006ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($T_Other)
160071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
160091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Data Types</th><td>-</td><td".getStyle("T", "S", $T_Other).">$TS_Link</td></tr>\n";
160101fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "type_changes_other:$T_Other;";
160111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
160121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16013ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($I_Other)
160141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
160161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "S", $I_Other).">$IS_Link</td></tr>\n";
160171fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "interface_changes_other:$I_Other;";
16018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16020ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($C_Other)
160218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
160228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
160238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "S", $C_Other).">$CS_Link</td></tr>\n";
160241fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "constant_changes_other:$C_Other;";
160258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
160268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
16028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
160291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # $TestInfo = getLegend().$TestInfo;
16030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
16031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
160351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
160361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
160371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
160381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "A"=>"new",
160391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "R"=>"failed",
160401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "S"=>"passed",
160411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "L"=>"warning",
160421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "M"=>"failed",
160431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "H"=>"failed"
160441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
160451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
160461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
160471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
160481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
160491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
160501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
16051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
16052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
160531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
16054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
160551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
160561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
160571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
160581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
160591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
160601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
160611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
160621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
160631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
160641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
16065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
16067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
16068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
16070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
160761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
160941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
160951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
160961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
161031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
161048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
161051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
161068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
161078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
161088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
161098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
161108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
161118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
161128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
161148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
161158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
161168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
161178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
161188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
16119f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($TargetSeverity ne $CompatRules{$Level}{$Kind}{"Severity"}) {
161208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
161218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
161228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
161238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
161281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
161311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
161348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
161358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
161368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
161378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
161388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
161408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
161418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
161428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
16143d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    if($Overcome) {
16144d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
16145d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    }
161468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
161478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Number = 0;
161571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
161608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
161628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
161638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
161648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
161658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
161668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
161678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
1616815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                    $Report .= "<tr>\n<th>1</th>\n<td align='left' valign='top'>".$Change."</td>\n<td align='left' valign='top'>$Effect</td>\n</tr>\n";
161698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Number += 1;
161708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
161718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
161728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
1617315bfdc281d18ec26a6a056ed45d641a885716165Andrey 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";
161748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = $ContentSpanStart."<span class='extendable'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
161758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
161768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
161778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
161811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
161821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
161848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
161858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
161868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
161871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a><h2>$Title ($Number)</h2><hr/>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
161951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
161961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
161971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
161981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Library and $Library!~/\.\w+\Z/) {
161991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Library .= " (.$LIB_EXT)";
162001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
162021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
162031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
162041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
162051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
162071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
162081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
162101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
162111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1621374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
162141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
162161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
162171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
162211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
162221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
162231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
162251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
162271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
162311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
162321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
162331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
162341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
162351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
162411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
162441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
162471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
162591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
162611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
162631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
162641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1626574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
162671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
162691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
162701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1627662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
162789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
162799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1628115bfdc281d18ec26a6a056ed45d641a885716165Andrey 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");
16282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
162841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
162879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
162889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
162901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
162931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
162971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
163011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
163021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
163041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
163051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
163061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
163071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ADDED_INTERFACES = $Anchor."<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
163161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
163171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16318850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16320850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
163221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
163261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
163271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
163281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
163291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16330850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
163361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
163391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16342850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16343850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
163531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
163541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
163551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
163571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
163581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
163591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1636074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
163621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
163641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
163651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16366850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16370850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1637262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
163751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1637715bfdc281d18ec26a6a056ed45d641a885716165Andrey 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");
16378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
163831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
163841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
163861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16389850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
163971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
163981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
164001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
164011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
164021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
164031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $REMOVED_INTERFACES = $Anchor."<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
164235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
164400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
164570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
164640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
164650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
164660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
164670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16482dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16483dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16484dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16485dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
1648628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1648728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(index($Content, $Macro)==-1) {
1648828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            next;
1648928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1649028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1649128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Kind!~/\A(Changed|Added|Removed)_Constant\Z/
1649228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Kind!~/_Type_/
1649328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Value=~/\s\(/ and $Value!~/['"]/)
16494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
164951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
1649628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            $Value=~s/\s[a-z]\w*(\)|,)/$1/ig; # remove parameter names
16497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
165260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16543dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
165451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
165461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
165471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
165482489ef88760861175102e4508089608391beead3Andrey Ponomarenko
165491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
165511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
165521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
165531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
165541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
165551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
165581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
165601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
165611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
165621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Symbol with Version
16564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DyLib = $Symbol_Library{1}{$VSym};
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1656662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $DyLib)
1656762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # const global data
1656862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $DyLib = "";
1656962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
165701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
165711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
165721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
165731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
165741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$SymbolChanges{$Symbol}{$Kind}} = %{$CompatProblems{$Level}{$Symbol}{$Kind}};
165751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165772489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
165782489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity ne $TargetSeverity) {
165791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        delete($SymbolChanges{$Symbol}{$Kind}{$Location});
16580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not keys(%{$SymbolChanges{$Symbol}{$Kind}}))
165831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
165841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    delete($SymbolChanges{$Symbol}{$Kind});
165851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    next;
16586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$SymbolChanges{$Symbol}})) {
165911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolChanges{$Symbol});
165921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
165942489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
165971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
166001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16603d59580888a06555261f3d4255d9c2cfcb408a51aAndrey 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}});
16604d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
16605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
16607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
166120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16613f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16619d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16620d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16621d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            }
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
166311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
166361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
166381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
166401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
166411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1664274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
166441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
166461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
1664728874769f026cec2a4c1ac1dfc975eda75275734Andrey 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}});
166481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
166501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
166511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
1665328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko                        foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
166551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
166571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
166580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
166601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
1666515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td align='left' valign='top'>".$Change."</td>\n<td align='left' valign='top'>".$Effect."</td>\n</tr>\n";
16666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
166721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
166741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ";
16675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
166761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= highLight_Signature_Italic_Color($Signature);
16677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
166791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= $Symbol;
16680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
166811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= " ($ProblemNum)".$ContentSpanEnd."<br/>\n";
166821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
166831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($NewSignature{$Symbol})
166841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
1668515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "\n<span class='new_sign_lbl'>changed to:</span>\n<br/>\n<span class='new_sign'>".highLight_Signature_Italic_Color($NewSignature{$Symbol})."</span><br/>\n";
16686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
166871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
166881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
166891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
1669015bfdc281d18ec26a6a056ed45d641a885716165Andrey 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";
166911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($NameSpace) {
1669362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                $INTERFACE_PROBLEMS=~s/\b\Q$NameSpace\E::\b//g;
16694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1669715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>\n";
16698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167012489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
167041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
167051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
167061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
167100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $INTERFACE_PROBLEMS = "<a name=\'".get_Anchor("Symbol", $Level, $TargetSeverity)."\'></a><a name=\'".get_Anchor("Interface", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$INTERFACE_PROBLEMS.$TOP_REF."<br/>\n";
16711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
167181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
167191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
1672074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my (%ReportMap, %TypeChanges) = ();
167212489ef88760861175102e4508089608391beead3Andrey Ponomarenko
167221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
167241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
16725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
16727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16728f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
167301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $TypeName = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
167311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
16732f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
167332489ef88760861175102e4508089608391beead3Andrey Ponomarenko
167341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Severity eq "Safe"
167351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $TargetSeverity ne "Safe") {
16736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
167381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
167392489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$TypeName}{$Kind}{$Target})
167402489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    {
167412489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
167422489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        { # select a problem with the highest priority
167432489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            next;
167442489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        }
16745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
167462489ef88760861175102e4508089608391beead3Andrey Ponomarenko
167472489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $TypeChanges{$TypeName}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
16748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
167522489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Kinds_Locations = ();
16754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $TypeName (keys(%TypeChanges))
16755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
167562489ef88760861175102e4508089608391beead3Andrey Ponomarenko        my %Kind_Target = ();
16757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (sort keys(%{$TypeChanges{$TypeName}}))
16758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16759f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16761f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
167621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Severity ne $TargetSeverity)
16763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # other priority
16764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Locations{$TypeName}{$Kind}{$Location} = 1;
16768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges{$TypeName}{$Kind}{$Location}{"Target"};
167692489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Kind_Target{$Kind}{$Target})
16770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicate target
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167742489ef88760861175102e4508089608391beead3Andrey Ponomarenko                $Kind_Target{$Kind}{$Target} = 1;
1677562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
167761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$TypeName} = 1;
16777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not keys(%{$TypeChanges{$TypeName}{$Kind}})) {
16779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($TypeChanges{$TypeName}{$Kind});
16780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$TypeChanges{$TypeName}})) {
167831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($TypeChanges{$TypeName});
167841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
167862489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16787850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$CompatProblems{$Level}});
16788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
167901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
167931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
16794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
16796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16798f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16806d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16807d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16808d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        }
16809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
16810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16812850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
168131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
16815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
16817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
16819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
16821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
168251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
168281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1682974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
16830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
16832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1683474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
16835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
16836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
16838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
168392489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16842f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
16847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
1684815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                                $TYPE_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td align='left' valign='top'>".$Change."</td>\n<td align='left' valign='top'>$Effect</td>\n</tr>\n";
16849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
16850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
16851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
16855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
16856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16857850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
16858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
168591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
16861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1686274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1686374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ".show_Type($TypeName, 1, 1)." ($ProblemNum)".$ContentSpanEnd;
168641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
168651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
168661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
168671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
16868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1686962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $TYPE_PROBLEMS=~s/\b\Q$NameSpace\E::(\w|\~)/$1/g;
16870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1687315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>\n";
16874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168762489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
168801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
168811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
16884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
168851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
16886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
16889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1689174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1689274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1689374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1689474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1689574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1689674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1689774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1689874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1689974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1690074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1690174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1690274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1690374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1690474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1690574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1690674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1690774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
169081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
169091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
169101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
169111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
169121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
169131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
169141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
169151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
169161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
169171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
169181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
169191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
169201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
169211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
169221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
169231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
169241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
169251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
169261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
169271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
169281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
169291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
169301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
16932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
16934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1693562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
16936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
16937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
16938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1694062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
16941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
16942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
16943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
16945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
169461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
16947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
169481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
169491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
16950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
16952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
16953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
16954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
169551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
16956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
169571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
169585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
169595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
16960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
16961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
16963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
169661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
16967ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<tr><th>Offset</th>";
16968ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
16969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
169701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
16971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
169731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Entries{$Index}{"E1"} ne $Entries{$Index}{"E2"})
16974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
169751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
16976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
169771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
169781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
16979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
169811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
16982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
169851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
169861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
16987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
16989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
169901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
16991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
16993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
16996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
16999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
17001dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
17002dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
17003dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
17004dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17005ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
17006ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $VEntry=~s/ \[.+?\]\Z//; # support for ABI Dumper
17007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
17008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
17009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
17010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
17011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17012fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
17013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
17014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
17015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
17016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
17017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
17018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
17019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17021f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub adjustParamPos($$$)
17022f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17023f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $Symbol, $LibVersion) = @_;
17024f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol})
17025f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17026f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$Symbol}{"Static"}
17027f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        and $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
17028f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17029f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return $Pos-1;
17030f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17031f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17032f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Pos;
17033f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17034f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17035f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17036f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17037f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17038f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamPos($$$)
17039f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17040f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
17041f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17042f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
17043f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"})
17044f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17045f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17046f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach (keys(%{$Info->{"Param"}}))
17047f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17048f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info->{"Param"}{$_}{"name"} eq $Name)
17049f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17050f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return $_;
17051f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17052f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17053f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17054f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17055f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17056f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17057f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17058f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamName($)
17059f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17060f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Loc = $_[0];
17061f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Loc=~s/\->.*//g;
17062f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $Loc;
17063f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17064f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17065850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub getAffectedSymbols($$$$)
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17067850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations, $Syms) = @_;
1706852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $LIMIT = 10;
17069f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17070f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $AffectLimit)
17071f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17072f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $LIMIT = $AffectLimit;
17073f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
1707452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1707552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymSel = ();
1707652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymLocKind = ();
1707752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1707852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    foreach my $Symbol (@{$Syms})
17079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
170802489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(index($Symbol, "_Z")==0
170812489ef88760861175102e4508089608391beead3Andrey Ponomarenko        and $Symbol=~/(C2|D2|D0)[EI]/)
17082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170852489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1708652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Kind (sort keys(%{$Kinds_Locations}))
17087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170882489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if(not defined $CompatProblems{$Level}{$Symbol}
170892489ef88760861175102e4508089608391beead3Andrey Ponomarenko            or not defined $CompatProblems{$Level}{$Symbol}{$Kind}) {
170902489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next;
170912489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
170922489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1709352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            foreach my $Loc (sort keys(%{$Kinds_Locations->{$Kind}}))
17094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1709552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if(not defined $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}) {
17096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
170982489ef88760861175102e4508089608391beead3Andrey Ponomarenko
170992489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my ($SN, $SS, $SV) = separate_symbol($Symbol);
171002489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Level eq "Source")
171012489ef88760861175102e4508089608391beead3Andrey Ponomarenko                { # remove symbol version
1710252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                    $Symbol = $SN;
171032489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
171042489ef88760861175102e4508089608391beead3Andrey Ponomarenko
171051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($SV and defined $CompatProblems{$Level}{$SN}
1710652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                and defined $CompatProblems{$Level}{$SN}{$Kind}{$Loc})
17107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicated problems for versioned symbols
17108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
171102489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1711152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}{"Type_Name"};
171122489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Type_Name ne $Target_TypeName) {
171132489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    next;
171142489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
17115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1711652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymLocKind{$Symbol}{$Loc}{$Kind} = 1;
17117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1712052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1712152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    foreach my $Symbol (sort keys(%SymLocKind))
1712252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1712352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        LOOP: foreach my $Loc (sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$SymLocKind{$Symbol}}))
1712452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1712552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            foreach my $Kind (keys(%{$SymLocKind{$Symbol}{$Loc}}))
1712652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
1712752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Loc"} = $Loc;
1712852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Kind"} = $Kind;
1712952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1713052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1713152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1713252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
17133850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
1713452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
1713652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Num = 0;
1713752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
1714152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1714252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17144ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Loc = $SymSel{$Symbol}{"Loc"};
1714552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $PName = getParamName($Loc);
17146ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $Loc);
1714752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
1714952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($PName)
17150d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            {
1715152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Target .= " param=\"$PName\"";
1715252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Desc=~s/parameter $PName /parameter \@param /;
17153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1715452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Aretval(\-|\Z)/i) {
17155d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"retval\"";
17156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1715752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Athis(\-|\Z)/i) {
17158d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"this\"";
17159d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            }
17160d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1716152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Desc=~s/\AField ([^\s]+) /Field \@field /) {
17162d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " field=\"$1\"";
17163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17164d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17165d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            $Affected .= "        <symbol name=\"$Symbol\"$Target>\n";
1716652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Desc)."</comment>\n";
17167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
1716852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1716952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Num>$LIMIT) {
1717052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1717152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1717252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1717352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Num += 1;
17174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
1717952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1718152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $SymSel{$Symbol}{"Loc"});
1718252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $S = get_Signature($Symbol, 1);
1718301e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko            my $PName = getParamName($SymSel{$Symbol}{"Loc"});
1718452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Pos = adjustParamPos(getParamPos($PName, $Symbol, 1), $Symbol, 1);
1718552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1718615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($S, $Pos, 1, 0, 0)."</span><br/>\n";
1718752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "<div class='affect'>".htmlSpecChars($Desc)."</div>\n";
1718852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1718952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Num>$LIMIT) {
1719052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last;
1719152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1719252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1719352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Num += 1;
17194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1719552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1719652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(keys(%SymSel)>$LIMIT) {
1719715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Affected .= " ...\n<br/>\n"; # and others ...
17198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1719952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1720015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>\n";
17201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
1720452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols (".keys(%SymSel).")".$ContentSpanEnd.$Affected;
17205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
172072489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17211f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub cmpLocations($$)
17212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1721362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
17214f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($L2=~/\A(retval|this)\b/
17215f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and $L1!~/\A(retval|this)\b/)
17216f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17217f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($L1!~/\-\>/) {
17218f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17219f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17220f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($L2=~/\-\>/) {
17221f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17222f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17227f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getAffectDesc($$$$)
17228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
172291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
17230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
172311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
17232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17233f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Location_I = $Location;
17234f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Location=~s/\A(.*)\-\>(.+?)\Z/$1/; # without the latest affected field
17235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %SymInfo = %{$CompleteSignature{1}{$Symbol}};
17245f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17248f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $METHOD_TYPE = $SymInfo{"Constructor"}?"constructor":"method";
17249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$SymInfo{"Class"}}{"Name"};
17250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17260f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $TypeID = undef;
17261f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17264f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17270f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17271f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Return"};
17272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17275f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17281f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17282f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Class"};
17283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17286f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17287f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17288f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = getParamPos($PName, $Symbol, 1);
17289f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17290f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17291f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in ".showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17294f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17296f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($PName) {
17297f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "\'".$PName."\'");
17298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17299f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17300f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Param"}{$PPos}{"type"};
17301f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17302f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17303f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Location!~/this/)
17304f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17305f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(my %PureType = get_PureType($TypeID, $TypeInfo{1}))
17306dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17307f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($PureType{"Type"} eq "Pointer") {
17308dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17309dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17310f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    elsif($PureType{"Type"} eq "Ref") {
17311dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17312dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17315f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            else
17320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17321f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Location_T = $Location;
17322f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $Location_T=~s/\A\w+(\->|\Z)//; # location in type
17323f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17324f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $TypeID_Problem = $TypeID;
17325f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Location_T) {
17326f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeID_Problem = getFieldType($Location_T, $TypeID, 1);
17327f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17328f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17329f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($TypeInfo{1}{$TypeID_Problem}{"Name"} eq $Problem{"Type_Name"}) {
17330f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17331f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17332f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                else {
17333f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17334f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1733862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
173398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17341d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17342d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my $Sent = join(" ", @Sentence);
17343d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1734452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Sent=~s/->/./g;
1734552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17346d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($ReportFormat eq "xml")
17347d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
17348d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Sent=~s/'//g;
17349d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
17350d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17351d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    return $Sent;
17352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17354f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getFieldType($$$)
17355f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17356f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Location, $TypeId, $LibVersion) = @_;
17357f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17358d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Fields = split(/\->/, $Location);
17359f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17360f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $Name (@Fields)
17361f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17362f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %Info = get_BaseType($TypeId, $LibVersion);
17363f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17364f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Pos (keys(%{$Info{"Memb"}}))
17365f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17366f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info{"Memb"}{$Pos}{"name"} eq $Name)
17367f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17368f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeId = $Info{"Memb"}{$Pos}{"type"};
17369f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                last;
17370f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17371f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17372f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17373f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17374f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $TypeId;
17375f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17376f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1738562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1738662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
173898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
173908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
173918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
173955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1740062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
174025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
174081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
174101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
174121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
174141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
174151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
174201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
174321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
174465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
174525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
174621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
174641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
174651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
174661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
174671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
174691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
174701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
174711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
174731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
174741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17475850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17476850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17478850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17479850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
1748062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1748162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1748262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
174831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
174841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
174851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
174881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
174891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
174911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
174921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
174931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
174941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
174951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
174961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
174971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
174991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
175001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
175011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
175021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
17503d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17504d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # additional symbols info (if needed)
17505d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # $Report .= get_Report_SymbolsInfo($Level);
17506d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
175071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
175081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
175131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
175141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
175151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
175161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
175181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
1751914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
1752041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Keywords = $TargetTitle.", compatibility, API, ABI, report";
1752141834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Description = "API/ABI compatibility report for the $TargetTitle $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
175221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
175231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
175241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1752552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title("Join")."
1752615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <br/>
1752715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <div class='tabset'>
175281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
175291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
175301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
175311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
175321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1753341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1753452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
175351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
175371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
175381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
175391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
1754014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
1754114b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Keywords = $TargetTitle.", ".lc($Level)." compatibility, API, report";
1754214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetTitle." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
175431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
175441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
175451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
175461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
175471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
175481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
175491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
175501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
1755152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title($Level)."\n".$Summary."\n";
175521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
175531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
175541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
1755541834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/>\n";
1755641834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1755752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
175581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
175591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
175621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
175631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getLegend()
175641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
175651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "<br/>
175661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<table class='summary'>
175671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
175681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='new'>added</td>
175691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='passed'>compatible</td>
175701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr>
175711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
175721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='warning'>warning</td>
175731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='failed'>incompatible</td>
175741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr></table>\n";
175751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
175761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
175771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
175781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
175791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
175800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
175811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
175841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
175851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
175861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
175871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
175881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
175891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
175901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
175911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
175921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
175931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
175941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1759841834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenkosub getReportFooter()
17599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1760041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    my $Footer = "";
1760101e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko
1760241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<hr/>";
1760341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<div class='footer' align='right'><i>Generated on ".localtime(time);
17604ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $Footer .= " by <a href='".$HomePage."'>ABI Compliance Checker</a> $TOOL_VERSION &#160;";
1760552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Footer .= "</i></div>";
1760641834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<br/>\n";
1760741834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko
17608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176132489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my ($Severity, $Level) = @_;
1761452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
176152489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Severity, $Level);
176162489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Severity, $Level)) {
176171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17618dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1761952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1762052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($Severity eq "Low" or $Severity eq "Safe") {
1762152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Report .= get_Report_ChangedConstants($Severity, $Level);
176228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1762352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
176281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
176291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
176302489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
176311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
176321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
176331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
176342489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_".$Level."_Problems\'></a>".$Report;
176351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
176371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
176381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
176392489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
176401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
176411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
176421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
176432489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_Problems\'></a>".$Report;
176441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
176541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
176551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
176561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <head>
17657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
17658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"keywords\" content=\"$Keywords\" />
17659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"description\" content=\"$Description\" />
176601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <title>
176611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title
176621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </title>
176631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <style type=\"text/css\">
176641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Styles
176651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </style>
176661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <script type=\"text/javascript\" language=\"JavaScript\">
176671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <!--
176681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Scripts
176691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    -->
176701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </script>
176711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </head>";
17672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17692a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1769374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
176941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1769574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17696a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
176971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17698a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17700a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17701a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17703a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17704a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1770574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1770674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1770774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1770874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1770974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1771074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17711fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17712fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17713fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17714fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1771774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1771874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1772074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1772174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1772274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17723a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1772474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
177254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17726fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17727fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17728fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17729fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17730fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17731fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17732fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17733fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
17734fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
17735fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
17736fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17737fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
177384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
17739a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
177404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
177419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
17742a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
17743a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
17744a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
17745a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
17746a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
17747a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
17748fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
17749fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
17750fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17751a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
17752a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
17753a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
17754a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
17755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1775774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1775874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1775974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1776074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1776174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1776274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1776374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1776474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1776574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1776674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1776774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1776874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1776974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1777074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1777174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1777274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1777374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
17776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
17777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1777874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1777974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1778074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1778174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1778274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17783177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
17784177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1778574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1778674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
17787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
17789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
17790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17792a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
17793a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
17794a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
17795a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
17796a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
17797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
177991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
178001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
178011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
178021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
178031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
178041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
178051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
178061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
17807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
178091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
17810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
17811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
178121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
178131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
178141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
178151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
178161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
178171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
178181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
178191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
17820fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
178211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
17822fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
178231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
178241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
178251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
178261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
178271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
17828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
17829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
17831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
17832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
17833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
17834fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
17835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
17836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
17837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
17838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
17839fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
17840fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
17841fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17842fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
17843fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17844fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17845fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17846fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17847fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17848fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17849fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17850fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
17851fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17852fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
17853fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17854fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
17855fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
17856fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17857fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
17859fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
17860fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17863fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17864fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
178659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
178669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
178679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
178689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
178699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
178709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
178719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
178729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
178739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
178749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
178759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
178769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
178779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
178789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
178799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
178809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
178819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
178829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
178839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
178849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
178859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
178869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
178879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
178889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
178899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
178909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
178919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
178929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
178939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
178949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
178959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
178969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
178979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
178989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
178999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
179009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
179019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
179029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
179039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
179049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
179059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
179069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
179079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
179089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
179099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
179109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
179119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
17912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
17913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
179148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
179158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
179168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
179178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
179198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
17920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
17921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
17922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
17923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
179248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
179258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
179268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
179278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
179288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
179298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
179308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
179318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
179328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
179338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
179348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
179358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
179368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
179378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
179398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
179408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
179438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
179448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
17948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
17949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
17950fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17952fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
17953fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
17954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
179558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
17956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
179578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
179608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
179618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
179648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
17965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
179668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
179678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
179698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
179718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
179728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
17974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
179751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
17977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
17979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
17980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
179828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
17983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
17984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
17985fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
17986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
17987fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
17988fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
17989fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17991fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
17992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
179948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
179968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
179988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
179998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
180038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
180048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
180058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
180068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
180078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
180118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
180128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
180138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
180148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
180178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
180198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
180208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
18022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
18023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
18024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
180258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
18027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
18029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
18030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
18031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
18032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
18035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
18036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
18039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
18040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
18043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
18044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
18047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
18048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
180508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
18051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
18052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
18053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
18054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
180568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
180588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
180598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
180608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
180618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
180628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
180638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18066fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
18067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
18069fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
18070fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
18071fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
18072fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
180758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
180798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
180808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
180848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
180858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
180898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
180908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
180918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
180991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
181031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
181071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
181151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1811862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
181191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18130570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
181314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
181329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18133570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18134570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18135570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18136570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18137570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18138570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1813974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1814074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1814174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18142570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1814374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18144570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1814574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18146570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18147fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18148fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18149fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18152fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1815874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18159570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18162fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18163570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18164570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18166570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18167570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18169570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18170570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18172570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18173570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1817474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18175570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18176570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18179570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18180570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18181570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18182570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1818474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18185570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18186fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18189fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
181951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1819774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1819874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1819974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1820074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
182011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
182021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
182031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
182041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
182051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
182061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
182070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
182081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
182091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
182101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
182111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18213850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1821407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18215850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18218570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18224570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18226570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18227570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18228570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18229570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18230570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18231570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18232570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18233570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18234570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18235570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18236570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18237570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18238570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18239570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18240570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18241570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18242570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18243570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18244570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18245570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18246570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18249570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18250570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18251570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18252570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18253570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18254570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18255570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18256570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18257570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18259570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18260570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
182618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
182628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18263570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18264570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18266570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18267570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18268570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18269570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18270570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18271570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18273570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18274570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18275570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18276570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18277570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18278570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18279570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18280570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18281570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18282570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18283570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18284570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18285570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18286570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18287570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18288570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18289570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18290570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18291570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18292570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18293570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18294570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18295570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18296570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18297570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18298570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18299570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18300570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18301570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18302570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18303570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18304570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18305570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18306570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18307570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18308570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18309570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18310570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18311570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18312570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18313570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18314570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18315570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18316570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18317570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18319570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18320570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18321570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18322570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18323570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18324570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18325570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18326570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18327570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18328570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18329570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18330570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18331570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18332570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18333570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18334570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18335570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18336570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18337570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18338570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18343570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18344570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18346570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18352570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18354570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18355570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18356570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18357570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18358570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18360570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18361570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18362570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18364570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18365570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18366570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18367570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18368570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18372570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18386570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18388570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18391570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18392570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
183931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
183941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
183951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
183961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
183971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
183981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
183991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
184001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
184011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
184021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
184031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
184041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
184081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1841107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1841407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1841507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1841607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1841707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18419850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1842007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1842207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1842307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1842407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1842507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18426e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1842707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1842807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1842907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1843007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1843107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1843207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1843307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1843407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1843507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1843607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1843707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1843807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1843907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1844007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1844107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1844207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1844307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1844407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1844507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1844607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18447e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1844807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18449e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18450e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18451e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18452e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18453e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18454e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18455e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1845607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1845707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1845807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1845907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18460e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18461e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18462e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18466dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1846962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
184709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
184729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
184749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
184759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
184769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18479570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            next if($tr_name{$Symbol});
184819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
184859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
184869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
184879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1849262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1849562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1849662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1849772930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1849862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1849962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1850062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
185019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1850262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1850362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1850462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1850562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1850662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1850762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1851362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1851662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1851762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
185189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1851962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1852062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1853462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
185529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
185571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
185801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
185839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
185856fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "macos")
18586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1858707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1858807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1858907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1859107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
185929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
185939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1859407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186006fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget eq "windows")
18601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18606a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
186079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
186089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18621f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        open(APP, "$ReadelfCmd -Ws \"$Path\" 2>\"$TMP_DIR/null\" |");
186229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
186259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
186269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
186279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
186289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
186299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
186309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
186329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
186339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
186349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
186369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
186389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
186399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
186409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
186419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
186509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
186519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
186529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
186539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
186549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
186559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
186569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
186579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
186589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
186599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
186609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
186619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
186629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
186639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
186649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
186659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
186669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
186689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
186699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
186709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
186719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
186739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
186749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18682fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
186839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
186849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
186859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
186869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1868774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
186889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
186899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
186909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
186919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
186929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
186939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
186949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
186959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
186969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
186979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
187009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
187029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
187039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
187049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
187059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
187099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
187101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
187119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
187129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
187139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
187149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
187151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
187169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
187179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
187189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
187199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
187209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
187219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
187229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
187231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
187249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
187259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
187269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
187271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
187289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
187299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
187309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
187319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
187329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1873307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
187349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1873507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
187369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1873707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
187389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1873907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
187409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
187429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
187439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
187449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18745570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
187469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
187479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
187489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1874974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
187501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
187519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18752e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
18753e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
18754e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
187559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
187569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
187579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
187599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
187609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
187611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
187629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
187639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
187649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
187651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
187661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
187679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
187689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
187691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
187701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
187719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
18772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
187739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
187749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1877574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1877674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Real_Path = realpath($Lib_Path);
1877774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1877874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1877974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1878074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1878174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1878274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1878374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1878474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
18785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
18786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1878774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
18788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1878974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1879074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
187919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
187929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
187939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
187949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
187959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
187969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
18798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1879962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
18800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
18801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1880257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1880357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1880457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1880557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1880657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1880757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1880857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1880957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1881057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1881157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1881257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1881357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1881457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1881557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
18816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18818dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
18819a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
188201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
18821dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
188221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
188231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
18824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
18825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1882607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
188274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
188284b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1883007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18831a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
188321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
188331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1883407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
188351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
188361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
188371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
188381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1883907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
188401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18843570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
18844570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18845570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
18846570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18847570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
18848570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1884974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
18850570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
18851570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18852570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18853570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18854570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1885507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
18856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
18857570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1885862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1885962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1886057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1886162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
18862570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18863570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1886462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1886662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18868570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18869570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
188709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
188719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
18872570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
188739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
188749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1888007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
188819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
188829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
188839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
188849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1888507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1888607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
188874b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
188884b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1888907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1889007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
188919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
188929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
188939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
188949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
188959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
188969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
188979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
18898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
188999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
18900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
18904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
18905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
18908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
189091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
18910a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
189111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
189121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
18913a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
189141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
189151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
189171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
189181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
189191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 1197 4AC 0000A620 SetThreadStackGuarantee
18922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 1198 4AD          SetThreadToken (forwarded to ...)
18923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 3368 _o2i_ECPublicKey
1892454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko          # 1 0 00005B30 ??0?N = ... (with pdb)
1892554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*(?:=.+)?\Z/i
18926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
1892754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            or /\A\s*\d+\s+_([\w\?\@]+)\s*(?:=.+)?\Z/)
18928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic, static and forwarded symbols
18929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $realname = $1;
1893062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1893162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1893257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1893362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1893462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1893562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1893662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1893862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
18941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
189429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
189439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
189449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
189459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
189469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
18952f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
189539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
189549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
189559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
189569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
189579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
189589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
189599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
189609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
189619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
189629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
189639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
18964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
189659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
18966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
18971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
18972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18976f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Cmd = $ReadelfCmd." -Ws \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18977a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
189781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
189791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
18980f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            system($Cmd." >\"$DebugPath\"");
189811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
189821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
189841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
18985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
189861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
18991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
189929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1899362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
189949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1899562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
189969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1899762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
189989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
189999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
19000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
190019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
19002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
190039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
19004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
190079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
19008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
190099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
19010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
19011570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
19012570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
19013570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1901474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
19015570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
19016570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19019c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
19020c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1902107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
19022c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
19023c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
19024c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
19025c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
19026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
190279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
190289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
190299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
19030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
19031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
19032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
19033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1903462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1903562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1903657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1903762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
190389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
190399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1904062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1904262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
190449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
190459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
190469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
190479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
190489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
190499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
190509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
190519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
190529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
190549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
190559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
190569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
190579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
190589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19062f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
19063f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        close(LIB);
19064f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19065f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Deps and $LIB_TYPE eq "dynamic")
19066f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # dynamic library specifics
19067f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Cmd = $ReadelfCmd." -Wd \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19068f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
19069f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19070f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            while(<LIB>)
19071f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
19072f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(/NEEDED.+\[([^\[\]]+)\]/)
19073f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # dependencies:
19074f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                  # 0x00000001 (NEEDED) Shared library: [libc.so.6]
19075f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $NeededLib{$1} = 1;
1907662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1907762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19078f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19079f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            close(LIB);
19080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
190829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
190839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
190859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1908974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
190919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
190929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
190949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19095a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
190969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
190979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
190989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
190999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
191019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
191029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19103a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19108fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19111fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19113fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19115fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19116fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19117fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19119fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19120fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19121fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19131fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
191389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
191399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19141fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1914274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1914374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1914474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1914574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1914674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
191479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
191549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
191579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
191589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
191599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
191609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
191619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
191629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
191639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
191659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
191669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
191679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
191689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
191699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
191709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
191719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
191729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19176e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19178e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19179e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19181e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19182e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19185e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
191862b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        my @Files = cmd_find($DevelPath,"f");
191872b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
191882b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        { # add symbolic links
191892b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if(-f $Link) {
191902b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                push(@Files, $Link);
191912b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
191922b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
19193e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19194ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for headers in /usr/lib
19195ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
19196ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
19197ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, @Headers);
19198e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19199e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19200e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19201e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
192029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19203e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19204e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19205e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19208e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19209ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"include"}})
19210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19211ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not -d $DevelPath);
19212ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for all header files in the /usr/include
19213ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # with or without extension (ncurses.h, QtCore, ...)
19214ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, cmd_find($DevelPath,"f"));
19215ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
19216ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # add symbolic links
19217ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(-f $Link) {
19218ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                push(@SysHeaders, $Link);
19219e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19222ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1922562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
192284b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
192374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
192438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
192471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
192481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
192631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
192661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
192738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
192748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
192758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
192768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
192778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
192798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
192808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
192818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
192828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
192838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
192848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
192858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
192868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
192878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
192888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
192898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
192908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
192918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
192928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
192938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
192968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
192978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
192988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
193018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
193028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
193048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
193058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
193068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
193078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
193088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
193108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
193118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
193128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
193138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
193148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
193158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
193168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
193178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
193188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
193198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
193208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
193218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
193228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
193238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
193248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
193258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
193278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
193288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
193298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
193308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
193318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
193328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
193338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
193348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
193358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
193368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
193378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
193388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
193398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
193408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
193418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
193428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
193448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
193458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
193478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
193488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
193518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
193548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
193558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
193568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
193578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
193588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
193598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
193608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
193628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
193638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
193648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
193658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
193668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
193698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
193708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
193718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
193728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1937362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1937462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1937562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1937662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1937762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1937862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1937962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
193808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
193818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
193828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
193838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
193848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
193878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
193888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1938962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1939062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1939162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1939262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
193971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
193981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19401f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $D (sort {$SkipHeaders{$LibVersion}{"Path"}{$a} cmp $SkipHeaders{$LibVersion}{"Path"}{$b}}
19402f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
194059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
194069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
194079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
194089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $P (sort {$SkipHeaders{$LibVersion}{"Pattern"}{$a} cmp $SkipHeaders{$LibVersion}{"Pattern"}{$b}}
19412f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1941462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1941562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1941662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1941762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1941862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1941962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1942062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1942162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19431570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
194428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
194439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
194469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
194479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
194489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
194499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
194509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1945154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
194529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1945307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
194546fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget=~/linux|bsd/i)
194552768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
194562768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
194572768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
194582768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
194599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1946057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1946157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
194629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1946354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19464b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(not $CheckedArch{$LibVersion} and -f $Path)
1946554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19466d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $ObjArch = getArch_Object($Path))
1946754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
19468d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            if($ObjArch ne getArch_GCC($LibVersion))
19469d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            { # translation unit dump generated by the GCC compiler should correspond to the input objects
19470d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $CheckedArch{$LibVersion} = 1;
19471d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey 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.");
1947254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1947354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1947454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1947554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko}
1947654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1947754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub getArch_Object($)
1947854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko{
1947954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $Path = $_[0];
1948054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1948154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my %MachineType = (
1948254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "14C" => "x86",
1948354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "8664" => "x86_64",
1948454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "1C0" => "arm",
1948554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "200" => "ia64"
1948654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    );
1948754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19488b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    my %ArchName = (
19489b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:31-bit" => "s390",
19490b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:64-bit" => "s390x",
19491b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common" => "ppc32",
19492b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common64" => "ppc64",
19493b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "i386:x86-64" => "x86_64",
19494b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "mips:3000" => "mips",
19495b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "sparc:v8plus" => "sparcv9"
19496b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    );
19497b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
194986fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "windows")
1949954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1950054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $DumpbinCmd = get_CmdPath("dumpbin");
1950154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $DumpbinCmd) {
1950254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
1950354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1950454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1950554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $DumpbinCmd." /headers \"$Path\"";
1950654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Out = `$Cmd`;
1950754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1950854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/(\w+)\smachine/)
1950954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1951054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(my $Type = $MachineType{uc($1)})
1951154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1951254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                return $Type;
1951354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1951454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1951554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
195166fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget=~/linux|bsd/)
1951754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1951854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
1951954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $ObjdumpCmd) {
1952054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
1952154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1952254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1952354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $ObjdumpCmd." -f \"$Path\"";
195246fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko
195256fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        if($OSgroup eq "windows") {
195266fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "set LANG=$LOCALE & ".$Cmd;
195276fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
195286fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        else {
195296fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "LANG=$LOCALE ".$Cmd;
195306fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
195316fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Out = `$Cmd`;
1953254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1953354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/architecture:\s+([\w\-\:]+)/)
1953454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1953554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $Arch = $1;
1953654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch=~s/\:(.+)//)
1953754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1953854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                my $Suffix = $1;
1953954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19540b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                if(my $Name = $ArchName{$Arch.":".$Suffix})
1954154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                {
19542b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                    $Arch = $Name;
1954354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                }
1954454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1954554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19546b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch=~/i[3-6]86/) {
1954754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86";
1954854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1954954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1955054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch eq "x86-64") {
1955154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86_64";
1955254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1955354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19554b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch eq "ia64-elf64") {
19555b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                $Arch = "ia64";
19556b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            }
19557b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
19558d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            return $Arch;
1955954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1956054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1956154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    else
1956254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    { # macos, etc.
1956354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        # TODO
1956454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1956554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1956654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    return undef;
195679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
195689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
195699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
195709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
195719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
195729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
195739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
195749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
195759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
195779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
195789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
195799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19580a914cb546e74ff89ff5038d0a57d6e7032617d80Lénaïc Huard    my $SonameCmd = "$ObjdumpCmd -x \"$Path\" 2>$TMP_DIR/null";
195819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
195829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
195839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
195859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
195869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1958754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`)
1958854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
195899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
195909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
195919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
195929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
195998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
196079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
196089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1961462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19615570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
196229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1962374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $Libs{realpath($Path)}=1;
19624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
196328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
196339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1963474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Libs{realpath($Path)}=1;
19635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19638570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
196418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
196459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1964674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $Libs{realpath($Path)}=1;
19647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1965162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
196581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
196591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
196601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
196611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19664d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getGCC_Opts($)
19665d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19666d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19667d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19668d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my @Opts = ();
19669d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19670d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($CompilerOptions{$LibVersion})
19671d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # user-defined options
19672d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $CompilerOptions{$LibVersion});
19673d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19674d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GccOptions)
19675d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # additional
19676d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $GccOptions);
19677d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19678d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19679d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(@Opts) {
19680d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return join(" ", @Opts);
19681d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19682d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19683d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return undef;
19684d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19685d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19686b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenkosub getArch_GCC($)
19687d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{
19688d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19689d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19690d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(defined $Cache{"getArch_GCC"}{$LibVersion}) {
19691d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return $Cache{"getArch_GCC"}{$LibVersion};
19692d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19693d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19694d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Arch = undef;
19695d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19696d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
19697d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    {
19698d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n");
19699d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19700d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." test.c -o test";
19701d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19702d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19703d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19704d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19705d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19706d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19707d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        system($Cmd);
19708d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19709d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19710d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $Arch = getArch_Object("$TMP_DIR/test");
19711d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19712d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test.c");
19713d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test");
19714d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19715d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19716d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Arch) {
19717d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check ARCH type");
19718d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19719d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19720d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return ($Cache{"getArch_GCC"}{$LibVersion} = $Arch);
19721d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19722d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1972354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub detectWordSize($)
19724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1972554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $LibVersion = $_[0];
1972654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19727d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Size = undef;
19728d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19729d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    # speed up detection
1973054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $Arch = getArch($LibVersion))
1973154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19732b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        if($Arch=~/\A(x86_64|s390x|ppc64|ia64|alpha)\Z/) {
19733d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "8";
19734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19735d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        elsif($Arch=~/\A(x86|s390|ppc32)\Z/) {
19736d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "4";
19737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19739d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19740d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
1974154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1974254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        writeFile("$TMP_DIR/empty.h", "");
19743d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19744d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." -E -dD empty.h";
19745d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19746d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19747d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19748d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19749d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19750d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19751d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Defines = `$Cmd`;
19752d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19753d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1975454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        unlink("$TMP_DIR/empty.h");
1975554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1975654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
1975754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 4
19758d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = $1;
1975954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1976054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
1976154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 3
1976254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $PTRDIFF = $1;
1976354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($PTRDIFF=~/long/) {
19764d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "8";
1976554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1976654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            else {
19767d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "4";
1976854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1976954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
19770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1977154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19772d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Size) {
19773d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check WORD size");
19774d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19775d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19776d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return $Size;
19777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19779d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getWordSize($)
19780d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19781f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
19782f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
19783f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
19784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
19785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
19787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
19788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
19789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
19790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
197931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
19794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
19795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
19796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
19797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
19798570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
19799570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
19800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
19801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
19802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
19804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
19805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
19809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
19811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
19812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
198139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
19814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
19815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
19816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
19819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
198209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
198219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
198229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19824850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1982501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
19826850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1982701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
1982801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
1982901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
1983001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
1983101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
19832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1983301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
1983401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
1983501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
1983601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
1983701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
1983801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
1983901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1984001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
1984101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
1984201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
1984301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1984401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
1984501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
1984601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1984701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
1984801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
1984901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
1985001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
19851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
19853570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
1985401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
19855570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
19856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
19857570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
19858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19859570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
1986052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $UsedDump{$LibVersion}{"M"} = $ABI->{"LibraryName"};
19861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1986299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($ABI->{"PublicABI"}) {
1986399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        $UsedDump{$LibVersion}{"Public"} = 1;
1986499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
1986599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
19866fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
19867fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
19868570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
19869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19870570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
19871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19872fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
19874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19875fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
19876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19877570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
19878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19879fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
198806ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko
19881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
198826ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
198836ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)");
19884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
19887fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
19888fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
19889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
19890fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19891fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
19892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1989315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if(not $TargetComponent_Opt)
1989415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        {
1989515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            if($ABI->{"LibraryName"}=~/\.ko[\.\d]*\Z/) {
1989615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "module";
1989715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
1989815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            else {
1989915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "object";
1990015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
1990115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
19902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
199045c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
199055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
199065c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
199071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1990801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
199091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
199101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
199111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
199125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
199135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
199145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
199155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
19916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1991701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
1991801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
19919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
19920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
19921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1992274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
1992374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
1992474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1992574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1992601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
19927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
19929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
19930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1993162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
1993201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
1993362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1993462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
19935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
1993601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
1993762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
1993862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
1993901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
1994062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1994162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
1994262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
1994362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1994462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
1994562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1994662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
1994762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
19948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
1994962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1995062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1995162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
1995262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
1995362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1995462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
1995562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
1995662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1995762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
1995862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1995962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
1996062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1996162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1996262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
1996362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
19965177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
19966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
19967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
19968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
1996962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1997062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1997162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1997262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
1997362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1997462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
1997562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1997662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1997762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1997862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
1997962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1998062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
1998162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
1998262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1998362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
1998462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
1998562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
19986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
1998762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
19988fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
1998962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1999062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1999162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
1999262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
19993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1999401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
1999501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
19996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
19997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1999801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
19999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
20001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
20002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
20003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
20004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2000662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2000701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
20008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2000962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
2001062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2001101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
2001262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
2001301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
2001462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2001562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
2001662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
2001762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
2001862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
2001962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
2002062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2002162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
2002262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
2002362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2002501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
20026d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
20027d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if(my $V = $TargetVersion{$LibVersion}) {
20028d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $V;
20029d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20030d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    else {
20031d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
20032d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20033d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
20034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipTypes{$LibVersion})
2003599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    { # if not defined by -skip-types option
2003699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"SkipTypes"})
2003799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2003899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"SkipTypes"}}))
2003999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2004099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2004199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2004299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2004399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"OpaqueTypes"})
2004499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        { # support for old dumps
2004599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"OpaqueTypes"}}))
2004699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2004799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2004899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2004999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
20050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20051ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
20052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
20053ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -skip-symbols option
20054ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
20055ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
20056ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20057ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
20058ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
20059ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
20060ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20061ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
20062ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
20063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2006401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
20065ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
20066ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if(not $TargetHeaders{$LibVersion})
20067ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -headers-list option
20068ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
20069ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
20070ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
2007101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
20072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2007301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
20074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2007501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
20076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
200772c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
20078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
2007901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
200802c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
200815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
200825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
20083850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
20084850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
200853e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
200872c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
200882c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        if(not $ABI->{"PublicABI"})
200892c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        {
200902c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            foreach (keys(%{$Registered_Sources{$LibVersion}})) {
200912c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
200922c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            }
20093fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2009501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
20096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
20097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
20098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
20099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
20100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20101fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20102fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2010301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
20104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
20105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
20106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
20107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
20108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
20109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
20111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
20112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
20113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
2011401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
20115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
20117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
20118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2011962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
20120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2012162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2012262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
20123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
20124fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
20125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
201269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
201279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
201289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
201299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
201309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
20131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2013462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
2013562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2013662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
2013762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2013862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2013962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2014062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
201421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20144f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
2014562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2014662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
2014762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
2014862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
2014962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
20150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
20153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2015462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
2015562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
20157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
20160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
20161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
20162fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
20163fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
20164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
20165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
20166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20169177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
20170177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
20171177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20172177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20173177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
20174177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20175177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
20176177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
20177177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20178177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20179177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20180177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20181177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20182177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20183177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
201843e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
201853e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
201863e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
201873e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20188177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20189177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20190177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20191177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20192177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20193177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20194177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20195177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20196177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20197177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20198177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20199177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20200177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2020174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2020274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2020374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2020474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2020574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2020674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2020774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2020874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2020974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2021074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2021174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2021374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2021474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2021574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2021674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2021774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2021874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2021974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2022074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2022174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2022274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2022374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2022474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2022574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2022674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2022774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2022874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2022974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2023074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2023174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2023262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20233f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    { # order is important
2023462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2023562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2023662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2023762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2023862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2024062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2024162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2024462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2024562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2024662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2024762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
202489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
202499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
202509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
202519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20253fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20254fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20255fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2025601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2025701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2025801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2025962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2026062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2026162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
202621b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            foreach my $SubId (keys(%{$TInfo{"Base"}}))
202631b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            {
202641b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($SubId eq $TypeId)
202651b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                { # Fix erroneus ABI dump
202661b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$TypeId}{"Base"}{$SubId});
202671b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    next;
202681b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                }
202691b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko
202701b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$SubId}{$TypeId} = 1;
2027162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2027262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2027301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2027401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2027501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2027601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2027701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2027801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2027901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2028001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2028101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2028201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2028301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2028401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2028501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2028601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2028701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20289fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20292fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2029362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2029562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2029662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2029762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2029862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2029962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2030062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2030162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2030262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
203038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2030462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2030562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2030662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2030762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2030862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2031062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2031162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2031262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TName_Tid{$LibVersion}{formatName($TInfo{"Name"}, "T")} = $TypeId;
2031462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2031562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2031662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2031762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2031862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2031962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2032062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2032162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2032262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2032462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2032562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2032662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2032762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20330b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20331b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2033262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2033362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20338f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20339f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20340ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20341ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20342ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20343ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20344ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20345ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20346ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20347ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20348ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20349ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20350ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20351ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20352ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20353ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20354ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20355ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20356ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20357ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20358ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20359ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20360ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20361f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20362f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20363f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20364f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
203659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
203669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
203679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
203689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20373f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20374f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2038001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2038101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2038201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2038401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2038501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2038901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2039562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2040062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2040262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2040362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2040462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2041701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2041801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2042401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
204259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
204269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
204279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
204289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
204299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2043801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20439fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2044001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2044401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
204456ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2044701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
204556ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
204658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
204929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20498ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckHeadersOnly = 1;
20499ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20500ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==1) {
20501ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "X";
20502ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20503ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20504ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==2) {
20505ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "Y";
20506ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20507ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20533a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20534a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20535a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20536a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2053774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2053874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2053974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2054074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2054174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2054274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20560a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20561a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2056674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2056774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2056874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2056974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2057074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2057174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2057274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2057374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2057474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2057882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20601570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20607570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20609a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
206101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20611570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20612570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2061574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Path = realpath($1);
20616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = path_format($Path, $OSgroup);
20617570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20620570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20631570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20632570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20642570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
20662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
20664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
20665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20666570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
20667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20671570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
206726fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    { # <search_libs> section of the XML descriptor
206736fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko      # do NOT search for systems libraries
20674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
20677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
20678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
20679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
20680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
20681570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
20682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
20684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
20685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
20686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
20687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
20688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
20689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
20690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
20691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
20692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
20693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
20694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
20695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20696570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
20697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
20698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
20699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
20700570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
20701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
20703570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
20704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
20707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
20708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
20709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
20710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
20711570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
20712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
20719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
20720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
20722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
20723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
207244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
20725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
207264b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
207274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
207284b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
207294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
207304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
207314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
20732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
20737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
20738570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
20741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20742570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
20743570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
20744570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
20745570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
20749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
20750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
20751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
20752570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
20753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
20754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
20757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
20758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
20759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
20762570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
20763570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
20764570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20766570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
20767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20768570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
20769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
20773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
20774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
20775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
20776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
20777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
20779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
20780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
20781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
20784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
20786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
20791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
20792570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
20793570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
20794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
20795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2079601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2079701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
20798570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2079901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
208008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2080101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2080201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2080301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2080401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2080501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2080601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2080701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2080801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2080901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2081001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
20813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20814f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
20815ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $GCC_Ver = get_dumpversion($GCC_PATH))
20816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20817ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $GccTarget = get_dumpmachine($GCC_PATH);
20818ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20819ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GccTarget=~/linux/)
20820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20821ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "linux";
20822ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20824ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            elsif($GccTarget=~/symbian/)
20825ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            {
20826ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "symbian";
20827ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20829ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20830ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget, target: ".getArch_GCC(1).")");
20831ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20832ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            # check GCC version
20833ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GCC_Ver=~/\A4\.8(|\.[012])\Z/)
20834ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57850
20835ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                # introduced in 4.8
20836ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                # fixed in 4.8.3
20837ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                printMsg("WARNING", "Not working properly with GCC $GCC_Ver. Please update or downgrade GCC or use a local installation by --gcc-path=PATH option.");
20838ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $EMERGENCY_MODE_48 = 1;
20839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20841ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
20842ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "something is going wrong with the GCC compiler");
20843ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
20844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
20846ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
20847ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # GCC standard paths
20848ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($GCC_PATH and not $NoStdInc)
20849ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
20850ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my %DPaths = detect_inc_default_paths();
20851ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultCppPaths = @{$DPaths{"Cpp"}};
20852ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultGccPaths = @{$DPaths{"Gcc"}};
20853ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultIncPaths = @{$DPaths{"Inc"}};
20854ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            push_U($SystemPaths{"include"}, @DefaultIncPaths);
20855ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
20856ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20857ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # users include paths
20858dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
20859dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
20860dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
20861dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
20862dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
20863570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2086674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2086774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2086874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2086974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2087074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2087174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
20872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
20875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
20878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
20881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
20884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
20893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
20897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
20898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20899a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
20900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
20901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
20902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
20905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
20909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
20910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20911a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
20912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
20913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
20914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20916570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
20917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
20923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20926a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
20927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
20928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2093462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2093662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2093762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2093862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2093962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
20940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2094162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2094262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2094362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2094462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2094562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2094662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2094762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2094862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
20949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
209549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
20955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
20957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20959570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
20960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20961570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
20962570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20963570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
20964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20965570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
20966570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20967570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
20968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20969570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
20970570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
20971570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20972570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
20973570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
20974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20976570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
20977570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
20978570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20979570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
20980570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
20981570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
20982570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20983570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20985570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
20986570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20987570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
20988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20989570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
20990570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
20991570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
20993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20996570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
20997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
21000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
210019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
210029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
210039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
21004dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
210059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
210069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
210079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
210089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
210099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
210109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
21011fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
21013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
21014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
21016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
21017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21019fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
21020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
21021a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
21022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
21023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
21024a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
21025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
21027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
21032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
21033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21037a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
21038a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
21039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
21040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
21041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
21043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
21044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
21045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
21046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
21051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
21056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
21057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
21064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
21067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
21068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
21069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
21071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
21075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
21079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
21080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
21081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
21082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
21085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
21096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
21100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
21101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
21107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
21111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
21112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
21113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
21120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
21127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
21129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
21130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
21131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
21132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
21133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
21134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
21135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
21138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
21140ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
21142ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    prepareSymbols(1);
21143ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
21145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
21146ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
21148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
211511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
211541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
21155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
21156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
21159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
211601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
21164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
211651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
21169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
21170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
21172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
21173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
21174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
21177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
21179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2118074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
21181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
21183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
211841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
21185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
21186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
21187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
21188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2119162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
211961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
211979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2121762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2121862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2121962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2122062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2122162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2122362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
212241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
212251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
212261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
212301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
2123241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    <br/><br/>\n".getReportFooter()."
2123352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    </body></html>";
21234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
212379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
212389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
212399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
212409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
212419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
212429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
212439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21247a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21248a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21249a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
21250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21262850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21264850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21265850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
212821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2128462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21290989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21298989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21299989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
213421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
213431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
213441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
213461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
213471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
213481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
213501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
213511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
213861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
213871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
213881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
213891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
213901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
213911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
213931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
213941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
213951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
213971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
213981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
213991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
214011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
214031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
214061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
214081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
214091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
214101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
214121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
214131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
214141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
214161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
214181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
214211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
214231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
214241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
214251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
214271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
214291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
214321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
214331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
214341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
214351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
214361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
214371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
214381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
214391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
214401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
214411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
214421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
214431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
214441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
214461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
214471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
214481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
214501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
214521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
214531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
214541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
214561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
214571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
214591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
214631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
214641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
214651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
214671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
214681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
214691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
214711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
214721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
214741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
214751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
214761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
214771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
214781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
214811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
214821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
214841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
214851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
214871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
214881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
214901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
214911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
214921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
214931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
214951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
214961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
214981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
214991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
215011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
215021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
215041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
215051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
215061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
215071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
215101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
215120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
215131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
215141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
215161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
215171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
215181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
215211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
215230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
215241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
215251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
215271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
215281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
215291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
215311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
215321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
215331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
215351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
215361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
215371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $ENV{"DevEnvDir"}
21544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $ENV{"LIB"}) {
21545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't start without VS environment (vsvars32.bat)");
21546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
215495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
215505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
215515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
215525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
215535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
215545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
215555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
215565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
215575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
215585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
215595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
215605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
215615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
215625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
215635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
215645c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
215655c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
215666bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenkosub defaultDumpPath($$)
215676bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko{
215686bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my ($N, $V) = @_;
215696bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    return "abi_dumps/".$N."/".$N."_".$V.".abi.".$AR_EXT; # gzipped by default
215706bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko}
215716bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko
21572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2157754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
21578ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($DumpAPI)) {
21579ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $DumpAPI);
21580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21581ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21582ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $DumpAPI));
21583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21586ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # set to default: N
21587ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $Descriptor{1}{"Version"} = "N";
21588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2159274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
215936bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my $DumpPath = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
215948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
215958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
215968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2159774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
215988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
215998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
216008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
216018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
216028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
216038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
216048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
216058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
216068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
216078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2160874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
216098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
216108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
216118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
216128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
216138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
216148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
216158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
216168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
216178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
216188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2161974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2162074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2162174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2162201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2162301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2162401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2162501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2162601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2162701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2162801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2162901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21630ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2163154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
21632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2163301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2163401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2163501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2163601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2163701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
21640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
21641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
21642ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
21643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
21645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
21646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
21649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
21653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
21654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
21655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
21657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
21658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
21659570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21661570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
21662570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
21663570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21664570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21665570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
21666570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21667570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21668570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
21669570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21670570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
21671570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
21672570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
21673570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
21674570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
21675570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21676570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21677570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21678570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
21679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
21681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
21682fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
21683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
21684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
21685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
21686fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
21687fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
21688fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21689fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2169101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
21692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
21693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
21694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2169562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
21696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
21697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
21698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
21699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
21700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
21701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
21702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
21703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
21704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
21705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
21706fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
21707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
21708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
21709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
21710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
21711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
21712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
21713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
21714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
217155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2171601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
217175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
217185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2171901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
217205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
21721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
21722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2172301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
21724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
217261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2172701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
217281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2172974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
21730fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2173174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
21732fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
21733fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2173474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
217355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
217365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
217375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
217385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
217395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2174001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
217415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
217421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
217431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2174401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
217451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
21746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
21747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
217485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
21749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
21750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
21751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
21754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
21755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
217565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
217575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
217585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
217595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
21761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
217635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
21764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
21765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
21767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
21768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2176907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2177007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
217715c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2177207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
21773ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
21774ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $OutputDumpPath");
21775ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
21776ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
217775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $DumpPath");
217785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
21779ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
21780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
21784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
21785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # 4 times faster than merging equal dumps
21786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
21787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
21788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
21789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
21790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
21791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
21792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath1 = unpackDump($Descriptor{1}{"Path"});
21794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath2 = unpackDump($Descriptor{2}{"Path"});
21795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
21796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2179701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2179801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2179901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2180001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2180101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2180201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2180301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
21804850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
21805850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21806850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
21807850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
21808850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
21809850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21810850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP2, $FilePath2);
21811850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content2 = <DUMP2>;
21812850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP2);
21813850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21814850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Content1 eq $Content2)
21815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21816850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21817850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
21818850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
21820850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
21821850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21822850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
21824850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
218269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
21827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
218291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
21831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
218331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
21835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
21837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
21838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
21839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
218401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
218411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
218421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
218431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
218441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Binary"}} = %{$ABIdump->{"SymbolInfo"}};
218451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Source"}} = %{$ABIdump->{"SymbolInfo"}};
218461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
21848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
21849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
21850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
21856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
21859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
21860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
21861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
21862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
21863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
21866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $LOG_PATH{$LibVersion} = get_abs_path($LOG_DIR)."/".$LOG_FILE;
21868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
21869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
21870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2187174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2187274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2187374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2187474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2187574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
21876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2187735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
21878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
21881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
21883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
21885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
21889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
21892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
21893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2189435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2189535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2189635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
21897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
21901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
21905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
21909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21910b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz(\.\w+|)|\.zip|\.xml|)\Z/)
21911b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    { # NOTE: name.abi.tar.gz.amd64 (dh & cdbs)
219129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
219139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
219149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
219159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
219169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
219179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
219189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
21919b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)\Z/) {
21920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
21921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
21923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
219251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
21926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
21928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
219290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
21930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21931ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{1}{"Path"}) {
21932ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{1}{"Path"}."\'");
21933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21934ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
219360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
21937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21938ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{2}{"Path"}) {
21939ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{2}{"Path"}."\'");
21940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21941ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
21943ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})
21944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{2}{"Path"}))
21945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # optimization: equal ABI dumps
21946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        quickEmptyReports();
21947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21948ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
21950ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21951ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})) {
21952ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $Descriptor{1}{"Path"});
21953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21954ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21955ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $Descriptor{1}{"Path"}));
21956ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
21957ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21958ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{2}{"Path"})) {
21959ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(2, $Descriptor{2}{"Path"});
21960ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
21961ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21962ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(2, createDescriptor(2, $Descriptor{2}{"Path"}));
21963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
21967fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
2196815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #1 is not set (use --v1=NUM option)\n";
21969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21970fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
21972fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
21973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
2197415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #2 is not set (use --v2=NUM option)\n";
21975fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21976fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
219772c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{1}{"V"}) {
219782c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(1);
219792c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
219802c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
219812c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{2}{"V"}) {
219822c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(2);
219832c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
21984ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21985ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # check input data
21986ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}) {
21987ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d1");
21988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21989ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}) {
21990ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d2");
21991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21992ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21993ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $CheckHeadersOnly)
21994bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21995ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{1}{"Libs"}) {
21996ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d1");
21997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21998ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{2}{"Libs"}) {
21999ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d2");
22000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22002ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
22004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
220066bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath1 = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
220076bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath2 = defaultDumpPath($TargetLibraryName, $Descriptor{2}{"Version"});
2200874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2200974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2201074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2201174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
22012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
22013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
22014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
22015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
22016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
22017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
22018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
22020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
22021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22025dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22029dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22031dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22032dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
22041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
22042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22043850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22045850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22048850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2204962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2205062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2205162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2205201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2205301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2205401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22055f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22056f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22057f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22058850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22059850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22060850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2206162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22062850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2206474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
22065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
22069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
22070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
22071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
22072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
22075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
22076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22080dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22081dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22083dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22085dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22086dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22087dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
22096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
22097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22098850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22099850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22100850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22101850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22102850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22103850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2210462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2210562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2210662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2210701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2210801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2210901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22110f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22111f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22112f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2211662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2211974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
2212714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko
22128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2212974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2213074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
2213114b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        if($TargetTitle ne $TargetLibraryName) {
2213214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-title", $TargetTitle);
22133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2214035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2214135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22143dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
221481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
221491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
221501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
221511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
221521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
221531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
221541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
221551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
221561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
221571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
221581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
221591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22160f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22161f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22162f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22163f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22164f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22165f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22166f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22167f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2216962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2217062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2217162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2217262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22173850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22191ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2219254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
22193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22202ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(2);
2220354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize(2);
22204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2220862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2221362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2222262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2222362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22236ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # process input data
22237ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{1}{"Headers"}
22238ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{1}{"Dump"}) {
22239ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(1);
22240ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22241ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{2}{"Headers"}
22242ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{2}{"Dump"}) {
22243ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(2);
22244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22245850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22247850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22248850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
222501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
222511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
222521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
222541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
222551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
222571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
222581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
222591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2226062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2226162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
222621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
222631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
222641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
222651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
222661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
222671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
222681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
222691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
222701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
222711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
222721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
222731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
222741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
222761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
222771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
222791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
222801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
222821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
222831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
222841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
222851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
222861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
222871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
222881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
222891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
222901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
22291ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
222921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22293f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
22294ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
222951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
222961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
222971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
222991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
223001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22301ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
223021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
223031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
223051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
223061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
223091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
223101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
223111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
223121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22313ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22314ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    mergeSymbols($Level);
22315ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(keys(%{$CheckedSymbols{$Level}})) {
22316ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        mergeConstants($Level);
223171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22318f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
22319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Cache{"mergeTypes"} = (); # free memory
22320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
223211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
223221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
223231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
223241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
223251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
223261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
223271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
223281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
22329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
223329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
223489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
223499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
223509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
223519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2235674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
223671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22369dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22370dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22371dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22372dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
223871fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
223881fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalSymbols) {
223891fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $SkipInternalSymbols=~s/\*/.*/g;
223901fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
223911fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
223921fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalTypes) {
223931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $SkipInternalTypes=~s/\*/.*/g;
223941fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
223951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
22396e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22397e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22398e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
223995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
224005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2240174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
224025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
224035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
224045c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
224051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
224061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
224071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
224085e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        if(not $CmpSystems)
224095e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        {
224105e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $BinaryOnly = 0;
224115e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $SourceOnly = 0;
224125e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        }
224135e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
224141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
224151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
224165e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
224171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
224181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
224191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
224201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
224211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
224221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
224241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
224251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
224261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
224271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
224291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
224301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
224315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
224321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
224351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
224361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
224375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
224391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
224401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
224411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
224421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
224431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
224441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
224451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
224461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
224525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
224535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
224545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
224555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
224565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
224575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
224585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
224595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
224605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
224615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
224625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
224635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2246401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
224655c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
224665c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
224734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22474570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22475570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
224808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
224818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
224828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
224838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22484570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22485570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22489ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if($InfoMsg)
22490ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
22491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22494570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22495570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2249652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        printMsg("INFO", "ABI Compliance Checker (ABICC) $TOOL_VERSION\nCopyright (C) 2015 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.");
22497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22499570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22500570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22519989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2252062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2252162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2252262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2252362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2252462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22525989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath))) {
22532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetLibs{$Lib} = 1;
22533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
225421fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{1}{get_filename($Header)} = 1;
225431fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{2}{get_filename($Header)} = 1;
22544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
225481fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{1}{get_filename($TargetHeader)} = 1;
225491fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{2}{get_filename($TargetHeader)} = 1;
22550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22556f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
22557ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly);
22558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
2256252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2256352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not $TargetSysInfo) {
2256452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Error", "-sysinfo option should be specified to dump system ABI");
2256552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2256652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2256752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -d $TargetSysInfo) {
2256852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$TargetSysInfo\'");
2256952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2257052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
22571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
225729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
22573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
22574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
22575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
22576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22577e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22578e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $SDesc = readFile($DumpSystem);
22579e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            if(my $RelDir = $RelativeDirectory{1}) {
22580e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko                $SDesc =~ s/{RELPATH}/$RelDir/g;
22581e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            }
22582e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22583e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $Ret = readSystemDescriptor($SDesc);
225849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
225859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
22586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
22587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
22588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
22590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
22591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
22594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
22595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
22596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
22598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
22599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
22601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
22602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
22604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
22605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
22610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
22611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
22612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
22613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
22614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
22615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
22616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
22617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
22618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
22619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
22622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
22624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
22625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
22626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
22627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
22628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
226299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
22630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
22633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
22634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
22635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
226369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
22637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryName) {
22640570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Error", "library name is not selected (-l option)");
22641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate library name
22644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryName=~/[\*\/\\]/) {
22645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
22646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2264814b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko    if(not $TargetTitle) {
2264914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $TargetTitle = $TargetLibraryName;
22650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22651ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
22653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
22655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
22656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
22658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
22659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2266152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($TypesListPath)
2266252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
2266352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -f $TypesListPath) {
2266452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TypesListPath\'");
2266552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2266652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($TypesListPath))) {
2266752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $TypesList{$Type} = 1;
2266852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2266952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
22670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
22671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
22673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
22674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22675a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath)))
22676a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        {
22677a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{1}{$Interface} = 1;
22678a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{2}{$Interface} = 1;
22679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
2268199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($SkipTypesListPath)
2268299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    {
2268399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(not -f $SkipTypesListPath) {
2268499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipTypesListPath\'");
2268599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2268699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($SkipTypesListPath)))
2268799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2268899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{1}{$Type} = 1;
2268999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{2}{$Type} = 1;
2269099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2269199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
22692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
22693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
22695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
22696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
226981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
226991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
227001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
22701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
22702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
22703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
22704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
22707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
22709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
22710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
22712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
22714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2271662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2271762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
22719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
22720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2272262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2272362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
22725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
22726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
22727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
22733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
22735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
22736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22737ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22738ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        detect_default_paths("bin|gcc");
227391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
22740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
22741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
22744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
22745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
22746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
22747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
22748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
22750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
22751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
227521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
227531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
227541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
227551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
227561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
227571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
227581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
227591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
227601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
227611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
227621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
227631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
22765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
22768